Page 1 of 2
Character /playtime
Posted: Wed Feb 27, 2013 10:05 pm
by Hypnotoad
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.
Re: Character /playtime
Posted: Fri Mar 01, 2013 3:42 am
by diatanato
не очень удачное решение. слишком много кода для такой простой задачи ((
Re: Character /playtime
Posted: Fri Mar 01, 2013 6:33 pm
by Hypnotoad
diatanato wrote:не очень удачное решение. слишком много кода для такой простой задачи ((
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."
Thanks for the feedback, I will look at improvement.
Translated to Russian:
Оригинал был области изменения сохраняются только. Поступило предложение для непредвиденных обстоятельств. Аварии сервера или долгое время в одной области.
Благодарю вас за предложение. Я буду исследовать улучшения.
Re: Character /playtime
Posted: Fri Mar 01, 2013 7:38 pm
by kjLotus
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
Re: Character /playtime
Posted: Sat Mar 02, 2013 1:07 am
by bluekirby0
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
Posted: Mon Mar 04, 2013 4:21 am
by diatanato
если в таблицу accounts_sessions добавить новое поле "update_time" и заполнять его текущим временем при каждом изменении session_key (переход между зонами), то можно использовать это значение для подсчета времени, проведенного в игре. делать этот подсчет лишь при переходе между зонами и выходе из игры (что практически одно и тоже). все просто. берем значение update_time (именно в этот момент персонаж вошел в зону) и вычетаем его из текущего времени, а результат добавляем к переменной play_time. в итоге получаем общее время, проведенное в игре.
Re: Character /playtime
Posted: Mon Mar 04, 2013 9:13 am
by atom0s
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.
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.
Re: Character /playtime
Posted: Mon Mar 04, 2013 12:20 pm
by bluekirby0
10 days without zoning? Sounds like a fish bot
Re: Character /playtime
Posted: Mon Mar 04, 2013 1:01 pm
by kjLotus
bluekirby0 wrote:10 days without zoning? Sounds like a fish bot
rolanberry afk while on vacation
i think i'd be okay with that not counting though
Re: Character /playtime
Posted: Tue Mar 05, 2013 12:29 am
by diatanato
we can save play time in game midnight with guild shop update (every 1 hour) - CZone::TOTDChange() case TIME_MIDNIGHT