Update Set.lua

Added SET_CLIENT:FilterCallsigns() and SET_CLIENT:FilterPlayernames()
This commit is contained in:
Thomas
2022-12-13 16:59:06 +01:00
committed by GitHub
parent 2e4f7956ac
commit 4368bef32f

View File

@@ -3808,6 +3808,8 @@ do -- SET_CLIENT
Countries = nil, Countries = nil,
ClientPrefixes = nil, ClientPrefixes = nil,
Zones = nil, Zones = nil,
Playernames = nil,
Callsigns = nil,
}, },
FilterMeta = { FilterMeta = {
Coalitions = { Coalitions = {
@@ -3880,6 +3882,40 @@ do -- SET_CLIENT
return ClientFound return ClientFound
end end
--- Builds a set of clients of certain callsigns.
-- @param #SET_CLIENT self
-- @param #string Callsigns Can be a string e.g. "Ford", or a table of strings e.g. {"Ford","Enfield","Chevy"}
-- @return #SET_CLIENT self
function SET_CLIENT:Filtercallsigns( Callsigns )
if not self.Filter.Callsigns then
self.Filter.Callsigns = {}
end
if type( Callsigns ) ~= "table" then
Callsigns = { Callsigns }
end
for callsignID, callsign in pairs( Callsigns ) do
self.Filter.Coalitions[Callsigns] = Callsigns
end
return self
end
--- Builds a set of clients of certain playernames.
-- @param #SET_CLIENT self
-- @param #string Playernames Can be a string e.g. "Apple", or a table of strings e.g. {"Walter","Hermann","Gonzo"}
-- @return #SET_CLIENT self
function SET_CLIENT:FilterPlayernames( Playernames )
if not self.Filter.Playernames then
self.Filter.Playernames = {}
end
if type( Playernames ) ~= "table" then
Playernames = { Playernames }
end
for PlayernameID, Playernames in pairs( Playernames ) do
self.Filter.Coalitions[Playernames] = Playernames
end
return self
end
--- Builds a set of clients of coalitions. --- Builds a set of clients of coalitions.
-- Possible current coalitions are red, blue and neutral. -- Possible current coalitions are red, blue and neutral.
-- @param #SET_CLIENT self -- @param #SET_CLIENT self
@@ -4235,7 +4271,6 @@ do -- SET_CLIENT
self:T( { "Evaluated Prefix", MClientPrefix } ) self:T( { "Evaluated Prefix", MClientPrefix } )
MClientInclude = MClientInclude and MClientPrefix MClientInclude = MClientInclude and MClientPrefix
end end
end
if self.Filter.Zones then if self.Filter.Zones then
local MClientZone = false local MClientZone = false
@@ -4249,6 +4284,31 @@ do -- SET_CLIENT
MClientInclude = MClientInclude and MClientZone MClientInclude = MClientInclude and MClientZone
end end
if self.Filter.Playernames then
local MClientPlayername = false
local playername = MClient:GetPlayerName()
for _,_Playername in pairs(self.Filter.Playernames) do
if playername and playername == _Playername then
MClientPlayername = true
end
end
self:T( { "Evaluated Playername", MClientPlayername } )
MClientInclude = MClientInclude and MClientPlayername
end
if self.Filter.Callsigns then
local MClientCallsigns = false
local callsign = MClient:GetCallsign()
for _,_Callsign in pairs(self.Filter.Callsigns) do
if callsign and string.find(callsign,_Callsign) then
MClientCallsigns = true
end
end
self:T( { "Evaluated Callsign", MClientCallsigns } )
MClientInclude = MClientInclude and MClientCallsigns
end
end
self:T2( MClientInclude ) self:T2( MClientInclude )
return MClientInclude return MClientInclude
end end