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

Help / Support ZP Menu Bank


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Andriis
Member
Join Date: May 2019
Old 05-04-2019 , 11:25   ZP Menu Bank
Reply With Quote #1

Hi!
I searched a bank system plugin to my zp server which has a menu. From the menu I can send ammo packs, I take ammo from the bank and I can deposit ammo in the bank.

I found one on a website, comments said that it's working correctly and stuff.. But when I installed the plugin to my server.. and typed /bank or /wd nothing is happened. I checked the .sma file but found nothing.. It should work but it's not and I don't know why..

Can someone help me with it? Or can someone send me one that is working? Thanks in advance.

This is the plugin I'm talking about:

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

#include <amxmodx>
#include <cstrike>
#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(PLUGIN, VERSION, AUTHOR)
    
    register_clcmd("takeAmount", "cmdTakeAmount")
    register_clcmd("saveAmount", "cmdSaveAmount")
    register_clcmd("donate", "cmdDonate")
    
    register_clcmd("say /bank", "bank_menu")
    register_clcmd("say_team /bank", "bank_menu")
    register_clcmd("say /wd", "bank_menu")
    register_clcmd("say_team /wd", "bank_menu")
}
public bank_menu(id)
{    
    if(is_valid_player(id))  
               {  
        new title[100]
        
        formatex(title, 99, "\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(id, bankMenu, 0)
            // return PLUGIN_HANDLED;
}
}
public menuBankHandler(id, menu, item)
{        
    new data[6], iName[64], access, callback
    menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback)
    
    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(szAps, 10)
    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(id, iApsSum)
        g_AP[id] -= iAps
        
        client_print(id, print_chat, "[MG][Bank] You took %i Ammopacks from Your Bank. Now you have %i Ammopacks in your Bank.", iAps, g_AP[id])
        
        return PLUGIN_CONTINUE
    }
    else
    {
        client_print(id, print_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(id, iApsSum)
        
        client_print(id, print_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(id, giveAps + zp_get_user_ammo_packs(id))
            g_AP[id] -= giveAps
            
            client_print(id, print_chat, "[MG][Bank] You took %i Ammopacks from your Bank. Now you have %i Ammopacks in your Bank.", giveAps, g_AP[id])
        }
    }
}

public cmdSaveAmount(id)
{
    
    new szAps[11]
    read_args(szAps, 10)
    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(id, haveAps - iAps)
        g_AP[id] += iAps
        
        client_print(id, print_chat, "[MG][Bank] You saved %i Ammopacks in your Bank. Now you have %i Ammopacks in your Bank.", iAps, g_AP[id])
    }
    else
    {
        client_print(id, print_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(id, 0)
    g_AP[id] += haveAps
    
    client_print(id, print_chat, "[MG][Bank] You saved %i Ammopacks to your Bank. Now you have %i Ammopacks in your Bank.", haveAps, g_AP[id])
}

public menuDonate(id)
{
    new DonateMenu = menu_create("\rChoose A player to Donate:", "menuDonateHandler")
    
    new players[32], pnum, tempid
    
    new szName[32], szTempid[10]
    
    get_players(players, pnum)
    
    for( new i; i<pnum; i++ )
    {
        tempid = players[i]
        
        if(id != tempid)
        {
            get_user_name(tempid, szName, 31)
            num_to_str(tempid, szTempid, 9)
            
            menu_additem(DonateMenu, szName, szTempid, 0)
        }
    }
    
    menu_display(id, DonateMenu, 0)
}

public menuDonateHandler(id, menu, item)
{    
    new data[6], iName[64];
    new access, callback;
    menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
    
    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(szAps, 10)
    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], NameDonate, 44)
        new Name[45]
        get_user_name(g_DonateID[id], Name, 44)
        
        client_print(id, print_chat, "[MG][Bank] You donated %i Ammopacks to %s. Now you have %i ammopacks in your Bank.", iAps, NameDonate, g_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.", Name, iAps, g_AP[g_DonateID[id]])
    }
    else
    {
        client_print(id, print_chat, "[MG][Bank] You dont have enough Ammopacks")
    }
    
    return PLUGIN_CONTINUE
}
public SaveData(id)    
{    
    new szMethod[ 65 ];   
       
    #if defined STEAM   
    get_user_authid( id, szMethod, 34 );   
    #endif   
       
    #if defined NICK   
    get_user_name( id, szMethod, 34 );   
    #endif   
       
    #if defined IP   
    get_user_ip( id, szMethod, 34, 1 );   
    #endif   
       
    new vaultkey[64], vaultdata[328];    
    format(vaultkey, 63, "zm_%s", szMethod);    
    format(vaultdata, 327, "%i", g_AP[id]);    
       
    fvault_set_data( "Bank_Save", vaultkey, vaultdata );   
}    
public LoadData(id)    
{    
    new szMethod[ 65 ];   
       
    #if defined STEAM   
    get_user_authid( id, szMethod, 34 );   
    #endif   
       
    #if defined NICK   
    get_user_name( id, szMethod, 34 );   
    #endif   
       
    #if defined IP   
    get_user_ip( id, szMethod, 34, 1 );   
    #endif   
       
    new vaultkey[64], vaultdata[328];    
    format(vaultkey, 63, "zm_%s", szMethod);    
    format(vaultdata, 327, "%i", g_AP[id]);    
       
    fvault_get_data( "Bank_Save", vaultkey, vaultdata, charsmax( vaultdata ) );   
       
    g_AP[ id ] = str_to_num( vaultdata );   
}    
// 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 - 74 views - 8.5 KB)
Andriis 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 12:36.


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