44 lines
1.5 KiB
Lua
44 lines
1.5 KiB
Lua
local Action_PlayerLeave = {
|
||
PlayerKey = 0;
|
||
ExitPlayer = {};
|
||
}
|
||
|
||
-- 触发器激活时,将执行Action的Execute
|
||
function Action_PlayerLeave:Execute(...)
|
||
-- 检查是否是玩家,而不是观察者
|
||
if type(self.ExitPlayer) == 'userdata' then
|
||
UGCLogSystem.Log("[Action_PlayerLeave:Execute] ExitPlayer = %s", UE.GetName(self.ExitPlayer));
|
||
if self.ExitPlayer:IsPureSpectator() then
|
||
return true;
|
||
end
|
||
else
|
||
local PC = UGCGameSystem.GetPlayerControllerByPlayerKey(self.PlayerKey)
|
||
if PC and UE.IsValid(PC) then
|
||
-- 不让他有操作
|
||
if PC:IsPureSpectator() or PC:IsFriendObserver() then return true; end
|
||
end
|
||
end
|
||
|
||
UGCLogSystem.Log("[Action_PlayerLeave:Execute] PlayerKey = %s", tostring(self.PlayerKey));
|
||
-- 保存 ArchiveData
|
||
table.func(MiniManager, "OnPlayerLeave", self.PlayerKey);
|
||
--- 玩家掉线。服务器客户端都是这样执行
|
||
GameState.PlayerDisconnect[self.PlayerKey] = true;
|
||
UGCLogSystem.Log("[Action_PlayerLeave:Execute] 发送结束协议 PlayerKey = %s", tostring(self.PlayerKey));
|
||
local Success = UGCGameSystem.SendPlayerSettlement(self.PlayerKey);
|
||
UGCLogSystem.Log("[Action_PlayerLeave:Execute] 执行是否成功:%s", Success)
|
||
UE.CloseServer();
|
||
|
||
UGCLogSystem.Log("[Action_PlayerLeave:Execute] 玩家退出");
|
||
|
||
return true;
|
||
end
|
||
|
||
--[[
|
||
-- 需要勾选Action的EnableTick,才会执行Update
|
||
-- 触发器激活后,将在每个tick执行Action的Update,直到self.bEnableActionTick为false
|
||
function Action_PlayerLeave:Update(DeltaSeconds)
|
||
end
|
||
]]
|
||
|
||
return Action_PlayerLeave; |