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

Save for certain steams


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 10-28-2020 , 00:44   Save for certain steams
Reply With Quote #1

Hello everyone, well as the title says, how can I do so that it is only saved to certain steams? Could you give me an example please? ... Thanks in advance

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]

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;
    
    
get_user_authid(idszSteamid[id], 34)
    
LoadData(id)
}

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

LoadData(id)
{
    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]) 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)

wicho is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-28-2020 , 07:48   Re: Save for certain steams
Reply With Quote #2

Code:
new const AUTH_LIST[][MAX_AUTHID_LENGTH] = {     "steam one",     "steam two" } LoadData(id) {     new auth[MAX_AUTHID_LENGTH]     get_user_authid(id, auth, charsmax(auth))     for (new i = 0; i < sizeof AUTH_LIST; i++)     {         if (equali(auth, AUTH_LIST[i]))         {             new szKey[40]             formatex(szKey, 39, "%sZPAP", auth)             new iAmmo = nvault_get(hVaultHandle, szKey)             #if defined IM_USING_ZP50             zp_ammopacks_set(id, iAmmo)             #else             zp_set_user_ammo_packs(id, iAmmo)             #endif             bIsLoaded[id] = true             break         }     } }
__________________









Last edited by CrazY.; 10-28-2020 at 07:48.
CrazY. is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 11-04-2020 , 00:42   Re: Save for certain steams
Reply With Quote #3

I tested but dont work the ammo packs dont save
wicho is offline
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
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 11-22-2020 , 11:52   Re: Save for certain steams
Reply With Quote #5

Code:
new const saveSteam[][]= {     {"STEAM ONE"},     {"STEAM TWO"} }
You actually have to put steam id's in there.
__________________
Black Rose is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 11-22-2020 , 15:12   Re: Save for certain steams
Reply With Quote #6

Yes I already put it but it doesn't work I don't understand why it doesn't work
wicho 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 09:36.


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