UGCProjects/ProjectTemp_T/Script/gamemode/Action_PlayerLeave.lua

30 lines
1.1 KiB
Lua
Raw Permalink Normal View History

2025-01-04 23:00:19 +08:00
local Action_PlayerLeave = {
LogoutPlayerKey = 0;
}
-- 触发器激活时将执行Action的Execute
function Action_PlayerLeave:Execute(...)
-- 保存玩家数据
UGCLogSystem.Log("[Action_PlayerLeave:Execute] 玩家 %d 退出", self.LogoutPlayerKey);
local UID = UGCGameSystem.GameState.PlayerAccountInfoMap[self.LogoutPlayerKey].UID
UGCPlayerStateSystem.SavePlayerArchiveData(UID, UGCGameSystem.GameState.PlayerArchives[self.LogoutPlayerKey]);
local Count = UGCGameSystem.GameState:LogoutPlayer(self.LogoutPlayerKey, true);
if Count == 0 then
-- 关闭
UGCLogSystem.Log("[Action_PlayerLeave:Execute] 执行,所有玩家都退出了")
UGCEventSystem.SetTimer(UGCGameSystem.GameState, function()
UGCGameSystem.SendModeCustomEvent("CloseServer");
end, 3);
end
return true
end
--[[
-- 需要勾选Action的EnableTick才会执行Update
-- 触发器激活后将在每个tick执行Action的Update直到self.bEnableActionTick为false
function Action_PlayerLeave:Update(DeltaSeconds)
end
]]
return Action_PlayerLeave;