Raised This Month: $ Target: $400
 0% 

Get nVault Timestamp


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 05-14-2020 , 09:38   Get nVault Timestamp
Reply With Quote #1

Hi,
Today I tried to get Timestamp from a nvault key.
Code:
PHP Code:
new iTimestamp szVal10 ], AuthID[33];
    
get_user_authid(idAuthIDcharsmax(AuthID))
        if(!
nvault_lookupg_Vault AuthIDszVal charsmaxszVal ) , iTimestamp )
        {
            
//do stuff
        
}
        else 
        {
            
client_print(idprint_team_default"You need to wait %02d hours until execute again!", (get_systime() - iTimestamp) );
            return 
PLUGIN_HANDLED;
        } 
This should get timeleft until the key got prune, but I get only this every second when I type the command to execute the code above:

PHP Code:
You need to wait 1 hours until execute again!
You need to wait 2 hours until execute again!
You need to wait 3 hours until execute again!
You need to wait 4 hours until execute again
I tried to use UnixTime Converter but nothing.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-14-2020 , 13:44   Re: Get nVault Timestamp
Reply With Quote #2

The timestamp is in seconds, not hours.
Show the code where you're writing/removing data to/from the vault.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 05-14-2020 , 14:12   Re: Get nVault Timestamp
Reply With Quote #3

PHP Code:
public plugin_cfg()
{
   
g_Vault nvault_open("Data");
   if(
g_Vault == INVALID_HANDLE)
      
set_fail_state("Error opening nVault");
   
   
nvault_prune(g_Vault,0,get_systime() - ((60 60) * 24));
}

public 
plugin_end()
{
   
nvault_close(g_Vault);
}

public 
something(id)
{
        new 
iTimestamp szVal10 ], AuthID[33]
        
get_user_authid(idAuthIDcharsmax(AuthID))
        if(!
nvault_lookupg_Vault AuthIDszVal charsmaxszVal ) , iTimestamp ))
        {
            
nvault_setg_Vault AuthID"player_data" );
            
//do something
        
}
        else
        {
            
client_print(idprint_team_default"You need to wait %02d hours until execute again!", (get_systime() - iTimestamp) );
            return 
PLUGIN_HANDLED;
        }

__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 05-14-2020 at 14:12.
Shadows Adi is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-14-2020 , 18:50   Re: Get nVault Timestamp
Reply With Quote #4

As OciXCrom told you, timestamps and get_systime() are in SECONDS.

Either do the math yourself to convert seconds to hours/minutes/seconds, or you can use the below with this include.

PHP Code:
new iTimestamp get_systime() - 198;
new 
iYears,iMonths,iDays,iHours,iMinutes,iSeconds;

timestamp_diffiTimestamp get_systime() , iYears,iMonths,iDays,iHours,iMinutes,iSeconds );    
server_print"Time Left: %d years, %d months, %d days, %d hours, %d minutes, %d seconds"iYears,iMonths,iDays,iHours,iMinutes,iSeconds ); 
Output
Code:
Time Left: 0 years, 0 months, 0 days, 0 hours, 3 minutes, 18 seconds
__________________

Last edited by Bugsy; 05-14-2020 at 18:50.
Bugsy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:06.


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