This commit is contained in:
Applevangelist 2023-02-17 16:23:16 +01:00
parent 2b02f6659a
commit ffb6cbfb17

View File

@ -31,7 +31,7 @@ do
-- @field #NET -- @field #NET
NET = { NET = {
ClassName = "NET", ClassName = "NET",
Version = "0.0.4", Version = "0.0.5",
BlockTime = 600, BlockTime = 600,
BlockedPilots = {}, BlockedPilots = {},
BlockedUCIDs = {}, BlockedUCIDs = {},
@ -202,7 +202,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)
local name local name = PlayerName
if Client then if Client then
name = Client:GetPlayerName() name = Client:GetPlayerName()
elseif PlayerName then elseif PlayerName then
@ -222,7 +222,10 @@ function NET:BlockPlayer(Client,PlayerName,Seconds,Message)
self:SendChat(name..": "..message) self:SendChat(name..": "..message)
end end
self:__PlayerBlocked(1,Client,name,Seconds) self:__PlayerBlocked(1,Client,name,Seconds)
self:ReturnToSpectators(Client) local PlayerID = self:GetPlayerIDByName(name)
if PlayerID and tonumber(PlayerID) ~= 1 then
local outcome = net.force_player_slot(tonumber(PlayerID), 0, '' )
end
return self return self
end end
@ -233,7 +236,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:UnblockPlayer(Client,PlayerName,Message) function NET:UnblockPlayer(Client,PlayerName,Message)
local name local name = PlayerName
if Client then if Client then
name = Client:GetPlayerName() name = Client:GetPlayerName()
elseif PlayerName then elseif PlayerName then
@ -299,6 +302,7 @@ end
-- @param #string Name The player name whose ID to find -- @param #string Name The player name whose ID to find
-- @return #number PlayerID or nil -- @return #number PlayerID or nil
function NET:GetPlayerIDByName(Name) function NET:GetPlayerIDByName(Name)
if not Name then return nil end
local playerList = self:GetPlayerList() local playerList = self:GetPlayerList()
for i=1,#playerList do for i=1,#playerList do
local playerName = net.get_name(i) local playerName = net.get_name(i)
@ -526,8 +530,8 @@ end
-- @return #boolean Success -- @return #boolean Success
function NET:ForceSlot(Client,SideID,SlotID) function NET:ForceSlot(Client,SideID,SlotID)
local PlayerID = self:GetPlayerIDFromClient(Client) local PlayerID = self:GetPlayerIDFromClient(Client)
if PlayerID then if PlayerID and tonumber(PlayerID) ~= 1 then
return net.force_player_slot(tonumber(PlayerID), SideID, SlotID ) return net.force_player_slot(tonumber(PlayerID), SideID, SlotID or '' )
else else
return false return false
end end