General > Developers Corner

ULX Custom command to set a var

(1/2) > >>

Best Wukong NA:
I'm not sure if this should be posted in developers corner or general chat but I think this is the right place.
I'm trying to make a custom command that sets the rank of a player. The rank NWInt is ("playerLvl")
How do I make a number input that sets the NWInt("playerLvl") to the number thats chosen?
I've already looked at the ulx slap as an example but I couldn't find it.


--- Code: ---local CATEGORY_NAME = "BFA"

function ulx.rank ( calling_ply, target_ply, level )
local affected_plys = {}
for i=1, #target_plys do
   local v = target_plys[ i ]
   v:SetNWInt("playerLvl",level)
   table.insert( affected_plys, v )

   ulx.fancyLogAdmin(calling_ply, true, "#A has changed the rank of #T",target_ply)
   end
end

local rank = ulx.command (CATEGORY_NAME,"ulx rank",ulx.rank,"!rank",true)
rank:addParam{type=ULib.cmds.PlayerArg}
rank:defaultAccess(ULib.ACCESS_ADMIN)
rank:help("Sets the rank of a player")

--- End code ---

An Error Has Occurred!

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

[0] Board index

Go to full version