![]() |
Calculating Offline Time
How would I calculate offline time? I mean how can I tell time, like in 2hrs a player would be unjailed even if he/she is offline. (I'm currently not concerned on the "setlevel2();") for when the players unjailed offline. But, I need a way to calculate time while offline. So it invokes something in 2hrs if the player is offline or not. And please explain the way simply. As timevar2 gets me confused.
|
Use timevar, so basically...
you set the time you want the player to get out PHP Code:
PHP Code:
so 60*60/5 == 720 Edit: In case you might not fully understand timevar is just a variable that the server increments by 1 ever 5 seconds, so its forever going up. Therefore the way in which you can apply timevar is very straight forward. Timevar2 is a more accurate way of judging time(increments every .1 of a second, maybe faster lol but the basis is its a more accurate presentation of time) but I tend to avoid it when doing big time distance calculations as it just ends up giving you messy numbers. Hope this helped you. Have fun :) |
timevar2 is the one most people use because it's more accurate, as timevar increases by 1 every 5 seconds and timevar2 increases as fast as Graal runs, 1:1 ratio.
|
Why not just remove a person from jail when they log in, rather than while they are offline?
|
Quote:
|
Quote:
PHP Code:
PHP Code:
|
Quote:
timevar2 increases by 1 every 1 second With a little algebra, we can determine how much time has passed by setting a variable equal to a time variable, then later on, subtracting the variable you set from the time variable. You can read and write some player variables even when the player is offline by creating a TServerPlayer object. The 3 vars you are concerned with are "x", "y", and "levelname". Here are some examples that might help you.. PHP Code:
Depending on how your script works, you might not even need to use timevar or timevar2. When you jail someone, schedule an event to release their account in however many seconds you wish... then in the event: PHP Code:
|
So does timevar2 go down on its own?
|
It increases automatically as time goes on.
|
Didn't you already make a thread about timevar, Astram?
|
To further clarify...
On the server-side timevar2 is the amount of seconds since the unix epoch (January 1st 1970). On the client-side timevar2 is the amount of seconds the client has been on for. I believe timevar is the same on both server-side and client-side, it's been forever since I've actually used it though. |
I wish Stefan would enable timevar3 for non-G3D servers.
Quote:
Quote:
PHP Code:
Quote:
|
Quote:
PHP Code:
Quote:
|
I made this quickly
PHP Code:
Edit: I can't get on Graal but would this work. PHP Code:
|
Quote:
If you just want a countdown do something like this: PHP Code:
|
| All times are GMT +2. The time now is 11:49 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.