AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   About get_systime (https://forums.alliedmods.net/showthread.php?t=224686)

Bladell 08-27-2013 08:57

About get_systime
 
How it is work?
What really do this native?Here : http://www.amxmodx.org/funcwiki.php?...time&go=search , I saw that count the seconds from 1 January 1970...Then this expression it's wrong for me:
Code:

nvault_prune(gVaultHandle, 0, get_systime() - (xpSaveDays * 24 * 3600))
If you make the difference betwen seconds elapsed since 1970 and a week (for example), you will get a result wich is in past, not in future.So...how this native work?
I think that the correct expression is
Code:

nvault_prune(gVaultHandle, 0, get_systime() + (xpSaveDays * 24 * 3600))
This is a line from SuperHero Mod...what I am trying to do is a message wich will be shown in the last X days before reset of experience.The problem is that I can't understand how work get_systime native...

YamiKaitou 08-27-2013 09:05

Re: About get_systime
 
get_systime will return the current Unix Epoch value. You are then subtracting a week, so it is expected to get a value in the past. Based on what you have provided, it looks like it is trying to remove old data that hasn't been updated in a week.

Bladell 08-27-2013 10:05

Re: About get_systime
 
Let me exaplin a bit better...
xpSaveDays it's the pointer on cvar sh_xpsavedays...

Code:

nvault_prune(gVaultHandle, 0, get_systime() - (xpSaveDays * 24 * 3600))
So, if I set sh_xpsavedays "7", the native will look like this:

Code:

nvault_prune(gVaultHandle, 0, get_systime() - (7 * 24 * 3600))
0 = start, and the result of get_systime() - (7 * 24 * 3600) = end

But I still not understand, what value return get_systime?The seconds elapsed since 1970?This mean that the value of get_systime() grow every seconds.

YamiKaitou 08-27-2013 10:08

Re: About get_systime
 
Quote:

Originally Posted by Bladell (Post 2022579)
xpSaveDays it's the pointer on cvar sh_xpsavedays...

Then you should be using get_pcvar_num instead of the variable itself

Quote:

But I still not understand, what value return get_systime?
It returns the current Unix Epoch time as reported by the OS.

Quote:

The seconds elapsed since 1970?
http://en.wikipedia.org/wiki/Unix_time

Quote:

This mean that the value of get_systime() grow every seconds.
Yes

President 08-27-2013 12:26

Re: About get_systime
 
When you save something on nvault, it records the time too
and when get_systime()-(time) is bigger than that time(recorded on save), it deletes the line

Do you understand now?

Bladell 09-03-2013 06:47

Re: About get_systime
 
Yea, thanks :)


All times are GMT -4. The time now is 18:49.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.