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(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /get", "block_use")
}
public plugin_cfg()
{
g_iVault = nvault_open(VAULT_NAME)
if(g_iVault == INVALID_HANDLE)
{
new szText[128]
formatex(szText, 127, "Error opening '%s' nVault.", VAULT_NAME)
set_fail_state(szText)
}
}
public plugin_end()
{
nvault_close(g_iVault)
}
public client_putinserver(id)
{
get_user_authid(id, g_szAuthID[id], charsmax(g_szAuthID[]))
LoadTime(id)
}
public block_use(id)
{
if(get_systime() - g_last_used[id] < 86400)
{
client_print(id, print_chat, "This command can only be used once a day!")
return PLUGIN_HANDLED
}
zp_ammopacks_set(id, zp_ammopacks_get(id) + 50)
client_print(id, print_chat, "You got 50 ammo packs enjoy them!!")
SaveTime(id)
return PLUGIN_HANDLED
}
public LoadTime(id)
{
g_last_used[id] = nvault_get(g_iVault, g_szAuthID[id])
}
public SaveTime(id)
{
new szTime[5]
num_to_str(g_last_used[id], szTime, charsmax(szTime))
nvault_set(g_iVault, g_szAuthID[id], szTime)
g_last_used[id] = get_systime()
}