General > Developers Corner
Help please.
JamminR:
Study up on variables, both defined in function, and passed to function.
ULX will always pass calling_ply (this isn't true of lua itself in general)
Here's example of YOUR code, commented to show exactly what should be fixed (somewhat apparent in zmaster, but perhaps not clear to a new coder)
--- Code: ---function ulx.response( PrintMessage ) -- THE part inside (), is passed TO the function from WHATEVER your calling the function.
-- in the case of ulx, var1, var2.... , var1 is ALWAYS 99% going to be the calling player, hence, we often name it calling_ply, so change "PrintMessage" to calling_ply
Player:PrintMessage( HUD_PRINTCONSOLE, "Get denied. No." ) -- "Player:" is not defined. Null. You could do, before this line, Player == calling_ply, or better yet, just use calling_ply:PrintMessage( ...)
end -- one too many ends....remove it. You didn't use any other if/then/for logic statements that need an end
end -- ends the function.
local response = ulx.response( CATEGORY_NAME, "ulx response", ulx.response, "!yes" )
response:addParam{ type=ULib.cmds.PlayersArg } -- Don't need this line. It would pass var2, in this case, a table of players, we often name the var target_ply
response:defaultAccess ( ULib.ACESS.ADMIN ) -- Tell Ulib the default group needed.
response:help ( "A test script for creepy" ) -- Obvious, adds to the help menu.
--- End code ---
Navigation
[0] Message Index
[*] Previous page
Go to full version