forked from TeamUlysses/ulib
Merge pull request #75 from JoshPiper/feat/team_picker
Team Picker Target Keyword
This commit is contained in:
commit
f1fd786a3c
@ -136,10 +136,14 @@ end
|
||||
Parameters:
|
||||
|
||||
target - A string of what you'd like to target. Accepts a comma separated list.
|
||||
enable_keywords - *(Optional, defaults to false)* If true, the keywords "*" for all players, "^" for self,
|
||||
"@" for picker (person in front of you), "#<group>" for those inside a specific group,
|
||||
"%<group>" for users inside a group (counting inheritance), and "$<id>" for users matching a
|
||||
particular ID will be activated.
|
||||
enable_keywords - *(Optional, defaults to false)* If true, various keywords will be enabled:
|
||||
"*" for all players,
|
||||
"^" for self,
|
||||
"@" for picker (person in front of you),
|
||||
"#<group>" for those inside a specific group,
|
||||
"%<group>" for users inside a group (counting inheritance),
|
||||
"$<id>" for users matching a particular ID, and
|
||||
"@<team>" for users inside a given team
|
||||
Any of these can be negated with "!" before it. IE, "!^" targets everyone but yourself.
|
||||
ply - *(Optional)* Player needing getUsers, this is necessary for some of the keywords.
|
||||
|
||||
@ -152,6 +156,7 @@ end
|
||||
v2.40 - Rewrite, added more keywords, removed immunity.
|
||||
v2.50 - Added "#" and '$' keywords, removed special exception for "%user" (replaced by "#user").
|
||||
v2.60 - Returns false if target is an empty string.
|
||||
v2.70 - Added "@<team>" keyword extension.
|
||||
]]
|
||||
function ULib.getUsers( target, enable_keywords, ply )
|
||||
if target == "" then
|
||||
@ -197,13 +202,37 @@ function ULib.getUsers( target, enable_keywords, ply )
|
||||
return false, "You cannot target yourself from console!"
|
||||
end
|
||||
end
|
||||
elseif piece == "@" then
|
||||
elseif piece:sub( 1, 1 ) == "@" then
|
||||
if #piece == 1 then
|
||||
if IsValid( ply ) then
|
||||
local player = ULib.getPicker( ply )
|
||||
if player then
|
||||
table.insert( tmpTargets, player )
|
||||
end
|
||||
end
|
||||
else
|
||||
local teamNameOrId = piece:sub( 2 )
|
||||
local teamId = tonumber( teamNameOrId )
|
||||
|
||||
if teamId then
|
||||
for _, ply in ipairs( team.GetPlayers( teamId ) ) do
|
||||
table.insert( tmpTargets, ply )
|
||||
end
|
||||
else
|
||||
local teams = team.GetAllTeams()
|
||||
|
||||
-- This can't be ipairs, as it's indexed by ID, starts at 0 and may not be sequential.
|
||||
for teamId, teamData in pairs( teams ) do
|
||||
if teamData.Name == teamNameOrId then
|
||||
for _, ply in ipairs( team.GetPlayers( teamId ) ) do
|
||||
table.insert( tmpTargets, ply )
|
||||
end
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif piece:sub( 1, 1 ) == "#" and ULib.ucl.groups[ piece:sub( 2 ) ] then
|
||||
local group = piece:sub( 2 )
|
||||
for _, player in ipairs( players ) do
|
||||
|
Loading…
Reference in New Issue
Block a user