Jump to content
  • 0

Total time online of a player saved in db


Nana

Question


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  118
  • Reputation:   6
  • Joined:  12/20/12
  • Last Seen:  

Is there any chanse to k now the total time online like a timer that starts when someone login, and stop when someone be afk, or vending or logout or something like these?

I think i can made the stoped part, but i really dont know how inicialize the timer

Do anyone have any clue about this?

Thanks a lot n_n

Link to comment
Share on other sites

9 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  43
  • Reputation:   15
  • Joined:  06/24/12
  • Last Seen:  

You can start by save the login time tick in a variable, just like this:

OnPcLoginEvent:
set tick, gettimetick(2);

When the player logs out, you can subtract the setted tick with an actual tick, then sum it with the value on DB, just like this:

OnPcLogoutEvent:
set time, gettimetick(2) - tick;

This will give you the time (in seconds) that the player were online. I'll let the queries part up to you! ;)

  • Upvote 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  118
  • Reputation:   6
  • Joined:  12/20/12
  • Last Seen:  

Great!! thanks a lot n_n

I'll give a shot with this n_n!!!

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

should be like this...

OnPCLoginEvent:
@login_time = gettimetick(2);
end;
OnPCLogoutEvent:
#online_time += ( gettimetick(2) - @login_time );
end;

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  43
  • Reputation:   15
  • Joined:  06/24/12
  • Last Seen:  

should be like this...

OnPCLoginEvent:
@login_time = gettimetick(2);
end;
OnPCLogoutEvent:
#online_time += ( gettimetick(2) - @login_time );
end;

@login_time will be deleted after "end;"

And, yes, it would be a better idea to store it on an account variable.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

yes...because we dont need to save it permanently....

we only need a permanent variable to store total online time..not the "different" between login time and logout time..

your method that shown in above...

the "time" variable will be reset and assigned with new value everytime they login and logout....

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  43
  • Reputation:   15
  • Joined:  06/24/12
  • Last Seen:  

I did it that way because she said to store it on Database. I was expecting her to make a query that updates the old value plus the new "time" value, so there woudn't be problems on reseting the variable everytime the players logon again.

As I said, "I'll let the queries part up to you!"...

Edited by Schrwaizer
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  118
  • Reputation:   6
  • Joined:  12/20/12
  • Last Seen:  

thanks n_n

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  161
  • Reputation:   31
  • Joined:  12/06/11
  • Last Seen:  

Emistry's script does exactly the same to what your script does, but in a cleaner fashion. "@login_time" is your "tick", and since "Tick" 's value will change again upon login, it is pointless to have it as a permanent variable stored in the database. The Variable Emistry used, isn't deleted upon 'end' but upon server restart.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  52
  • Reputation:   0
  • Joined:  04/27/13
  • Last Seen:  

Hello, i know its an old post,

 

what is there any command to type on chat to get total time played in the whole life of the character?

 

 

Thank you.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...