Small tick() question

The definition for tick() on the wiki site says this:

number tick()
Returns how much time has elapsed since the UNIX epoch, on the current local session’s computer.
The UNIX epoch is represented by the date January 1st, 1970.

By “local sessions computer”, does that mean if I store the current tick() and the player changes their date and time to lets say a day more than it currently is, if I were to reward something every day, could they just constantly change their time and get rewards?

Yea it will work if they change their pc time, try to use a server sided time method, as the gift system should be server sided.

2 Likes

It was just an example, just trying to see if it does that before I use tick() for anything important, thanks! :slight_smile:

Use os.time() in the server side for it to work.

2 Likes

Yes. The Client can change their system time to change what tick() will return.
But a thing here is: Why would you let the client determine whether or not they should get rewarded something everyday? It’s pretty much routine to never ever trust the client.

You’re much better off having the server determine whether or not the player is worthing of an award using os.time(). Which returns the time since the Unix Epoch in UTC Time, as opposed to a local system’s time.

1 Like

Again, It was just an example to make sure I dont use it for anything too important. I was trying to find a way to get the players local timezone w/o having to use os.time() cause I dont know how to get it from that. :slight_smile:

1 Like

Why not tick() instead of os.time?

Thats the reason I created the topic. If someone changes their devices time, It will take it as they client is telling the truth, we simply cannot trust the client with anything. os.time() is the same always and cannot be changed.

I was asking the question in terms of the server, not client.

Wouldn’t it still take the clients time, or am I just not understanding? :3

If the server did tick() it wouldn’t use the client’s data. And it wouldn’t know which client to take it from. Think about it :stuck_out_tongue:

No os.date and tick() on the server side wont take the clients time, only on client side it will.

If it wont be using a clients time what timezone will it be in?

It will be using the EPOCH timestamp which is UTC/GMT time zone.

Like the client. tick() on the server will change depending on where the server’s location is.
For simple things like timers, aka things that will only run during the duration of that server. tick() is fine to use on the server then. But for things like giving out rewards. Using os.time() is pretty much a must, as it always returns the same time-zone: UTC.

1 Like

Alright thank you, I believe I understand now. :smiley: