30 lines
1.1 KiB
Lua
30 lines
1.1 KiB
Lua
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; |