Raised This Month: $32 Target: $400
 8% 

NVault_Prune Certain Hour


Post New Thread Reply   
 
Thread Tools Display Modes
Depresie
Veteran Member
Join Date: Nov 2013
Old 05-08-2015 , 08:27   Re: NVault_Prune Certain Hour
Reply With Quote #21

Lets say i recieved my free mode for today, and here comes 00:00, and at 00:01 i try the free mode command, but the map didnt change yet so i will not recieve my free mode, and i tought that would update the prune and i will not be able to recieve the free mode again after map change, only on the next day

But the code works excelent, no issues at all

Last edited by Depresie; 05-08-2015 at 09:05.
Depresie is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-08-2015 , 09:25   Re: NVault_Prune Certain Hour
Reply With Quote #22

You could just check the timestamp of the existing nvault entry to see if a day has passed. If you go this route, you can ditch the entire pruning method.
__________________
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-08-2015 , 10:31   Re: NVault_Prune Certain Hour
Reply With Quote #23

Give this a try. The prune that is used here is just for cleanup and it does not impact the decision as to whether or not the player can use the command. It will prevent your vault file from getting huge.

Untested
PHP Code:
#include <amxmodx>
#include <nvault>

new g_Vault g_szAuthID33 ][ 34 ];

public 
plugin_init() 
{
    
register_plugin"Command once per day" "0.1" "bugsy" );
    
    
register_clcmd"getitem" "GiveItem" );
}

public 
plugin_cfg()
{
    
g_Vault nvault_open"test" );
    
    
nvault_pruneg_Vault get_systime() - 86400 );
}

public 
client_authorizedid )
{
    
get_user_authidid g_szAuthIDid ] , charsmaxg_szAuthID[] ) );
}

public 
GiveItemid )
{
    new 
iTimestamp szVal10 ];
    
    if ( !
nvault_lookupg_Vault g_szAuthIDid ] , szVal charsmaxszVal ) , iTimestamp ) || ( iTimestamp && ( ( get_systime() - iTimestamp ) >= 86400 ) ) )
    {
        
//ok to give item
        
        
nvault_setg_Vault g_szAuthIDid ] , "whatever" );
    }
    else
    {
        
//you can only have this once per day
    
}

__________________

Last edited by Bugsy; 05-08-2015 at 10:31.
Bugsy is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 05-08-2015 , 11:43   Re: NVault_Prune Certain Hour
Reply With Quote #24

ah, so you say to check if the data is in the nvault instead of loading it
i was thinking about that, but as the previous method works flawlessly, i think i will stick with it
anyway thanks for the tuts im sure im gonna meet with nvault again soon, and all the stuff you posted will help me alot
Depresie is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-08-2015 , 11:51   Re: NVault_Prune Certain Hour
Reply With Quote #25

This one is better and precise, at the exact moment 24 hours passes he will be able to use the command again.
__________________
Bugsy is offline
Reply


Thread Tools
Display Modes

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 04:57.


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