General > Developers Corner

ULX Respawn

<< < (2/3) > >>

Hatty:
Like this?


--- Code: ---local CATEGORY_NAME = "Custom ULX Commands"

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 ( "Custom ULX Commands" , "ulx spawn", ulx.spawn, "!spawn" )
spawn:addParam{ type=ULib.cmds.PlayersArg }
spawn:defaultAccess( ULib.ACCESS_ADMIN )
spawn:help( "Spawnd target(s)." )
--- End code ---

JamminR:
It should work, but you have unnecessary  CATEGORY_NAME variable name above it.
You have now turned your utility variable into a string,
which ulx command set-up expects that first spot to be filled with. A variable containing a string, or as in your case now, an actual string.
While at same time, possibly overwriting previous category name variable defined much earlier in the file.

jacksop:
What JamminR is saying is right.

There are 2 things you could do.

1. Delete the variable declaration at the beginning of the file and keep the string "Custom ULX Commands" in ulx.command

2.
Change your local variable (CATEGORY_NAME) to something unique - literally anything (lets just say SpawnCommand) -- local SpawnCommand = "Custom ULX Commands"
BUT you need to keep whatever you call that variable (in my case SpawnCommand) the same as what you put into the ulx.command so it would look like...
local spawn = ulx.command(SpawnCommand, "ulx spawn")..... and so on

Sorry if im repeating things. Its just because you said you were new to lua and I wanna make sure you understand.

JamminR:
1) Don't do 1. (he's editing ULX files, all other 'fun' commands before his would break)
2) Now you're confusing things even more.
I basically said ulx.spawn ( "THIS CONTENT HERE", ...) is what goes in menu. Could be ulx.spawn ( variable_name, ...) and variable_name could literally be CATEGORY_NAME, already defined by us way up in the fun.lua file, or ulx.spawn ( "Custom ULX command", ...) and make thier own menu.

JamminR:

--- 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 ( "Custom ULX Commands" , "ulx spawn", ulx.spawn, "!spawn" )
spawn:addParam{ type=ULib.cmds.PlayersArg }
spawn:defaultAccess( ULib.ACCESS_ADMIN )
spawn:help( "Spawnd target(s)." )
--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version