Author Topic: Can someone help me check if "message" is something in a table  (Read 1612 times)

0 Members and 1 Guest are viewing this topic.

Offline fubar

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Trying to make it so if the user is entering a weapon that is banned, it will not work!
Code: [Select]
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" )

An Error Has Occurred!

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