ULX

Author Topic: ULX Slay command with a Reason.  (Read 4474 times)

0 Members and 1 Guest are viewing this topic.

Offline CheesyViking

  • Newbie
  • *
  • Posts: 10
  • Karma: 0
ULX Slay command with a Reason.
« on: September 06, 2013, 05:46:20 AM »
Hey, I'm Ricky and I'm just trying to figure out how to add a reason to the slay command.
Code: [Select]
function ulx.slay( calling_ply, target_plys )
local affected_plys = {}

for i=1, #target_plys do
local v = target_plys[ i ]

if ulx.getExclusive( v, calling_ply ) then
ULib.tsayError( calling_ply, ulx.getExclusive( v, calling_ply ), true )
elseif not v:Alive() then
ULib.tsayError( calling_ply, v:Nick() .. " is already dead!", true )
elseif v:IsFrozen() then
ULib.tsayError( calling_ply, v:Nick() .. " is frozen!", true )
else
v:Kill()
table.insert( affected_plys, v )
end
end

ulx.fancyLogAdmin( calling_ply, "#A slayed #T", affected_plys )
end
local slay = ulx.command( CATEGORY_NAME, "ulx slay", ulx.slay, "!slay" )
slay:addParam{ type=ULib.cmds.PlayerArg }
slay:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
slay:defaultAccess( ULib.ACCESS_ADMIN )
slay:help( "Slays Target." )

That is what i've got so far, but it prints this error into console.
addons/ulx/lua/ulx/modules/sh/fun.lua:75: attempt to get length of local 'target_plys' (a userdata value)
I did copy over the thing from the kick command and try edit it. But it prints that into console and dosen't slay the player.

Any help would be highly appreciated.

An Error Has Occurred!

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