General > Developers Corner
STEAMID Targeting in Same Command
JamminR:
I'm not MrP, but I can answer.
In your function, you setup target variable, target_player, but later reference only target_ply
Rice Cooker:
Thanks JamminR!
I still dont seem to be able to get this to function properly.
I have changed the function to just fancyadmin but I am still getting this error:
[ERROR] lua/includes/extensions/string.lua:297: attempt to call global 'error' (a nil value)
Ex Code:
--- Code: ---local CATEGORY_NAME = "Fun"
function ulx.test_command( calling_ply, target_ply )
local ply = nil
if player.GetBySteamID( target_ply ) then ply = player.GetBySteamID( target_ply ) end
if ULib.getUser( target_ply ) then ply = ULib.getUser( target_ply ) end
if IsValid( ply ) then
ulx.fancyLogAdmin( calling_ply, "#A has tried the test command on #T", target_ply )
else
ULib.tsayError( calling_ply, "The Command Is Broken!", true )
end
end
local test_command = ulx.command( CATEGORY_NAME, "ulx test", ulx.test_command, "!testcommand" )
test_command:addParam{ type=ULib.cmds.StringArg, hint="Player Name or SteamID", ULib.cmds.takeRestOfLine }
test_command:defaultAccess( ULib.ACCESS_ADMIN )
test_command:help( "Test Command" )
--- End code ---
Timmy:
In your command target_ply does not hold a Player but a string ("Player Name or SteamID"). The Player instance was stored in the ply variable instead.
Format specifier #s formats a string:
--- Code: ---ulx.fancyLogAdmin( calling_ply, "#A formatted #s", target_ply )
--- End code ---
Format specifier #T formats a Player, or a table of Players:
--- Code: ---ulx.fancyLogAdmin( calling_ply, "#A formatted #T", ply )
--- End code ---
Fun fact: ULX commands support SteamID targeting out-of-the-box. See "ulx help" for more info on how to use keyword targeting.
--- Code: ---ulx slay $STEAM_0:1:0
--- End code ---
Rice Cooker:
Thanks Timmy!
I appreciate the help. I understand that ULX already has steamid targeting within keyword targeting but I would like to have all commands being able to target without having to place a symbol. It would allow all staff to be able to utilize the commands without having to be aware of ULX targeting.
Navigation
[0] Message Index
[*] Previous page
Go to full version