mirror of
https://github.com/opentibiabr/canary
synced 2026-08-16 06:26:09 -04:00
New Features: • Server-side quest tracker persistence with per-player options (auto-track/auto-untrack) and safe initial-sync. Improvements: • Robust login/logout sync to prevent lost or empty tracker state. • Automatic tracking/untracking pipeline with delayed, cancelable removals. • Tighter quest/mission progression checks and reduced tracked-quest limits. Stability: • Safer protocol parsing with malformed-packet guards, expanded logging, and message unread-byte support.
54 lines
1.3 KiB
Lua
54 lines
1.3 KiB
Lua
local playerLogout = CreatureEvent("PlayerLogout")
|
|
|
|
function playerLogout.onLogout(player)
|
|
local playerId = player:getId()
|
|
|
|
if _G.NextUseStaminaTime[playerId] then
|
|
_G.NextUseStaminaTime[playerId] = nil
|
|
end
|
|
|
|
if LastQuestlogUpdate then
|
|
LastQuestlogUpdate[playerId] = nil
|
|
end
|
|
|
|
if PlayerTrackedMissionRemovalEvents and PlayerTrackedMissionRemovalEvents[playerId] and player.flushTrackedMissionRemovalEvents then
|
|
player:flushTrackedMissionRemovalEvents(false)
|
|
end
|
|
|
|
if PlayerTrackedMissionsData then
|
|
if PlayerTrackedMissionsData[playerId] and player.saveTrackedMissions then
|
|
player:saveTrackedMissions()
|
|
end
|
|
PlayerTrackedMissionsData[playerId] = nil
|
|
end
|
|
|
|
if PlayerTrackedMissionRemovalEvents then
|
|
PlayerTrackedMissionRemovalEvents[playerId] = nil
|
|
end
|
|
|
|
if PlayerQuestTrackerInitialSync then
|
|
PlayerQuestTrackerInitialSync[playerId] = nil
|
|
end
|
|
|
|
local stats = player:inBossFight()
|
|
if stats then
|
|
local boss = Monster(stats.bossId)
|
|
if boss then
|
|
local dmgOut = boss:getDamageMap()[playerId]
|
|
if dmgOut then
|
|
stats.damageOut = (stats.damageOut or 0) + dmgOut.total
|
|
end
|
|
|
|
stats.stamina = player:getStamina()
|
|
end
|
|
end
|
|
|
|
if _G.OnExerciseTraining[playerId] then
|
|
stopEvent(_G.OnExerciseTraining[playerId].event)
|
|
_G.OnExerciseTraining[playerId] = nil
|
|
player:setTraining(false)
|
|
end
|
|
return true
|
|
end
|
|
|
|
playerLogout:register()
|