General > Developers Corner

ULX Respawn

(1/3) > >>

Hatty:
So I am new to the lua field but I am trying to add a command and I pasted it in the Fun.lua in the ulx folder on my server but it is not working Here is the code:

--- Code: ---function ulx.spawn( calling_ply, target_plys )
local affected_plys = {}
for k,v in pairs(target_plys) do
if !v:Alive() then
v:Spawn()
table.insert(affected_plys, v)
end
end
ulx.fancyLogAdmin( calling_ply, "#A spawned #T", affected_plys )
end
local spawn = ulx.command( Utility, "ulx spawn", ulx.spawn, "!spawn" )
spawn:addParam{ type=ULib.cmds.PlayersArg }
spawn:defaultAccess( ULib.ACCESS_ADMIN )
spawn:help( "Spawnd target(s)." )
--- End code ---

MrPresident:
What happens when you try and run the command? Any error?

Hatty:
Nope
just shows the command in chat with no errors as if I just said it in game

jacksop:
You need to create a variable for the ulx.command to link to. At the moment you have "Utility" in this parameter. Do you have a local variable called "Utility" at all in your code?

If not you would need to create one above the function ulx.spawn.

e.g. local Utility = "Extra ULX commands" -- this also creates a tab in the ulx menu called Extra ULX commands.

Unless of course you didn't include it in your code box??

Hatty:
so where would I add that line of code again sorry Im newish to lua coding

Navigation

[0] Message Index

[#] Next page

Go to full version