Ulysses
General => Developers Corner => Topic started by: iSnipeu on July 28, 2012, 11:34:05 PM
-
When your using ulx commands you can use things like ^ (to target yourself), * (to target everyone) and I'm pretty sure you can use % to target groups (e.g %admin)
Is there a way to add extra stuff to this?
For example "!slap &" (which could only target alive players).
-
When your using ulx commands you can use things like ^ (to target yourself), * (to target everyone) and I'm pretty sure you can use % to target groups (e.g %admin)
Is there a way to add extra stuff to this?
For example "!slap &" (which could only target alive players).
You certainly can. Just edit the ULib.getUsers and ULib.getUser functions in ulib/lua/ulib/shared/player.lua. The first function is used in cases where multiple targets are expected (eg, slap). The second function is used where only one target is expected (eg, ban). You'll only need to to add the relevant "elseif" case in each of these functions... you shouldn't need to edit any other pieces.
Be sure to let us know what additions you make, we'd love to hear about them.
-
Thanks!
I've currently added # - this will only target alive players, you can use !# to target dead players
Here is the code if anyone wants it.
Remember this is in ulib/lua/ulib/shared/player.lua in the ULib.getUsers function @ line 109
if piece == "*" then -- All!
table.Add( tmpTargets, players )
elseif piece == "^" then -- Self!
if ply then
table.insert( tmpTargets, ply )
end
elseif piece == "#" then -- Alive players!
for _, pl in ipairs( players ) do
if pl:Team() != 1002 and pl:Alive() then
table.insert( tmpTargets, pl )
end
end
elseif piece == "@" then
if ply and ply:IsValid() then
local player = ULib.getPicker( ply )
if player then
table.insert( tmpTargets, player )
end
end
-
iSnipeu, you don't need to explicitly handle the "not" cases, that is "!#" and "!^". This is already being handled in the functions automagically. You only need to code the positive logic. :)
-
Meg, would our functions specifically target non-alive players though?
-
iSnipeu, you don't need to explicitly handle the "not" cases, that is "!#" and "!^". This is already being handled in the functions automagically. You only need to code the positive logic. :)
Fixed it, I completely forgot about that.
-
Meg, would our functions specifically target non-alive players though?
It's a general case to inverse the selection. The set operation is just (all players) - (positive selection) within the bounds of who you're allowed to target.