ULX

Author Topic: Variables  (Read 2531 times)

0 Members and 1 Guest are viewing this topic.

Offline dankpepe

  • Jr. Member
  • **
  • Posts: 51
  • Karma: 1
Variables
« on: May 17, 2016, 12:10:28 PM »
I'm using this code:

Code: [Select]

function ulx.undercover( calling_ply, name, should_revoke )
   
local ply_name = calling_ply:GetName()
local rank = calling_ply:GetUserGroup()
id = calling_ply:SteamID()
ULib.ucl.userAllow(id,"ulx uncover",false)

    if not should_revoke then
    calling_ply:setRPName(name)
    else
    calling_ply:setRPName(ply_name)
    end

    if not should_revoke then
    calling_ply:SetUserGroup("user")
    else
    calling_ply:SetUserGroup(rank)
    end
end


local undercover = ulx.command( CATEGORY_NAME, "ulx undercover", ulx.undercover, "!undercover", true )
undercover:addParam{ type=ULib.cmds.StringArg, hint="Name to change", ULib.cmds.takeRestOfLine }
undercover:defaultAccess( ULib.ACCESS_ADMIN )
undercover:help( "Makes you go undercover" )
undercover:setOpposite( "ulx uncover", { _, true }, "!uncover", true )


Starting it works fine, but when I try to revoke I get an error. The error is 17 lines in a batch file so I'm not gonna type the whole thing out unless you need it. The first part says: [ERROR] gamemodes/darkrp/gamemode/modules/base/sv_data.lua:226: bad argument #1 to 'len' (string expected, got boolean)

I know what this means, it's trying to set my name to true or false, but I don't know why. In the code I used 1 =, not 2, so it should be setting the variable.

Offline dankpepe

  • Jr. Member
  • **
  • Posts: 51
  • Karma: 1
Re: Variables
« Reply #1 on: May 17, 2016, 12:12:33 PM »
I tried adding print(ply_name) and print(rank) after  if not should_revoke then calling_ply:setRPName(name), and it printed the data fine. I don't know why this isn't working

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Variables
« Reply #2 on: May 17, 2016, 01:11:51 PM »
Is that the paste of the entire code/the entire error? You just said the first part of the error said that, what about the rest?
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline dankpepe

  • Jr. Member
  • **
  • Posts: 51
  • Karma: 1
Re: Variables
« Reply #3 on: May 17, 2016, 01:44:27 PM »
The entire error is:

Code: [Select]

[ERROR] gamemodes/gamemode/modules/base/sv_data.lua:226: bad argument #1 to 'len' (string expected, got boolean)
1. len - [C]:-1
2. storeRPName - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:226
3.callback - gamemode/darkrp/gamemode/modules/base/sv_entityvars.lua:207
4.callback - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:235
5. query - gamemode/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:302
6.retrieveRPNames - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:234
7.setRPName - gamemodes/darkrp/gamemode/modules/base/sv_entityvars.lua:191
8. call - addons/danker_commands/lua/ulx/modules/sh/undercover.lua:12
9.__fn - addons/ulib/lua/ulib/shared/commands.lua:943
10. unknown - addons/ulib/lua/ulib/shared/commands.lua:1296
11. Run - lua/includes/modules/comcommand.lua:54
12. unknown - addons/ulib/lua/ulib/shared/commands.lua:1211
13. unknown - lua/includes/modules/concommand.1


Also worth noting, when I change back, which doesn't work, it says [my name] changed their name to true, but it stays the same.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Variables
« Reply #4 on: May 17, 2016, 01:51:36 PM »
The entire error is:

Code: [Select]

[ERROR] gamemodes/gamemode/modules/base/sv_data.lua:226: bad argument #1 to 'len' (string expected, got boolean)
1. len - [C]:-1
2. storeRPName - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:226
3.callback - gamemode/darkrp/gamemode/modules/base/sv_entityvars.lua:207
4.callback - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:235
5. query - gamemode/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:302
6.retrieveRPNames - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:234
7.setRPName - gamemodes/darkrp/gamemode/modules/base/sv_entityvars.lua:191
[b]8. call - addons/danker_commands/lua/ulx/modules/sh/undercover.lua:12[/b] [b][i][u]here[/u][/i][/b]
9.__fn - addons/ulib/lua/ulib/shared/commands.lua:943
10. unknown - addons/ulib/lua/ulib/shared/commands.lua:1296
11. Run - lua/includes/modules/comcommand.lua:54
12. unknown - addons/ulib/lua/ulib/shared/commands.lua:1211
13. unknown - lua/includes/modules/concommand.1


Also worth noting, when I change back, which doesn't work, it says [my name] changed their name to true, but it stays the same.

Number 8 is where it's being referenced to your code. Can you paste line 12 of your code? It's kind of difficult to tell which line is which when you have it pasted like that. (Next time, add =lua after the "code" in tag ([c ode=lua]))
« Last Edit: May 17, 2016, 01:53:47 PM by iViscosity »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given