View Full Version : [SOLVED] Keeping phase on logout

05-21-2014, 05:42 AM
Currently when you log out your phase will be set back to 1. Does anyone know where I can change this to keep the current phase when they log out?

05-21-2014, 05:49 AM
You cant "set" it anywhere.
You need to code it.

You lose them since the real phasing is made with spells, which persist through relog if needed.
So it is basically not needed on blizzlike server and it wouldnt be blizzlike.

Just save the phase to DB on logout and apply the phasing on login.

05-21-2014, 07:44 AM
So that's why I couldn't find anything.
Here is a working script if anyone needs it.
You'll need to add a new coulmn "phasemask" in the characters table. Make sure its Normal INT.

-- Made by Neccta for Azure-WoW, big thanks to Rochet2.

function Login(event, player)
local query = CharDBQuery("SELECT phasemask FROM characters WHERE `guid` = "..player:GetGUIDLow())
if (not query) then

function Logout(event, player)
CharDBExecute("UPDATE `characters` SET `phasemask` = "..player:GetPhaseMask().." WHERE `guid` = "..player:GetGUIDLow())

RegisterPlayerEvent(3, Login)
RegisterPlayerEvent(4, Logout)

That was really easy to make after you helped out with the bosster script. :wink2:

05-21-2014, 08:25 AM
You could also make it save the phase on OnSave hook for player.
This is when a player is saved.

Also you should move the if (not query) stuff above the setphase.

actually the on logout hook part can then probably be removed as player is saved on logout.

05-21-2014, 09:21 AM
Oh I didn't know that there was a OnSave hook. I'll move the (not query), thanks.

05-21-2014, 09:16 PM
Players has a certain amount of time they are saved as well. I believe it is in your world config. Default is I think every 10 or 15 minutes. In conclusion of that, if the said information isn't saved before a certain crash or whatever, it won't be save. Don't let that scare you though, it is a great solution using that hook. :P

05-22-2014, 11:24 AM
Wouldn't it be smart to save it when the command was used

05-22-2014, 12:19 PM
Wouldn't it be smart to save it when the command was used
If you are referring to SetPhase
Then no.

Saving should be consistent.
If for example a player starts a quest that phases him, the phase is saved.
Then the core crashes and the player has a rollback since he was not saved due to the crash.
This results to the player being phased but not started the quest.

Should save data when the character is otherwise saved as well. To me it seems like best practice and will have least DB queries etc.

Just my personal opinion.