mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Added CLIENT:FindByPlayerName(Name)
NET - slot blocker comments in log removed
This commit is contained in:
parent
3e8413c6b7
commit
7dc239f506
@ -62,15 +62,15 @@
|
|||||||
--
|
--
|
||||||
-- @field #CLIENT
|
-- @field #CLIENT
|
||||||
CLIENT = {
|
CLIENT = {
|
||||||
ClassName = "CLIENT",
|
ClassName = "CLIENT",
|
||||||
ClientName = nil,
|
ClientName = nil,
|
||||||
ClientAlive = false,
|
ClientAlive = false,
|
||||||
ClientTransport = false,
|
ClientTransport = false,
|
||||||
ClientBriefingShown = false,
|
ClientBriefingShown = false,
|
||||||
_Menus = {},
|
_Menus = {},
|
||||||
_Tasks = {},
|
_Tasks = {},
|
||||||
Messages = {},
|
Messages = {},
|
||||||
Players = {},
|
Players = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -95,6 +95,22 @@ function CLIENT:Find(DCSUnit, Error)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Finds a CLIENT from the _DATABASE using the relevant player name.
|
||||||
|
-- @param #CLIENT self
|
||||||
|
-- @param #string Name Name of the player
|
||||||
|
-- @return #CLIENT or nil if not found
|
||||||
|
function CLIENT:FindByPlayerName(Name)
|
||||||
|
|
||||||
|
local foundclient = nil
|
||||||
|
_DATABASE:ForEachClient(
|
||||||
|
function(client)
|
||||||
|
if client:GetPlayerName() == Name then
|
||||||
|
foundclient = client
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
return foundclient
|
||||||
|
end
|
||||||
|
|
||||||
--- Finds a CLIENT from the _DATABASE using the relevant Client Unit Name.
|
--- Finds a CLIENT from the _DATABASE using the relevant Client Unit Name.
|
||||||
-- As an optional parameter, a briefing text can be given also.
|
-- As an optional parameter, a briefing text can be given also.
|
||||||
@ -105,13 +121,13 @@ end
|
|||||||
-- @return #CLIENT
|
-- @return #CLIENT
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Create new Clients.
|
-- -- Create new Clients.
|
||||||
-- local Mission = MISSIONSCHEDULER.AddMission( 'Russia Transport Troops SA-6', 'Operational', 'Transport troops from the control center to one of the SA-6 SAM sites to activate their operation.', 'Russia' )
|
-- local Mission = MISSIONSCHEDULER.AddMission( 'Russia Transport Troops SA-6', 'Operational', 'Transport troops from the control center to one of the SA-6 SAM sites to activate their operation.', 'Russia' )
|
||||||
-- Mission:AddGoal( DeploySA6TroopsGoal )
|
-- Mission:AddGoal( DeploySA6TroopsGoal )
|
||||||
--
|
--
|
||||||
-- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*HOT-Deploy Troops 1' ):Transport() )
|
-- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*HOT-Deploy Troops 1' ):Transport() )
|
||||||
-- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*RAMP-Deploy Troops 3' ):Transport() )
|
-- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*RAMP-Deploy Troops 3' ):Transport() )
|
||||||
-- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*HOT-Deploy Troops 2' ):Transport() )
|
-- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*HOT-Deploy Troops 2' ):Transport() )
|
||||||
-- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*RAMP-Deploy Troops 4' ):Transport() )
|
-- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*RAMP-Deploy Troops 4' ):Transport() )
|
||||||
function CLIENT:FindByName( ClientName, ClientBriefing, Error )
|
function CLIENT:FindByName( ClientName, ClientBriefing, Error )
|
||||||
|
|
||||||
-- Client
|
-- Client
|
||||||
@ -124,7 +140,7 @@ function CLIENT:FindByName( ClientName, ClientBriefing, Error )
|
|||||||
|
|
||||||
ClientFound.MessageSwitch = true
|
ClientFound.MessageSwitch = true
|
||||||
|
|
||||||
return ClientFound
|
return ClientFound
|
||||||
end
|
end
|
||||||
|
|
||||||
if not Error then
|
if not Error then
|
||||||
@ -262,8 +278,8 @@ end
|
|||||||
-- @param #CLIENT self
|
-- @param #CLIENT self
|
||||||
-- @param #string ClientName Name of the Group as defined within the Mission Editor. The Group must have a Unit with the type Client.
|
-- @param #string ClientName Name of the Group as defined within the Mission Editor. The Group must have a Unit with the type Client.
|
||||||
function CLIENT:Reset( ClientName )
|
function CLIENT:Reset( ClientName )
|
||||||
self:F()
|
self:F()
|
||||||
self._Menus = {}
|
self._Menus = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Is Functions
|
-- Is Functions
|
||||||
@ -347,85 +363,85 @@ function CLIENT:GetDCSGroup()
|
|||||||
self:F3()
|
self:F3()
|
||||||
|
|
||||||
-- local ClientData = Group.getByName( self.ClientName )
|
-- local ClientData = Group.getByName( self.ClientName )
|
||||||
-- if ClientData and ClientData:isExist() then
|
-- if ClientData and ClientData:isExist() then
|
||||||
-- self:T( self.ClientName .. " : group found!" )
|
-- self:T( self.ClientName .. " : group found!" )
|
||||||
-- return ClientData
|
-- return ClientData
|
||||||
-- else
|
-- else
|
||||||
-- return nil
|
-- return nil
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
local ClientUnit = Unit.getByName( self.ClientName )
|
local ClientUnit = Unit.getByName( self.ClientName )
|
||||||
|
|
||||||
local CoalitionsData = { AlivePlayersRed = coalition.getPlayers( coalition.side.RED ), AlivePlayersBlue = coalition.getPlayers( coalition.side.BLUE ) }
|
local CoalitionsData = { AlivePlayersRed = coalition.getPlayers( coalition.side.RED ), AlivePlayersBlue = coalition.getPlayers( coalition.side.BLUE ) }
|
||||||
|
|
||||||
for CoalitionId, CoalitionData in pairs( CoalitionsData ) do
|
for CoalitionId, CoalitionData in pairs( CoalitionsData ) do
|
||||||
self:T3( { "CoalitionData:", CoalitionData } )
|
self:T3( { "CoalitionData:", CoalitionData } )
|
||||||
for UnitId, UnitData in pairs( CoalitionData ) do
|
for UnitId, UnitData in pairs( CoalitionData ) do
|
||||||
self:T3( { "UnitData:", UnitData } )
|
self:T3( { "UnitData:", UnitData } )
|
||||||
if UnitData and UnitData:isExist() then
|
if UnitData and UnitData:isExist() then
|
||||||
|
|
||||||
--self:F(self.ClientName)
|
--self:F(self.ClientName)
|
||||||
if ClientUnit then
|
if ClientUnit then
|
||||||
|
|
||||||
local ClientGroup = ClientUnit:getGroup()
|
local ClientGroup = ClientUnit:getGroup()
|
||||||
|
|
||||||
if ClientGroup then
|
if ClientGroup then
|
||||||
self:T3( "ClientGroup = " .. self.ClientName )
|
self:T3( "ClientGroup = " .. self.ClientName )
|
||||||
|
|
||||||
if ClientGroup:isExist() and UnitData:getGroup():isExist() then
|
if ClientGroup:isExist() and UnitData:getGroup():isExist() then
|
||||||
|
|
||||||
if ClientGroup:getID() == UnitData:getGroup():getID() then
|
if ClientGroup:getID() == UnitData:getGroup():getID() then
|
||||||
self:T3( "Normal logic" )
|
self:T3( "Normal logic" )
|
||||||
self:T3( self.ClientName .. " : group found!" )
|
self:T3( self.ClientName .. " : group found!" )
|
||||||
self.ClientGroupID = ClientGroup:getID()
|
self.ClientGroupID = ClientGroup:getID()
|
||||||
self.ClientGroupName = ClientGroup:getName()
|
self.ClientGroupName = ClientGroup:getName()
|
||||||
return ClientGroup
|
return ClientGroup
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- Now we need to resolve the bugs in DCS 1.5 ...
|
-- Now we need to resolve the bugs in DCS 1.5 ...
|
||||||
-- Consult the database for the units of the Client Group. (ClientGroup:getUnits() returns nil)
|
-- Consult the database for the units of the Client Group. (ClientGroup:getUnits() returns nil)
|
||||||
self:T3( "Bug 1.5 logic" )
|
self:T3( "Bug 1.5 logic" )
|
||||||
|
|
||||||
local ClientGroupTemplate = _DATABASE.Templates.Units[self.ClientName].GroupTemplate
|
local ClientGroupTemplate = _DATABASE.Templates.Units[self.ClientName].GroupTemplate
|
||||||
|
|
||||||
self.ClientGroupID = ClientGroupTemplate.groupId
|
self.ClientGroupID = ClientGroupTemplate.groupId
|
||||||
|
|
||||||
self.ClientGroupName = _DATABASE.Templates.Units[self.ClientName].GroupName
|
self.ClientGroupName = _DATABASE.Templates.Units[self.ClientName].GroupName
|
||||||
|
|
||||||
self:T3( self.ClientName .. " : group found in bug 1.5 resolvement logic!" )
|
self:T3( self.ClientName .. " : group found in bug 1.5 resolvement logic!" )
|
||||||
return ClientGroup
|
return ClientGroup
|
||||||
|
|
||||||
end
|
end
|
||||||
-- else
|
-- else
|
||||||
-- error( "Client " .. self.ClientName .. " not found!" )
|
-- error( "Client " .. self.ClientName .. " not found!" )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
--self:F( { "Client not found!", self.ClientName } )
|
--self:F( { "Client not found!", self.ClientName } )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- For non player clients
|
|
||||||
if ClientUnit then
|
|
||||||
local ClientGroup = ClientUnit:getGroup()
|
|
||||||
if ClientGroup then
|
|
||||||
self:T3( "ClientGroup = " .. self.ClientName )
|
|
||||||
if ClientGroup:isExist() then
|
|
||||||
self:T3( "Normal logic" )
|
|
||||||
self:T3( self.ClientName .. " : group found!" )
|
|
||||||
return ClientGroup
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Nothing could be found :(
|
-- For non player clients
|
||||||
self.ClientGroupID = nil
|
if ClientUnit then
|
||||||
self.ClientGroupName = nil
|
local ClientGroup = ClientUnit:getGroup()
|
||||||
|
if ClientGroup then
|
||||||
return nil
|
self:T3( "ClientGroup = " .. self.ClientName )
|
||||||
|
if ClientGroup:isExist() then
|
||||||
|
self:T3( "Normal logic" )
|
||||||
|
self:T3( self.ClientName .. " : group found!" )
|
||||||
|
return ClientGroup
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Nothing could be found :(
|
||||||
|
self.ClientGroupID = nil
|
||||||
|
self.ClientGroupName = nil
|
||||||
|
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -437,7 +453,7 @@ function CLIENT:GetClientGroupID()
|
|||||||
-- This updates the ID.
|
-- This updates the ID.
|
||||||
self:GetDCSGroup()
|
self:GetDCSGroup()
|
||||||
|
|
||||||
return self.ClientGroupID
|
return self.ClientGroupID
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -449,7 +465,7 @@ function CLIENT:GetClientGroupName()
|
|||||||
-- This updates the group name.
|
-- This updates the group name.
|
||||||
self:GetDCSGroup()
|
self:GetDCSGroup()
|
||||||
|
|
||||||
return self.ClientGroupName
|
return self.ClientGroupName
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the UNIT of the CLIENT.
|
--- Returns the UNIT of the CLIENT.
|
||||||
@ -458,23 +474,23 @@ end
|
|||||||
function CLIENT:GetClientGroupUnit()
|
function CLIENT:GetClientGroupUnit()
|
||||||
self:F2()
|
self:F2()
|
||||||
|
|
||||||
local ClientDCSUnit = Unit.getByName( self.ClientName )
|
local ClientDCSUnit = Unit.getByName( self.ClientName )
|
||||||
|
|
||||||
self:T( self.ClientDCSUnit )
|
self:T( self.ClientDCSUnit )
|
||||||
|
|
||||||
if ClientDCSUnit and ClientDCSUnit:isExist() then
|
if ClientDCSUnit and ClientDCSUnit:isExist() then
|
||||||
local ClientUnit=_DATABASE:FindUnit( self.ClientName )
|
local ClientUnit=_DATABASE:FindUnit( self.ClientName )
|
||||||
return ClientUnit
|
return ClientUnit
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the DCSUnit of the CLIENT.
|
--- Returns the DCSUnit of the CLIENT.
|
||||||
-- @param #CLIENT self
|
-- @param #CLIENT self
|
||||||
-- @return DCS#Unit
|
-- @return DCS#Unit
|
||||||
function CLIENT:GetClientGroupDCSUnit()
|
function CLIENT:GetClientGroupDCSUnit()
|
||||||
self:F2()
|
self:F2()
|
||||||
|
|
||||||
local ClientDCSUnit = Unit.getByName( self.ClientName )
|
local ClientDCSUnit = Unit.getByName( self.ClientName )
|
||||||
|
|
||||||
@ -489,29 +505,29 @@ end
|
|||||||
-- @param #CLIENT self
|
-- @param #CLIENT self
|
||||||
-- @return #boolean true is a transport.
|
-- @return #boolean true is a transport.
|
||||||
function CLIENT:IsTransport()
|
function CLIENT:IsTransport()
|
||||||
self:F()
|
self:F()
|
||||||
return self.ClientTransport
|
return self.ClientTransport
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Shows the @{AI.AI_Cargo#CARGO} contained within the CLIENT to the player as a message.
|
--- Shows the @{AI.AI_Cargo#CARGO} contained within the CLIENT to the player as a message.
|
||||||
-- The @{AI.AI_Cargo#CARGO} is shown using the @{Core.Message#MESSAGE} distribution system.
|
-- The @{AI.AI_Cargo#CARGO} is shown using the @{Core.Message#MESSAGE} distribution system.
|
||||||
-- @param #CLIENT self
|
-- @param #CLIENT self
|
||||||
function CLIENT:ShowCargo()
|
function CLIENT:ShowCargo()
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
local CargoMsg = ""
|
local CargoMsg = ""
|
||||||
|
|
||||||
for CargoName, Cargo in pairs( CARGOS ) do
|
for CargoName, Cargo in pairs( CARGOS ) do
|
||||||
if self == Cargo:IsLoadedInClient() then
|
if self == Cargo:IsLoadedInClient() then
|
||||||
CargoMsg = CargoMsg .. Cargo.CargoName .. " Type:" .. Cargo.CargoType .. " Weight: " .. Cargo.CargoWeight .. "\n"
|
CargoMsg = CargoMsg .. Cargo.CargoName .. " Type:" .. Cargo.CargoType .. " Weight: " .. Cargo.CargoWeight .. "\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if CargoMsg == "" then
|
if CargoMsg == "" then
|
||||||
CargoMsg = "empty"
|
CargoMsg = "empty"
|
||||||
end
|
end
|
||||||
|
|
||||||
self:Message( CargoMsg, 15, "Co-Pilot: Cargo Status", 30 )
|
self:Message( CargoMsg, 15, "Co-Pilot: Cargo Status", 30 )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -526,39 +542,39 @@ end
|
|||||||
-- @param #number MessageInterval is the interval in seconds between the display of the @{Core.Message#MESSAGE} when the CLIENT is in the air.
|
-- @param #number MessageInterval is the interval in seconds between the display of the @{Core.Message#MESSAGE} when the CLIENT is in the air.
|
||||||
-- @param #string MessageID is the identifier of the message when displayed with intervals.
|
-- @param #string MessageID is the identifier of the message when displayed with intervals.
|
||||||
function CLIENT:Message( Message, MessageDuration, MessageCategory, MessageInterval, MessageID )
|
function CLIENT:Message( Message, MessageDuration, MessageCategory, MessageInterval, MessageID )
|
||||||
self:F( { Message, MessageDuration, MessageCategory, MessageInterval } )
|
self:F( { Message, MessageDuration, MessageCategory, MessageInterval } )
|
||||||
|
|
||||||
if self.MessageSwitch == true then
|
if self.MessageSwitch == true then
|
||||||
if MessageCategory == nil then
|
if MessageCategory == nil then
|
||||||
MessageCategory = "Messages"
|
MessageCategory = "Messages"
|
||||||
end
|
end
|
||||||
if MessageID ~= nil then
|
if MessageID ~= nil then
|
||||||
if self.Messages[MessageID] == nil then
|
if self.Messages[MessageID] == nil then
|
||||||
self.Messages[MessageID] = {}
|
self.Messages[MessageID] = {}
|
||||||
self.Messages[MessageID].MessageId = MessageID
|
self.Messages[MessageID].MessageId = MessageID
|
||||||
self.Messages[MessageID].MessageTime = timer.getTime()
|
self.Messages[MessageID].MessageTime = timer.getTime()
|
||||||
self.Messages[MessageID].MessageDuration = MessageDuration
|
self.Messages[MessageID].MessageDuration = MessageDuration
|
||||||
if MessageInterval == nil then
|
if MessageInterval == nil then
|
||||||
self.Messages[MessageID].MessageInterval = 600
|
self.Messages[MessageID].MessageInterval = 600
|
||||||
else
|
else
|
||||||
self.Messages[MessageID].MessageInterval = MessageInterval
|
self.Messages[MessageID].MessageInterval = MessageInterval
|
||||||
end
|
end
|
||||||
MESSAGE:New( Message, MessageDuration, MessageCategory ):ToClient( self )
|
MESSAGE:New( Message, MessageDuration, MessageCategory ):ToClient( self )
|
||||||
else
|
else
|
||||||
if self:GetClientGroupDCSUnit() and not self:GetClientGroupDCSUnit():inAir() then
|
if self:GetClientGroupDCSUnit() and not self:GetClientGroupDCSUnit():inAir() then
|
||||||
if timer.getTime() - self.Messages[MessageID].MessageTime >= self.Messages[MessageID].MessageDuration + 10 then
|
if timer.getTime() - self.Messages[MessageID].MessageTime >= self.Messages[MessageID].MessageDuration + 10 then
|
||||||
MESSAGE:New( Message, MessageDuration , MessageCategory):ToClient( self )
|
MESSAGE:New( Message, MessageDuration , MessageCategory):ToClient( self )
|
||||||
self.Messages[MessageID].MessageTime = timer.getTime()
|
self.Messages[MessageID].MessageTime = timer.getTime()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if timer.getTime() - self.Messages[MessageID].MessageTime >= self.Messages[MessageID].MessageDuration + self.Messages[MessageID].MessageInterval then
|
if timer.getTime() - self.Messages[MessageID].MessageTime >= self.Messages[MessageID].MessageDuration + self.Messages[MessageID].MessageInterval then
|
||||||
MESSAGE:New( Message, MessageDuration, MessageCategory ):ToClient( self )
|
MESSAGE:New( Message, MessageDuration, MessageCategory ):ToClient( self )
|
||||||
self.Messages[MessageID].MessageTime = timer.getTime()
|
self.Messages[MessageID].MessageTime = timer.getTime()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
MESSAGE:New( Message, MessageDuration, MessageCategory ):ToClient( self )
|
MESSAGE:New( Message, MessageDuration, MessageCategory ):ToClient( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -31,7 +31,7 @@ do
|
|||||||
-- @field #NET
|
-- @field #NET
|
||||||
NET = {
|
NET = {
|
||||||
ClassName = "NET",
|
ClassName = "NET",
|
||||||
Version = "0.0.6",
|
Version = "0.0.7",
|
||||||
BlockTime = 600,
|
BlockTime = 600,
|
||||||
BlockedPilots = {},
|
BlockedPilots = {},
|
||||||
BlockedUCIDs = {},
|
BlockedUCIDs = {},
|
||||||
@ -154,17 +154,18 @@ function NET:_EventHandler(EventData)
|
|||||||
local name = data.IniPlayerName and data.IniPlayerName or data.IniUnit:GetPlayerName()
|
local name = data.IniPlayerName and data.IniPlayerName or data.IniUnit:GetPlayerName()
|
||||||
local ucid = self:GetPlayerUCID(nil,name)
|
local ucid = self:GetPlayerUCID(nil,name)
|
||||||
local PlayerID = self:GetPlayerIDByName(name) or "none"
|
local PlayerID = self:GetPlayerIDByName(name) or "none"
|
||||||
|
local PlayerSide, PlayerSlot = self:GetSlot(data.IniUnit)
|
||||||
local TNow = timer.getTime()
|
local TNow = timer.getTime()
|
||||||
self:I(self.lid.."Event for: "..name.." | UCID: "..ucid)
|
self:T(self.lid.."Event for: "..name.." | UCID: "..ucid)
|
||||||
if self.BlockedPilots[name] then
|
if self.BlockedPilots[name] then
|
||||||
self:I(self.lid.."Pilot "..name.." ID "..PlayerID.." Blocked for another "..self.BlockedPilots[name]-timer.getTime().." seconds!")
|
self:T(self.lid.."Pilot "..name.." ID "..PlayerID.." Blocked for another "..self.BlockedPilots[name]-timer.getTime().." seconds!")
|
||||||
end
|
end
|
||||||
if self.BlockedUCIDs[ucid] then
|
if self.BlockedUCIDs[ucid] then
|
||||||
self:I(self.lid.."Pilot "..name.." ID "..PlayerID.." Blocked for another "..self.BlockedUCIDs[ucid]-timer.getTime().." seconds!")
|
self:T(self.lid.."Pilot "..name.." ID "..PlayerID.." Blocked for another "..self.BlockedUCIDs[ucid]-timer.getTime().." seconds!")
|
||||||
end
|
end
|
||||||
-- Joining
|
-- Joining
|
||||||
if data.id == EVENTS.PlayerEnterUnit or data.id == EVENTS.PlayerEnterAircraft then
|
if data.id == EVENTS.PlayerEnterUnit or data.id == EVENTS.PlayerEnterAircraft then
|
||||||
self:I(self.lid.."Pilot Joining: "..name.." | UCID: "..ucid)
|
self:T(self.lid.."Pilot Joining: "..name.." | UCID: "..ucid)
|
||||||
-- Check for known pilots
|
-- Check for known pilots
|
||||||
if self.BlockedPilots[name] and TNow < self.BlockedPilots[name] then
|
if self.BlockedPilots[name] and TNow < self.BlockedPilots[name] then
|
||||||
-- block pilot by name
|
-- block pilot by name
|
||||||
@ -177,7 +178,13 @@ function NET:_EventHandler(EventData)
|
|||||||
local outcome = net.force_player_slot(tonumber(PlayerID), 0, '' )
|
local outcome = net.force_player_slot(tonumber(PlayerID), 0, '' )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self.KnownPilots[name] = true
|
self.KnownPilots[name] = {
|
||||||
|
name = name,
|
||||||
|
ucid = ucid,
|
||||||
|
id = PlayerID,
|
||||||
|
side = PlayerSide,
|
||||||
|
slot = PlayerSlot,
|
||||||
|
}
|
||||||
if (self.BlockedUCIDs[ucid] and TNow >= self.BlockedUCIDs[ucid]) or (self.BlockedPilots[name] and TNow >= self.BlockedPilots[name]) then
|
if (self.BlockedUCIDs[ucid] and TNow >= self.BlockedUCIDs[ucid]) or (self.BlockedPilots[name] and TNow >= self.BlockedPilots[name]) then
|
||||||
self.BlockedPilots[name] = nil
|
self.BlockedPilots[name] = nil
|
||||||
self.BlockedUCIDs[ucid] = nil
|
self.BlockedUCIDs[ucid] = nil
|
||||||
@ -188,21 +195,21 @@ function NET:_EventHandler(EventData)
|
|||||||
end
|
end
|
||||||
-- Leaving
|
-- Leaving
|
||||||
if data.id == EVENTS.PlayerLeaveUnit and self.KnownPilots[name] then
|
if data.id == EVENTS.PlayerLeaveUnit and self.KnownPilots[name] then
|
||||||
self:I(self.lid.."Pilot Leaving: "..name.." | UCID: "..ucid)
|
self:T(self.lid.."Pilot Leaving: "..name.." | UCID: "..ucid)
|
||||||
self:__PlayerLeft(1,data.IniUnit,name)
|
self:__PlayerLeft(1,data.IniUnit,name)
|
||||||
self.KnownPilots[name] = false
|
self.KnownPilots[name] = false
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
-- Ejected
|
-- Ejected
|
||||||
if data.id == EVENTS.Ejection and self.KnownPilots[name] then
|
if data.id == EVENTS.Ejection and self.KnownPilots[name] then
|
||||||
self:I(self.lid.."Pilot Ejecting: "..name.." | UCID: "..ucid)
|
self:T(self.lid.."Pilot Ejecting: "..name.." | UCID: "..ucid)
|
||||||
self:__PlayerEjected(1,data.IniUnit,name)
|
self:__PlayerEjected(1,data.IniUnit,name)
|
||||||
self.KnownPilots[name] = false
|
self.KnownPilots[name] = false
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
-- Dead, Crash, Suicide
|
-- Dead, Crash, Suicide
|
||||||
if (data.id == EVENTS.PilotDead or data.id == EVENTS.SelfKillPilot or data.id == EVENTS.Crash) and self.KnownPilots[name] then
|
if (data.id == EVENTS.PilotDead or data.id == EVENTS.SelfKillPilot or data.id == EVENTS.Crash) and self.KnownPilots[name] then
|
||||||
self:I(self.lid.."Pilot Dead: "..name.." | UCID: "..ucid)
|
self:T(self.lid.."Pilot Dead: "..name.." | UCID: "..ucid)
|
||||||
self:__PlayerDied(1,data.IniUnit,name)
|
self:__PlayerDied(1,data.IniUnit,name)
|
||||||
self.KnownPilots[name] = false
|
self.KnownPilots[name] = false
|
||||||
return self
|
return self
|
||||||
@ -219,7 +226,7 @@ end
|
|||||||
-- @param #string Message (optional) Message to be sent via chat.
|
-- @param #string Message (optional) Message to be sent via chat.
|
||||||
-- @return #NET self
|
-- @return #NET self
|
||||||
function NET:BlockPlayer(Client,PlayerName,Seconds,Message)
|
function NET:BlockPlayer(Client,PlayerName,Seconds,Message)
|
||||||
self:I({PlayerName,Seconds,Message})
|
self:T({PlayerName,Seconds,Message})
|
||||||
local name = PlayerName
|
local name = PlayerName
|
||||||
if Client and (not PlayerName) then
|
if Client and (not PlayerName) then
|
||||||
name = Client:GetPlayerName()
|
name = Client:GetPlayerName()
|
||||||
@ -322,10 +329,10 @@ end
|
|||||||
function NET:GetPlayerIDByName(Name)
|
function NET:GetPlayerIDByName(Name)
|
||||||
if not Name then return nil end
|
if not Name then return nil end
|
||||||
local playerList = self:GetPlayerList()
|
local playerList = self:GetPlayerList()
|
||||||
self:I({playerList})
|
self:T({playerList})
|
||||||
for i=1,#playerList do
|
for i=1,#playerList do
|
||||||
local playerName = net.get_name(i)
|
local playerName = net.get_name(i)
|
||||||
self:I({playerName})
|
self:T({playerName})
|
||||||
if playerName == Name then
|
if playerName == Name then
|
||||||
return playerList[i]
|
return playerList[i]
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user