24.09.2013, 17:56
This can be done without even a timer.
When a player logins, use GetTickCount and store it in a temporary variable.
When a player disconnects, use GetTickCount again minus the variable you used before.
You've got the milliseconds of the online time for the player. That can be easily converted to seconds/minutes/hours. The last step is to add the previous results (those you loaded on login) with the converted results and you get the sum of the online time.
If you want to display the current online time, then follow: "use GetTickCount again minus the variable you used before." and there you go!
When a player logins, use GetTickCount and store it in a temporary variable.
When a player disconnects, use GetTickCount again minus the variable you used before.
You've got the milliseconds of the online time for the player. That can be easily converted to seconds/minutes/hours. The last step is to add the previous results (those you loaded on login) with the converted results and you get the sum of the online time.
If you want to display the current online time, then follow: "use GetTickCount again minus the variable you used before." and there you go!