Posts: 328
Threads: 79
Joined: Jan 2011
I want to create some time function with unix timestamp, Lets say time is in regard to hours, So i need to do sumthing like if the time limit give to a player i 1 hour, Instead of checking time onplayerconnect (coz they can exploit time limit by never logging off
atleast some time) can i use the function onplayerupdate , but im afraid it may cause some lag (not sure) will it cause? any solution? And how many timers can be used without server being lagged
Posts: 150
Threads: 0
Joined: Dec 2010
Reputation:
0
Depends on your server spec and network.
Posts: 328
Threads: 79
Joined: Jan 2011
No just take it as some average common server
Posts: 1,317
Threads: 23
Joined: Feb 2010
Reputation:
0
So you want to check a variable, every update for every player?
If its just a single if statement, it probally wouldn't cause lagg, but you'd have to think for yourself, "is the check nessercary to be done every update?" the server updates a player approximately 32 times in a second. You're probally better off, storing the current time in a variable when the player logs on, and then have a timer running that checks every player every hour.
I mean a timer, that starts when the gamemode starts, it just compares the stored time for every player, against a maximum online time, you set before.
Posts: 328
Threads: 79
Joined: Jan 2011
@Playbox, I use unix timestamp , So if calculate the time left and set a timer for it, Then naturally the timerwould stop when player logs off, Thats the problem , it was okay if it is matter of days, but it is in terms of hours so thats where i have a problem, Got any idea for this?
Posts: 328
Threads: 79
Joined: Jan 2011
You didn't get my point, I already knew how to do that but, When the players disconnects before the period of 1 hr the timer naturally is stopped. So its possible to exploit
P.S:- How can i get the time left in a timer? So that i can substract it from the storedtime and save it to a file
Posts: 1,317
Threads: 23
Joined: Feb 2010
Reputation:
0
The timer keeps running, considering its not bound to a player..
You can store the time when the player logs of, you just do the same thing as you do inside the timer, you store the amount of seconds in a variable and save that to a file. Then you use that the next time a player logs in.
Posts: 328
Threads: 79
Joined: Jan 2011
Yah it is supposed to bound to playerid, And how can get time left in a timer?
Posts: 1,317
Threads: 23
Joined: Feb 2010
Reputation:
0
Why would you bound it to a player? The timer just checks if a player is online for 3600 seconds every hour.
When the player disconnects you just use, gettime again, you compare it against the time you stored when he logged in, and there you have the online seconds. You store it somewhere, and use it when he logs in.