UGCProjects/TrainingCamp/Script/gamemode/Action_PlayerLeave.lua

30 lines
1.2 KiB
Lua
Raw Normal View History

2025-01-04 23:00:19 +08:00
local Action_PlayerLeave = {
-- 可配置参数定义参数将显示在Action配置面板
-- 例:
-- MyIntParameter = 0
PlayerKey = 0;
}
-- 触发器激活时将执行Action的Execute
function Action_PlayerLeave:Execute(...)
ugcprint(string.format("[Action_PlayerLeave] Start settlement %d", self.PlayerKey));
local TeamID = UGCPlayerStateSystem.GetTeamID(self.PlayerKey);
UGCGameSystem.SendPlayerSettlement(self.PlayerKey);
DefaultSettings.CurrPlayerCount = DefaultSettings.CurrPlayerCount - 1
UGCEventSystem.SendEvent(EventTypes.AddPlayer, self.PlayerKey, TeamID, false);
local IsAllPlayerLogOut, AlivePlayerCount = GameState:PlayerLoginOrLeave(false, self.PlayerKey);
-- 检查是否所有玩家都已经退出了?
if IsAllPlayerLogOut then LuaQuickFireEvent("CloseServer", self); end
if AlivePlayerCount == 1 then LuaQuickFireEvent("GameEnd", self) end
return true
end
--[[
-- 需要勾选Action的EnableTick才会执行Update
-- 触发器激活后将在每个tick执行Action的Update直到self.bEnableActionTick为false
function Action_PlayerLeave:Update(DeltaSeconds)
end
]]
return Action_PlayerLeave;