Ulysses Stuff > General Chat & Help and Support

Can someone help me check if "message" is something in a table

(1/1)

fubar:
Trying to make it so if the user is entering a weapon that is banned, it will not work!

--- Code: ---local CN= "Trainer"

local bannedSweps = { }
bannedSweps["weapon_keypadchecker"] = true
bannedSweps["arrest_stick"] = true
bannedSweps["door_ram"] = true
bannedSweps["keys"] = true
bannedSweps["pocket"] = true
bannedSweps["unarrest_stick"] = true
bannedSweps["weaponchecker"] = true
bannedSweps["weapon_nav_editor"] = true
bannedSweps["manhack_welder"] = true
bannedSweps["tbfy_manager"] = true
bannedSweps["weapon_vape_mega"] = true



function ulx.give( calling_ply, target_ply, message )

if message == (bannedSweps[""]) then

print("That weapon is banned!")
else

target_ply:Give( message )
end
ulx.fancyLogAdmin( calling_ply, true , "#A gave #T a ".. message ,target_ply)

end

local give = ulx.command( CN, "ulx give", ulx.give , "!give" , true )
give:addParam{ type=ULib.cmds.PlayerArg, target="*"}
give:addParam{ type=ULib.cmds.StringArg, hint="weapon"}
give:defaultAccess( ULib.ACCESS_ADMIN )
give:help( "Gives a certain player a weapon" )
--- 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