View Single Post
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 11-22-2020 , 00:14   Re: Save for certain steams
Reply With Quote #4

Bump, someone?

I try this but dont work

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

//Uncomment 'IM_USING_ZP50' if your server is running ZP50 and above.
//#define IM_USING_ZP50
#if defined IM_USING_ZP50
native zp_ammopacks_get(id)
native zp_ammopacks_set(idamount)
#else
native zp_get_user_ammo_packs(id)
native zp_set_user_ammo_packs(idamount)
#endif

//Your vault name
#define VAULT_NAME "apstore"

//Max player's ammopack that can be save in vault.
#define MAX_AMMOPACK 9999

//Max day player's ammopack can be stay in vault, set 0 = permanent.
#define DAY_PRUNE 0
new hVaultHandlebool:bIsLoaded[33], szSteamid[33][35], g_bSave[33];

new const 
saveSteam[][]=
{
    {
"STEAM ONE"},
    {
"STEAM TWO"}
}

public 
plugin_init()
{
    
register_plugin("ZP AP Store""0.0.1""wbyokomo")
}

public 
plugin_cfg()
{
    
hVaultHandle nvault_open(VAULT_NAME)
    if(
hVaultHandle == INVALID_HANDLE)
    {
        new 
szText[128]
        
formatex(szText127"Error opening '%s' nVault."VAULT_NAME)
        
set_fail_state(szText)
    }
    
    new 
day DAY_PRUNE
    
if(day 0nvault_prune(hVaultHandle0get_systime() - (DAY_PRUNE 86400));
}

public 
plugin_end()
{
    
nvault_close(hVaultHandle)
}

public 
client_putinserver(id)
{
    if(
is_user_hltv(id)) return;
    if(
is_user_bot(id)) return;

    
g_bSave[id] = false;

    
get_user_authid(idszSteamid[id], 34)

    for(new 
0sizeof(saveSteam); i++)
    {
        if(
equal(szSteamid[id], saveSteam[i]))
        {
            
g_bSave[id] = true;
            break;
        }
    }
     
    
LoadData(id)
}

public 
client_disconnect(id)
{
    
SaveData(id)
    
g_bSave[id] = bIsLoaded[id] = false
}

LoadData(id)
{
    if(!
g_bSave[id])
        return;

    new 
szKey[40]
    
formatex(szKey39"%sZPAP"szSteamid[id])
    new 
iAmmo nvault_get(hVaultHandleszKey)
    
#if defined IM_USING_ZP50
    
zp_ammopacks_set(idiAmmo)
    
#else
    
zp_set_user_ammo_packs(idiAmmo)
    
#endif
    
bIsLoaded[id] = true
}

SaveData(id)
{
    if(!
bIsLoaded[id] || !g_bSave[id]) return;
    
    
#if defined IM_USING_ZP50
    
new ap zp_ammopacks_get(id)
    
#else
    
new ap zp_get_user_ammo_packs(id)
    
#endif
    
if(ap MAX_AMMOPACKap MAX_AMMOPACK;
    new 
szAmmo[12], szKey[40]
    
formatex(szKey39"%sZPAP"szSteamid[id])
    
formatex(szAmmo11"%d"ap)
    
nvault_set(hVaultHandleszKeyszAmmo)


Last edited by wicho; 11-22-2020 at 00:32.
wicho is offline