Raised This Month: $51 Target: $400
 12% 

ZP Bank Menu


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Fun Stuff       
.Ahlach_.
Junior Member
Join Date: Dec 2015
Old 06-23-2016 , 18:11   ZP Bank Menu
Reply With Quote #1

ZP Bank Menu
Zombie Plague Bank
This plugin saves ammopacks automatique on the bank when map change and player disconnect.
Commands :
say /bank , say /wd
PHP Code:
#include <amxmodx>
#include <zombieplague>
#include <fvault>   

#define PLUGIN "[MG] Bank Menu"
#define VERSION "1.0"
#define AUTHOR "XizzyS x)"

#define is_valid_player(%1) (1 <= %1 <= 32)   

new g_AP[33]
new 
g_DonateID[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("takeAmount""cmdTakeAmount")
    
register_clcmd("saveAmount""cmdSaveAmount")
    
register_clcmd("donate""cmdDonate")
    
    
register_clcmd("say /bank""menuBank")
    
register_clcmd("say_team /bank""menuBank")
    
register_clcmd("say /wd""menuBank")
    
register_clcmd("say_team /wd""menuBank")
}
public 
menuBank(id)
{    
    if(
is_valid_player(id))  
               {  
        new 
title[100]
        
        
formatex(title99"\r[MG] \wBank[ You have in bank : \y%i\w]"g_AP[id])
        
        
        new 
bankMenu menu_create(title"menuBankHandler")
        
        
menu_additem(bankMenu"\wTake Amount""1")
        
menu_additem(bankMenu"\wTake All^n""2")
        
        
menu_additem(bankMenu"\wSave Amount""3")
        
menu_additem(bankMenu"\wSave All^n""4")
        
        
menu_additem(bankMenu"\wDonate Amout^n^n""5")
        
        
        
menu_display(idbankMenu0)
             return 
PLUGIN_HANDLED;
}
}
public 
menuBankHandler(idmenuitem)
{        
    new 
data[6], iName[64], accesscallback
    menu_item_getinfo
(menuitemaccessdata5iName63callback)
    
    new 
key str_to_num(data)
    
    switch(
key)
    {
        case 
1:
        {
            
client_cmd(id"messagemode takeAmount")
        }
        case 
2:
        {
            
cmdTakeAll(id)
        }
        case 
3:
        {
            
client_cmd(id"messagemode saveAmount")
        }
        case 
4:
        {
            
cmdSaveAll(id)
        }
        case 
5:
        {
            
menuDonate(id)
        }
    }
}

public 
cmdTakeAmount(id)
{
    
    new 
szAps[11]
    
read_args(szAps10)
    
remove_quotes(szAps)
    
    if(
equal(szAps"") || equal(szAps" "))
        return 
PLUGIN_HANDLED
    
    
new iAps str_to_num(szAps)
    
    if(
iAps 1) return PLUGIN_HANDLED
    
    
new iApsSum iAps zp_get_user_ammo_packs(id)
    
    if(
iAps <= g_AP[id] && iApsSum <= 999)
    {
        
zp_set_user_ammo_packs(idiApsSum)
        
g_AP[id] -= iAps
        
        client_print
(idprint_chat"[MG][Bank] You took %i Ammopacks from Your Bank. Now you have %i Ammopacks in your Bank."iApsg_AP[id])
        
        return 
PLUGIN_CONTINUE
    
}
    else
    {
        
client_print(idprint_chat"[MG][Bank] You dont have enough Ammopacks or you wanted to take too much Ammopacks.")
    }
    
    return 
PLUGIN_CONTINUE
}

public 
cmdTakeAll(id)
{
    new 
iApsSum zp_get_user_ammo_packs(id) + g_AP[id]
    
    if(
iApsSum <= 999)
    {
        
zp_set_user_ammo_packs(idiApsSum)
        
        
client_print(idprint_chat"[MG][Bank] You took all %i Ammopacks from your Bank."g_AP[id])
        
        
g_AP[id] = 0
    
}
    else if(
iApsSum 999)
    {
        new 
giveAps 999 zp_get_user_ammo_packs(id)
        
        if(
giveAps <= g_AP[id])
        {
            
zp_set_user_ammo_packs(idgiveAps zp_get_user_ammo_packs(id))
            
g_AP[id] -= giveAps
            
            client_print
(idprint_chat"[MG][Bank] You took %i Ammopacks from your Bank. Now you have %i Ammopacks in your Bank."giveApsg_AP[id])
        }
    }
}

public 
cmdSaveAmount(id)
{
    
    new 
szAps[11]
    
read_args(szAps10)
    
remove_quotes(szAps)
    
    if(
equal(szAps"") || equal(szAps" "))
        return 
PLUGIN_HANDLED
    
    
new iAps str_to_num(szAps)
    
    if(
iAps 1) return PLUGIN_HANDLED
    
    
new haveAps zp_get_user_ammo_packs(id)
    
    if(
iAps <= haveAps)
    {
        
zp_set_user_ammo_packs(idhaveAps iAps)
        
g_AP[id] += iAps
        
        client_print
(idprint_chat"[MG][Bank] You saved %i Ammopacks in your Bank. Now you have %i Ammopacks in your Bank."iApsg_AP[id])
    }
    else
    {
        
client_print(idprint_chat"[MG][Bank] You dont have enough Ammopacks")
    }
    
    return 
PLUGIN_CONTINUE
}

public 
cmdSaveAll(id)
{
    new 
haveAps zp_get_user_ammo_packs(id)
    
    
zp_set_user_ammo_packs(id0)
    
g_AP[id] += haveAps
    
    client_print
(idprint_chat"[MG][Bank] You saved %i Ammopacks to your Bank. Now you have %i Ammopackt in your Bank."haveApsg_AP[id])
}

public 
menuDonate(id)
{
    new 
DonateMenu menu_create("\rChoose A player to Donate:""menuDonateHandler")
    
    new 
players[32], pnumtempid
    
    
new szName[32], szTempid[10]
    
    
get_players(playerspnum)
    
    for( new 
ii<pnumi++ )
    {
        
tempid players[i]
        
        if(
id != tempid)
        {
            
get_user_name(tempidszName31)
            
num_to_str(tempidszTempid9)
            
            
menu_additem(DonateMenuszNameszTempid0)
        }
    }
    
    
menu_display(idDonateMenu0)
}

public 
menuDonateHandler(idmenuitem)
{    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    
    new 
tempid str_to_num(data);
    
    
g_DonateID[id] = tempid
    
    client_cmd
(id"messagemode donate")
    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
}

public 
cmdDonate(id)
{
    if(!
g_DonateID[id] == 0) return PLUGIN_HANDLED
    
new szAps[11]
    
read_args(szAps10)
    
remove_quotes(szAps)
    
    if(
equal(szAps"") || equal(szAps" "))
        return 
PLUGIN_HANDLED
    
    
new iAps str_to_num(szAps)
    
    if(
iAps 1) return PLUGIN_HANDLED
    
    
if(iAps <= g_AP[id])
    {
        
// Take iAps away
        
g_AP[id] -= iAps
        
        
new NameDonate[45]
        
get_user_name(g_DonateID[id], NameDonate44)
        new 
Name[45]
        
get_user_name(g_DonateID[id], Name44)
        
        
client_print(idprint_chat"[MG][Bank] You donated %i Ammopacks to %s. Now you have %i ammopacks in your Bank."iApsNameDonateg_AP[id])
        
        
// give iAps to Donateid
        
g_AP[g_DonateID[id]] += iAps
        client_print
(g_DonateID[id], print_chat"[MG][Bank] %s donated %i Ammopacks to you. Now you have %i Ammopacks in your Bank."NameiApsg_AP[g_DonateID[id]])
    }
    else
    {
        
client_print(idprint_chat"[MG][Bank] You dont have enough Ammopacks")
    }
    
    return 
PLUGIN_CONTINUE
}
public 
SaveData(id)    
{    
    new 
szMethod65 ];   
       
    
#if defined STEAM   
    
get_user_authididszMethod34 );   
    
#endif   
       
    #if defined NICK   
    
get_user_nameidszMethod34 );   
    
#endif   
       
    #if defined IP   
    
get_user_ipidszMethod34);   
    
#endif   
       
    
new vaultkey[64], vaultdata[328];    
    
format(vaultkey63"zm_%s"szMethod);    
    
format(vaultdata327"%i"g_AP[id]);    
       
    
fvault_set_data"Bank_Save"vaultkeyvaultdata );   
}    
public 
LoadData(id)    
{    
    new 
szMethod65 ];   
       
    
#if defined STEAM   
    
get_user_authididszMethod34 );   
    
#endif   
       
    #if defined NICK   
    
get_user_nameidszMethod34 );   
    
#endif   
       
    #if defined IP   
    
get_user_ipidszMethod34);   
    
#endif   
       
    
new vaultkey[64], vaultdata[328];    
    
format(vaultkey63"zm_%s"szMethod);    
    
format(vaultdata327"%i"g_AP[id]);    
       
    
fvault_get_data"Bank_Save"vaultkeyvaultdatacharsmaxvaultdata ) );   
       
    
g_APid ] = str_to_numvaultdata );   
}    
// When client enter on server    
public client_putinserver(id)    
{    
    
LoadData(id);    
}    

// When client disconnect    
public client_disconnect(id)    
{  
    
cmdSaveAll(id);      
    
SaveData(id);  
 

Attached Files
File Type: sma Get Plugin or Get Source (zp_bankmenu.sma - 952 views - 7.1 KB)

Last edited by Arkshine; 06-24-2016 at 03:32. Reason: You are not allowed to post compiled plugin
.Ahlach_. is offline
tousif
AlliedModders Donor
Join Date: Nov 2014
Location: India
Old 06-24-2016 , 02:07   Re: ZP Bank Menu
Reply With Quote #2

Remove .amxx file .
tousif is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-24-2016 , 08:41   Re: ZP Bank Menu
Reply With Quote #3

Not another bank plugin...
__________________
HamletEagle is offline
DebexeL
New Member
Join Date: Sep 2016
Location: Finland
Old 09-14-2016 , 09:22   Re: ZP Bank Menu
Reply With Quote #4

Good thing I saw this topic.. I haven't seen any zp bank plugin that I actually got working, other than this. I don't personally care about what method the creator uses for storing the data, as long as it is not veeery very slow.
(Referencing all the talk I have seen about the speeds of fvault, nvault, and other data storing methods.)

But yeah, this actually works! Only thing I noticed when compiling, was 'Warning #213 tag mismatch' that occured at line 228.

Here is the original code and how I fixed it:
Change this:

PHP Code:
public cmdDonate(id

    if(!
g_DonateID[id] == 0) return PLUGIN_HANDLED 
To this:
PHP Code:
public cmdDonate(id

    if(
g_DonateID[id] == 0) return PLUGIN_HANDLED 
And.. I also noticed there were some defines used in the code that were not written at the start of the script:
Here is one part of the code where the defines are needed. It seems he made this to also support NonSteam. I would remove the support, but don't know how.

PHP Code:
#if defined STEAM   
    
get_user_authididszMethod34 );   
    
#endif   
       
    #if defined NICK   
    
get_user_nameidszMethod34 );   
    
#endif   
       
    #if defined IP   
    
get_user_ipidszMethod34);   
    
#endif 
But, anyways.. I got rid of the warning message when compiling, and added the missing defines.
Here is the fixed code for you:
(Also.. Please remove the NonSteam support, we don't need it.)

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <zombieplague>
#include <fvault>   

#define PLUGIN "[MG] Bank Menu"
#define VERSION "1.0"
#define AUTHOR "XizzyS x)"

#define is_valid_player(%1) (1 <= %1 <= 32)

//SELECT ONLY ONE OF THESE THREE BELOW! Nobody know what *might* happen if you select two or even all of them!
//Uncomment '#define STEAM' to use SteamID
//Uncomment '#define NICK' to use PlayerNick
//Uncomment '#define IP' to use Player IP
#define STEAM
//#define NICK
//#define IP

new g_AP[33]
new 
g_DonateID[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("takeAmount""cmdTakeAmount")
    
register_clcmd("saveAmount""cmdSaveAmount")
    
register_clcmd("donate""cmdDonate")
    
    
register_clcmd("say /bank""menuBank")
    
register_clcmd("say_team /bank""menuBank")
    
register_clcmd("say /wd""menuBank")
    
register_clcmd("say_team /wd""menuBank")
}
public 
menuBank(id)
{    
    if(
is_valid_player(id))  
               {  
        new 
title[100]
        
        
formatex(title99"\r[MG] \wBank[ You have in bank : \y%i\w]"g_AP[id])
        
        
        new 
bankMenu menu_create(title"menuBankHandler")
        
        
menu_additem(bankMenu"\wTake Amount""1")
        
menu_additem(bankMenu"\wTake All^n""2")
        
        
menu_additem(bankMenu"\wSave Amount""3")
        
menu_additem(bankMenu"\wSave All^n""4")
        
        
menu_additem(bankMenu"\wDonate Amout^n^n""5")
        
        
        
menu_display(idbankMenu0)
            
// return PLUGIN_HANDLED;
}
}
public 
menuBankHandler(idmenuitem)
{        
    new 
data[6], iName[64], accesscallback
    menu_item_getinfo
(menuitemaccessdata5iName63callback)
    
    new 
key str_to_num(data)
    
    switch(
key)
    {
        case 
1:
        {
            
client_cmd(id"messagemode takeAmount")
        }
        case 
2:
        {
            
cmdTakeAll(id)
        }
        case 
3:
        {
            
client_cmd(id"messagemode saveAmount")
        }
        case 
4:
        {
            
cmdSaveAll(id)
        }
        case 
5:
        {
            
menuDonate(id)
        }
    }
}

public 
cmdTakeAmount(id)
{
    
    new 
szAps[11]
    
read_args(szAps10)
    
remove_quotes(szAps)
    
    if(
equal(szAps"") || equal(szAps" "))
        return 
PLUGIN_HANDLED
    
    
new iAps str_to_num(szAps)
    
    if(
iAps 1) return PLUGIN_HANDLED
    
    
new iApsSum iAps zp_get_user_ammo_packs(id)
    
    if(
iAps <= g_AP[id] && iApsSum <= 999)
    {
        
zp_set_user_ammo_packs(idiApsSum)
        
g_AP[id] -= iAps
        
        client_print
(idprint_chat"[MG][Bank] You took %i Ammopacks from Your Bank. Now you have %i Ammopacks in your Bank."iApsg_AP[id])
        
        return 
PLUGIN_CONTINUE
    
}
    else
    {
        
client_print(idprint_chat"[MG][Bank] You dont have enough Ammopacks or you wanted to take too much Ammopacks.")
    }
    
    return 
PLUGIN_CONTINUE
}

public 
cmdTakeAll(id)
{
    new 
iApsSum zp_get_user_ammo_packs(id) + g_AP[id]
    
    if(
iApsSum <= 999)
    {
        
zp_set_user_ammo_packs(idiApsSum)
        
        
client_print(idprint_chat"[MG][Bank] You took all %i Ammopacks from your Bank."g_AP[id])
        
        
g_AP[id] = 0
    
}
    else if(
iApsSum 999)
    {
        new 
giveAps 999 zp_get_user_ammo_packs(id)
        
        if(
giveAps <= g_AP[id])
        {
            
zp_set_user_ammo_packs(idgiveAps zp_get_user_ammo_packs(id))
            
g_AP[id] -= giveAps
            
            client_print
(idprint_chat"[MG][Bank] You took %i Ammopacks from your Bank. Now you have %i Ammopacks in your Bank."giveApsg_AP[id])
        }
    }
}

public 
cmdSaveAmount(id)
{
    
    new 
szAps[11]
    
read_args(szAps10)
    
remove_quotes(szAps)
    
    if(
equal(szAps"") || equal(szAps" "))
        return 
PLUGIN_HANDLED
    
    
new iAps str_to_num(szAps)
    
    if(
iAps 1) return PLUGIN_HANDLED
    
    
new haveAps zp_get_user_ammo_packs(id)
    
    if(
iAps <= haveAps)
    {
        
zp_set_user_ammo_packs(idhaveAps iAps)
        
g_AP[id] += iAps
        
        client_print
(idprint_chat"[MG][Bank] You saved %i Ammopacks in your Bank. Now you have %i Ammopacks in your Bank."iApsg_AP[id])
    }
    else
    {
        
client_print(idprint_chat"[MG][Bank] You dont have enough Ammopacks")
    }
    
    return 
PLUGIN_CONTINUE
}

public 
cmdSaveAll(id)
{
    new 
haveAps zp_get_user_ammo_packs(id)
    
    
zp_set_user_ammo_packs(id0)
    
g_AP[id] += haveAps
    
    client_print
(idprint_chat"[MG][Bank] You saved %i Ammopacks to your Bank. Now you have %i Ammopacks in your Bank."haveApsg_AP[id])
}

public 
menuDonate(id)
{
    new 
DonateMenu menu_create("\rChoose A player to Donate:""menuDonateHandler")
    
    new 
players[32], pnumtempid
    
    
new szName[32], szTempid[10]
    
    
get_players(playerspnum)
    
    for( new 
ii<pnumi++ )
    {
        
tempid players[i]
        
        if(
id != tempid)
        {
            
get_user_name(tempidszName31)
            
num_to_str(tempidszTempid9)
            
            
menu_additem(DonateMenuszNameszTempid0)
        }
    }
    
    
menu_display(idDonateMenu0)
}

public 
menuDonateHandler(idmenuitem)
{    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    
    new 
tempid str_to_num(data);
    
    
g_DonateID[id] = tempid
    
    client_cmd
(id"messagemode donate")
    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
}

public 
cmdDonate(id)
{
    if(
g_DonateID[id] == 0) return PLUGIN_HANDLED
    
new szAps[11]
    
read_args(szAps10)
    
remove_quotes(szAps)
    
    if(
equal(szAps"") || equal(szAps" "))
        return 
PLUGIN_HANDLED
    
    
new iAps str_to_num(szAps)
    
    if(
iAps 1) return PLUGIN_HANDLED
    
    
if(iAps <= g_AP[id])
    {
        
// Take iAps away
        
g_AP[id] -= iAps
        
        
new NameDonate[45]
        
get_user_name(g_DonateID[id], NameDonate44)
        new 
Name[45]
        
get_user_name(g_DonateID[id], Name44)
        
        
client_print(idprint_chat"[MG][Bank] You donated %i Ammopacks to %s. Now you have %i ammopacks in your Bank."iApsNameDonateg_AP[id])
        
        
// give iAps to Donateid
        
g_AP[g_DonateID[id]] += iAps
        client_print
(g_DonateID[id], print_chat"[MG][Bank] %s donated %i Ammopacks to you. Now you have %i Ammopacks in your Bank."NameiApsg_AP[g_DonateID[id]])
    }
    else
    {
        
client_print(idprint_chat"[MG][Bank] You dont have enough Ammopacks")
    }
    
    return 
PLUGIN_CONTINUE
}
public 
SaveData(id)    
{    
    new 
szMethod65 ];   
       
    
#if defined STEAM   
    
get_user_authididszMethod34 );   
    
#endif   
       
    #if defined NICK   
    
get_user_nameidszMethod34 );   
    
#endif   
       
    #if defined IP   
    
get_user_ipidszMethod34);   
    
#endif   
       
    
new vaultkey[64], vaultdata[328];    
    
format(vaultkey63"zm_%s"szMethod);    
    
format(vaultdata327"%i"g_AP[id]);    
       
    
fvault_set_data"Bank_Save"vaultkeyvaultdata );   
}    
public 
LoadData(id)    
{    
    new 
szMethod65 ];   
       
    
#if defined STEAM   
    
get_user_authididszMethod34 );   
    
#endif   
       
    #if defined NICK   
    
get_user_nameidszMethod34 );   
    
#endif   
       
    #if defined IP   
    
get_user_ipidszMethod34);   
    
#endif   
       
    
new vaultkey[64], vaultdata[328];    
    
format(vaultkey63"zm_%s"szMethod);    
    
format(vaultdata327"%i"g_AP[id]);    
       
    
fvault_get_data"Bank_Save"vaultkeyvaultdatacharsmaxvaultdata ) );   
       
    
g_APid ] = str_to_numvaultdata );   
}    
// When client enter on server    
public client_putinserver(id)    
{    
    
LoadData(id);    
}    

// When client disconnect    
public client_disconnect(id)    
{  
    
cmdSaveAll(id);      
    
SaveData(id);  
 

Thank you for your time, and see you again!
DebexeL 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 08:24.


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