Raised This Month: $ Target: $400
 0% 

Use command once a day


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 11-23-2018 , 14:45   Use command once a day
Reply With Quote #1

Hi all, well I want to add a command /get that gives 50 ammo packs but I want to only use it once a day, I did this but it does not work, I can use it once on each map, can someone tell me what is the problem? ... thx in advance

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

#define PLUGIN "command"
#define VERSION "1.0"
#define AUTHOR "kha"

//Name of vault
#define VAULT_NAME "getap"

new g_last_used[33], g_iVault
new g_szAuthID[33][34]

public 
plugin_init() 
{
         
register_plugin(PLUGINVERSIONAUTHOR)

         
register_clcmd("say /get""block_use")
}

public 
plugin_cfg()
{
         
g_iVault nvault_open(VAULT_NAME)
         if(
g_iVault == INVALID_HANDLE)
         {
             new 
szText[128]
             
formatex(szText127"Error opening '%s' nVault."VAULT_NAME)
             
set_fail_state(szText)
         }
}

public 
plugin_end()
{
         
nvault_close(g_iVault)
}

public 
client_putinserver(id)
{
         
get_user_authid(idg_szAuthID[id], charsmax(g_szAuthID[]))
         
LoadTime(id)
}

public 
block_use(id
{
         if(
get_systime() - g_last_used[id] < 86400
         {
         
client_print(idprint_chat"This command can only be used once a day!")
                  return 
PLUGIN_HANDLED
         
}

         
zp_ammopacks_set(idzp_ammopacks_get(id) + 50)
         
client_print(idprint_chat"You got 50 ammo packs enjoy them!!")
     
         
SaveTime(id)
         return 
PLUGIN_HANDLED


public 
LoadTime(id)
{
         
g_last_used[id] = nvault_get(g_iVaultg_szAuthID[id])  


public 
SaveTime(id)
{
         new 
szTime[5]
         
num_to_str(g_last_used[id], szTimecharsmax(szTime))
         
nvault_set(g_iVaultg_szAuthID[id], szTime)
         
g_last_used[id] = get_systime()

wicho is offline
 



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 07:37.


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