Character /playtime
Character /playtime
Hello, today I bring to you from the work shop of Hypnotoad:
Character /playtime implementation.
Since this is already an available field in the database, this is a small ordeal.
Although it has been tested, I think the implementation may be a little bloated.
Due to that, I implore you to give feedback on a better implementation, as I would love to improve upon this.
Small explanation on how it works:
The playtime is measured in 'seconds' played, as such, the database field will be in that format also.
Playtime server side is kept to the nearest second, and saved to the database every 10 minutes.
It is primarily saved to the database when a character zones/leaves the game.
Character playtime is only updated for a client when they zone or login, as such, the client handles playtime internally until you zone, at which point the server sends this time. I'm guessing this is to keep the client in sync and updated.
Character /playtime implementation.
Since this is already an available field in the database, this is a small ordeal.
Although it has been tested, I think the implementation may be a little bloated.
Due to that, I implore you to give feedback on a better implementation, as I would love to improve upon this.
Small explanation on how it works:
The playtime is measured in 'seconds' played, as such, the database field will be in that format also.
Playtime server side is kept to the nearest second, and saved to the database every 10 minutes.
It is primarily saved to the database when a character zones/leaves the game.
Character playtime is only updated for a client when they zone or login, as such, the client handles playtime internally until you zone, at which point the server sends this time. I'm guessing this is to keep the client in sync and updated.
Re: Character /playtime
не очень удачное решение. слишком много кода для такой простой задачи ((
Re: Character /playtime
Originally I was just saving on zone change, but a friend suggested "what if the server crashes, or a person is in same zone for hours."diatanato wrote:не очень удачное решение. слишком много кода для такой простой задачи ((
Thanks for the feedback, I will look at improvement.
Translated to Russian:
Оригинал был области изменения сохраняются только. Поступило предложение для непредвиденных обстоятельств. Аварии сервера или долгое время в одной области.
Благодарю вас за предложение. Я буду исследовать улучшения.
Re: Character /playtime
load playtime on login
save server time when they login
on /playtime, get difference between current time with login time, add that to playtime to get total playtime
on logout/disconnect, write difference between current time with login time + playtime to DB
this just leaves the issue of server crashes
save server time when they login
on /playtime, get difference between current time with login time, add that to playtime to get total playtime
on logout/disconnect, write difference between current time with login time + playtime to DB
this just leaves the issue of server crashes
-
- Developer
- Posts: 707
- Joined: Sun Jul 22, 2012 12:11 am
Re: Character /playtime
I don't believe the accuracy of the info is of vital importance on server crashes. I'm ok with just ignoring that case.
Re: Character /playtime
если в таблицу accounts_sessions добавить новое поле "update_time" и заполнять его текущим временем при каждом изменении session_key (переход между зонами), то можно использовать это значение для подсчета времени, проведенного в игре. делать этот подсчет лишь при переходе между зонами и выходе из игры (что практически одно и тоже). все просто. берем значение update_time (именно в этот момент персонаж вошел в зону) и вычетаем его из текущего времени, а результат добавляем к переменной play_time. в итоге получаем общее время, проведенное в игре.
Re: Character /playtime
Ignoring server crash happenings kind of a big deal in my opinion. Server crashes can happen any time at random. Be it 10 minutes after starting, or 10 days. If a person has played on the server for hours on end, a day, weeks, etc. and it crashes, having all that playtime not recorded isn't really that great.bluekirby0 wrote:I don't believe the accuracy of the info is of vital importance on server crashes. I'm ok with just ignoring that case.
-
- Developer
- Posts: 707
- Joined: Sun Jul 22, 2012 12:11 am
Re: Character /playtime
10 days without zoning? Sounds like a fish bot
Re: Character /playtime
rolanberry afk while on vacationbluekirby0 wrote:10 days without zoning? Sounds like a fish bot
i think i'd be okay with that not counting though
Re: Character /playtime
we can save play time in game midnight with guild shop update (every 1 hour) - CZone::TOTDChange() case TIME_MIDNIGHT