• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] Keeping phase on logout

Status
Not open for further replies.

Neccta

Exalted Member
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?
 

Rochet2

Moderator / Eluna Dev
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.
 

Neccta

Exalted Member
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.
Code:
-- 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())
    player:SetPhaseMask(query:GetUInt32(0))
    if (not query) then
        return
    end
end

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

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

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

Rochet2

Moderator / Eluna Dev
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.
:)
 
Last edited:

Tommy

Founder
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
 

Rochet2

Moderator / Eluna Dev
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.
 
Last edited:
Status
Not open for further replies.
Top