• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Storage time

vagnerkuntz

New Member
Joined
Jun 1, 2012
Messages
45
Reaction score
0
this is correct is time to add an item
Code:
    setPlayerStorageValue(cid, 22334, os.time() + 1*60*60*4)
 
Last edited:
Why would you multiply by 1?
Code:
1 * 60 * 60 * 4 -- 1 is not needed because any number times 1 is the number
-- you can just write
60 * 60 * 4
Code:
Lua manual about os.time():

    The returned value is a number, whose meaning depends on your system. In POSIX, 
Windows, and some other systems, this number counts the number of seconds since some 
given start time (the "epoch"). In other systems, the meaning is not specified, and the number
returned by time can be used only as an argument to os.date and os.difftime.
source : http://stackoverflow.com/questions/16181858/luaj-os-time-return-miliseconds
 
Normally you go something like..
1000 * 60 * 60 * 24 * 7

1000 milliseconds = 1 second
1000 * 60 = 60 seconds (1 minute)
1000 * 60 * 60 = 60 minutes (1 hour)
1000 * 60 * 60 * 24 = 24 hours (1 day)
1000 * 60 * 60 * 24 * 7 = 7 days (1 week)

Of course you could go further, but I think that should be enough for anyone. :p

I think over-all they meant it to be 1 second, but didn't realize it starts in milliseconds.
If you change their numbers to accommodate seconds, it is a 4 hour timer.

Code:
setPlayerStorageValue(cid, 22334, os.time() + 1*60*60*4) -- 14.4 seconds (14,400 milliseconds)
setPlayerStorageValue(cid, 22334, os.time() + 1000 * 60 * 60 * 4) -- 4 hours (14,400,000 milliseconds)
 
Last edited by a moderator:
Normally you go something like..
1000 * 60 * 60 * 24 * 7

1000 milliseconds = 1 second
1000 * 60 = 60 seconds (1 minute)
1000 * 60 * 60 = 60 minutes (1 hour)
1000 * 60 * 60 * 24 = 24 hours (1 day)
1000 * 60 * 60 * 24 * 7 = 7 days (1 week)

Of course you could go further, but I think that should be enough for anyone. :p

I think over-all they meant it to be 1 second, but didn't realize it starts in milliseconds.
If you change their numbers to accommodate seconds, it is a 4 hour timer.

Code:
setPlayerStorageValue(cid, 22334, os.time() + 1*60*60*4) -- 14.4 seconds (14,400 milliseconds)
setPlayerStorageValue(cid, 22334, os.time() + 1000 * 60 * 60 * 4) -- 4 hours (14,400,000 milliseconds)

os.time() return a unix timestamp which is in seconds and not milliseconds, so 1000 * 60 * 60 * 4 = 4000 hours, which is quite a big gap in a timer event
 
I misread the post. Derp derp. :(
I'll edit previous post to avoid confusion.

But yeah, in my script I usually do something like this..
Code:
local time = 1 * 14 * 60 * 60
Just to help me later on when quickly re-reading the code.
I find it a bit easier to calculate.
Meh. :P
 
Back
Top