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

[Request] Change Ammo Bank To Money Bank


Post New Thread Reply   
 
Thread Tools Display Modes
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 04-30-2020 , 18:33   Re: [Request] Change Ammo Bank To Money Bank
Reply With Quote #11

@Supremache
Quote:
Originally Posted by Napoleon_be
it won't work yet.
It won't work because there are many unimplemented parts.
It will be implemented when he comes back.
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-01-2020 , 02:37   Re: [Request] Change Ammo Bank To Money Bank
Reply With Quote #12

Quote:
Originally Posted by +ARUKARI- View Post
@Supremache


It won't work because there are many unimplemented parts.
It will be implemented when he comes back.
I really dont understand u..
Supremache is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-01-2020 , 02:59   Re: [Request] Change Ammo Bank To Money Bank
Reply With Quote #13

Quote:
Originally Posted by Supremache View Post
I really dont understand u..
It does not work yet, wait longer, okay?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-01-2020 , 03:33   Re: [Request] Change Ammo Bank To Money Bank
Reply With Quote #14

Quote:
Originally Posted by Napoleon_be View Post
It does not work yet, wait longer, okay?
Okey bro take your time
Supremache is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-01-2020 , 15:33   Re: [Request] Change Ammo Bank To Money Bank
Reply With Quote #15

Here you go, it's ready. I tested only the simple things, please let me know if bugs occure. Also, it's a quickly coded plugin, things could be optimized but i don't really have time for that at the moment.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <basebuilder>
#include <cstrike>
#include <nvault>

#pragma semicolon 1

#if !defined MAX_PLAYERS
    
const MAX_PLAYERS 32;
#endif

#define MAXCASH 16000
#define MAXBANKCASH 1000000000

new const szVersion[] = "1.0.0";

new 
iVault;
new 
iMoney[MAX_PLAYERS 1];
new 
szTargetId[32];
new 
iDonateTarget[32];

new 
pExceedLimit;

public 
plugin_init() {
      
register_plugin("BankMenu"szVersion"NapoleoN#");

      
iVault nvault_open("BaseBuilderBank");

      
register_clcmd("say /bank""ShowBankMenu");

      
register_clcmd("say /rb""ResetBank");

      
register_clcmd("TakeCashFromBank""WithdrawMessageModeHandler");
      
register_clcmd("DepositCashToBank""DepositMessageModeHandler");
      
register_clcmd("EnterAmount""DonateMessageModeHandler");

      
pExceedLimit =     register_cvar("bank_cashlimit""1"); // Change to 0 if u want to be able to withdraw / deposit more than 16k$
}

public 
ResetBank(id) {
    if(
get_user_flags(id) & ADMIN_BAN) {
        
iMoney[id] = 0;
        
ColorChat(idGREEN"[BB]^1 Banks have been reset by an admin.");
    }
}

public 
plugin_end() {
    
nvault_close(iVault);
}

#if AMXX_VERSION_NUM < 183
public client_disconnect(id) {
#else
public client_disconnected(id) {
#endif
    
SaveData(id);
}

public 
client_authorized(id) {
    
LoadData(id);
}

public 
SaveData(id) {
    new 
szAuth[35], szTemp[10];
    
get_user_authid(idszAuthcharsmax(szAuth));

    
formatex(szTempcharsmax(szTemp), "%i"iMoney[id]);

    
nvault_set(iVaultszAuthszTemp);
}

public 
LoadData(id) {
    new 
szAuth[35], szMoney[10], szTemp[10];
    
get_user_authid(idszAuthcharsmax(szAuth));

    
nvault_get(iVaultszAuthszTempcharsmax(szTemp));

    
parse(szTempszMoneycharsmax(szMoney));

    
iMoney[id] = str_to_num(szMoney);
}

public 
ShowBankMenu(id) {
    new 
szHeader[70];
    
formatex(szHeadercharsmax(szHeader), "\yBank Menu \r[Protected] ^n\yYou have %i$"iMoney[id]);

    new 
iBankMenu menu_create(szHeader"BankHandler");

    
menu_additem(iBankMenu"\wWithdraw");
    
menu_additem(iBankMenu"\wWithdraw All^n");

    
menu_additem(iBankMenu"\wDeposit");
    
menu_additem(iBankMenu"\wDeposit All^n");

    
menu_additem(iBankMenu"\yManage Your Account^n^n");

    
menu_additem(iBankMenu"\rDonate Cash^n");

    
menu_display(idiBankMenu);
}

public 
BankHandler(idiBankMenuiItem) {
    if(
is_user_connected(id) && iItem != MENU_EXIT) {
        switch(
iItem) {
            case 
0client_cmd(id"messagemode TakeCashFromBank");
            case 
1WithdrawAllCash(id);
            case 
2client_cmd(id"messagemode DepositCashToBank");
            case 
3DepositAllCash(id);
            case 
4client_cmd(id"say /register");
            case 
5DonateCash(id);
        }
    }

    
menu_destroy(iBankMenu);
}

public 
WithdrawMessageModeHandler(id) {
    new 
szAmount[10], iAmountiCashiTotalCash;
    
read_argv(1szAmountcharsmax(szAmount));

    
iAmount str_to_num(szAmount);
    
iCash cs_get_user_money(id);
    
iTotalCash iAmount iCash;

    if(
iAmount <= iMoney[id]) {
        if(
iAmount MAXCASH) {
            if(!
get_pcvar_num(pExceedLimit)) {
                
iMoney[id] -= iAmount;
                
cs_set_user_money(idiTotalCash);
            }

            else {
                
ColorChat(idGREEN"[BB]^1 Max withdrawal amount is 16.000$");
            }
        }

        else {
            if(
iTotalCash <= MAXCASH) {
                
iMoney[id] -= iAmount;
                
cs_set_user_money(idiTotalCash);
            }

            else {
                
ColorChat(idGREEN"[BB]^1 Max cash limit exceeded.");
            }
        }

    }

    else {
        
ColorChat(idGREEN"[BB]^1 You can't withdraw more than you currently have banked.");
    }

    
ColorChat(idGREEN"Test: szAmount = %i"iAmount);
}

public 
WithdrawAllCash(id) {
    new 
iCash cs_get_user_money(id);
    new 
iCashBuffer;

    if(
iMoney[id] > 0) {
        if(!
get_pcvar_num(pExceedLimit)) {
            
iCashBuffer iMoney[id];
            
iMoney[id] -= iCashBuffer;
            
cs_set_user_money(idiMoney[id] + iCashBuffer);
        }

        else {
            
iCashBuffer MAXCASH iCash;

            if(
iMoney[id] < iCashBuffer) {
                
cs_set_user_money(idiCash iMoney[id]);
                
iMoney[id] -= iMoney[id];
            }
            else {
                
cs_set_user_money(idiCash iCashBuffer);
                
iMoney[id] -= iCashBuffer;
            }
        }
    }
}

public 
DepositMessageModeHandler(id) {
    new 
szAmount[10], iAmountiCash;
    
read_argv(1szAmountcharsmax(szAmount));

    
iAmount str_to_num(szAmount);
    
iCash cs_get_user_money(id);

    if(
iAmount 0) {
        if(
iAmount <= iCash) {
            
iMoney[id] += iAmount;
            
cs_set_user_money(idclamp(iCash iAmount0_));
        }

        else {
            
ColorChat(idGREEN"[BB]^1 You don't have that much cash.");
        }
    }

    else {
        
ColorChat(idGREEN"[BB]^1 Specify a minimum of 1$");
    }
}

public 
DepositAllCash(id) {
    new 
iCash cs_get_user_money(id);

    if(
iCash 0) {
        
iMoney[id] += iCash;
        
cs_set_user_money(idiCash iCash);
    }

    else {
        
ColorChat(idGREEN"[BB]^1 You don't have any cash to deposit.");
    }
}

public 
DonateCash(id) {
    new 
iPlayerMenu menu_create("Choose a player to donate to:""DonateHandler");

    new 
iPlayers[MAX_PLAYERS], iNumszName[32], iPlayerszUserId[32];
    
get_players(iPlayersiNum"ch");

    for(new 
iiNumi++) {
        
iPlayer iPlayers[i];
        
get_user_name(iPlayerszNamecharsmax(szName));
        
num_to_str(get_user_userid(iPlayer), szUserIdcharsmax(szUserId));
        
menu_additem(iPlayerMenuszNameszUserId);
    }
    
menu_display(idiPlayerMenu);
}

public 
DonateHandler(idiPlayerMenuiItem) {
    if(
iItem != MENU_EXIT) {
        new 
iAccessiCallBack;
        
menu_item_getinfo(iPlayerMenuiItemiAccessszTargetIdcharsmax(szTargetId), __iCallBack);

        
client_cmd(id"messagemode EnterAmount");
    }
    
menu_destroy(iPlayerMenu);
}

public 
DonateMessageModeHandler(id) {
    new 
iUserId str_to_num(szTargetId);
    
iDonateTarget[id] = find_player("k"iUserId);

    if(
iDonateTarget[id] && is_user_connected(iDonateTarget[id])) {
        new 
szInput[32], iAmount;
        
read_argv(1szInputcharsmax(szInput));

        
iAmount str_to_num(szInput);

        if(
iAmount <= iMoney[id]) {
            
iMoney[id] -= iAmount;
            
iMoney[iDonateTarget[id]] += iAmount;

            new 
szName[32], szNameReceiver[32];
            
get_user_name(idszNamecharsmax(szName));
            
get_user_name(iDonateTarget[id], szNameReceivercharsmax(szNameReceiver));

            
ColorChat(idGREEN"[BB]^3 %s^1 donated^4 %i$^1 to^3 %s."szNameiAmountszNameReceiver);
        }

        else {
            
ColorChat(idGREEN"[BB]^1 You don't have enough funds on your bank.");
        }
    }

    else {
        
ColorChat(idGREEN"[BB]^1 Invalid target.");
    }

Attached Files
File Type: sma Get Plugin or Get Source (BaseBuilderBank.sma - 47 views - 6.4 KB)
__________________

Last edited by Napoleon_be; 05-02-2020 at 05:45.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-01-2020 , 19:13   Re: [Request] Change Ammo Bank To Money Bank
Reply With Quote #16

Quote:
Originally Posted by Napoleon_be View Post
Here you go, it's ready. I tested only the simple things, please let me know if bugs occure. Also, it's a quickly coded plugin, things could be optimized but i don't really have time for that at the moment.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <basebuilder>
#include <cstrike>
#include <nvault>

#pragma semicolon 1

#if !defined MAX_PLAYERS
    
const MAX_PLAYERS 32;
#endif

#define MAXCASH 16000
#define MAXBANKCASH 1000000000

new const szVersion[] = "1.0.0";

new 
iVault;
new 
iMoney[MAX_PLAYERS 1];
new 
szTargetId[32];
new 
iDonateTarget[32];

new 
pExceedLimit;

public 
plugin_init() {
      
register_plugin("BankMenu"szVersion"NapoleoN#");

      
iVault nvault_open("BaseBuilderBank");

      
register_clcmd("say /bank""ShowBankMenu");

      
register_clcmd("TakeCashFromBank""WithdrawMessageModeHandler");
      
register_clcmd("DepositCashToBank""DepositMessageModeHandler");
      
register_clcmd("EnterAmount""DonateMessageModeHandler");

      
pExceedLimit =     register_cvar("bank_cashlimit""1"); // Change to 0 if u want to be able to withdraw / deposit more than 16k$
}

public 
plugin_end() {
    
nvault_close(iVault);
}

#if AMXX_VERSION_NUM < 183
public client_disconnect(id) {
#else
public client_disconnected(id) {
#endif
    
SaveData(id);
}

public 
client_authorized(id) {
    
LoadData(id);
}

public 
SaveData(id) {
    new 
szAuth[35], szTemp[10];
    
get_user_authid(idszAuthcharsmax(szAuth));

    
formatex(szTempcharsmax(szTemp), "%i"iMoney[id]);

    
nvault_set(iVaultszAuthszTemp);
}

public 
LoadData(id) {
    new 
szAuth[35], szMoney[10], szTemp[10];
    
get_user_authid(idszAuthcharsmax(szAuth));

    
nvault_get(iVaultszAuthszTempcharsmax(szTemp));

    
parse(szTempszMoneycharsmax(szMoney));

    
iMoney[id] = str_to_num(szMoney);
}

public 
ShowBankMenu(id) {
    new 
szHeader[70];
    
formatex(szHeadercharsmax(szHeader), "\yBank Menu \r[Protected] ^n\yYou have %i$"iMoney[id]);

    new 
iBankMenu menu_create(szHeader"BankHandler");

    
menu_additem(iBankMenu"\wWithdraw");
    
menu_additem(iBankMenu"\wWithdraw All^n");

    
menu_additem(iBankMenu"\wDeposit");
    
menu_additem(iBankMenu"\wDeposit All^n");

    
menu_additem(iBankMenu"\yManage Your Account^n^n");

    
menu_additem(iBankMenu"\rDonate Cash^n");

    
menu_display(idiBankMenu);
}

public 
BankHandler(idiBankMenuiItem) {
    if(
is_user_connected(id) && iItem != MENU_EXIT) {
        switch(
iItem) {
            case 
0client_cmd(id"messagemode TakeCashFromBank");
            case 
1WithdrawAllCash(id);
            case 
2client_cmd(id"messagemode DepositCashToBank");
            case 
3DepositAllCash(id);
            case 
4client_cmd(id"say /register");
            case 
5DonateCash(id);
        }
    }

    
menu_destroy(iBankMenu);
}

public 
WithdrawMessageModeHandler(id) {
    new 
szAmount[10], iAmountiCashiTotalCash;
    
read_argv(1szAmountcharsmax(szAmount));

    
iAmount str_to_num(szAmount);
    
iCash cs_get_user_money(id);
    
iTotalCash iAmount iCash;

    if(
iAmount <= iMoney[id]) {
        if(
iAmount MAXCASH) {
            if(!
get_pcvar_num(pExceedLimit)) {
                
iMoney[id] -= iAmount;
                
cs_set_user_money(idiTotalCash);
            }

            else {
                
ColorChat(idGREEN"[BB]^1 Max withdrawal amount is 16.000$");
            }
        }

        else {
            if(
iTotalCash <= MAXCASH) {
                
iMoney[id] -= iAmount;
                
cs_set_user_money(idiTotalCash);
            }

            else {
                
ColorChat(idGREEN"[BB]^1 Max cash limit exceeded.");
            }
        }

    }

    else {
        
ColorChat(idGREEN"[BB]^1 You can't withdraw more than you currently have banked.");
    }

    
ColorChat(idGREEN"Test: szAmount = %i"iAmount);
}

public 
WithdrawAllCash(id) {
    new 
iCash cs_get_user_money(id);
    new 
iCashBuffer;

    if(
iMoney[id] > 0) {
        if(!
get_pcvar_num(pExceedLimit)) {
            
iCashBuffer iMoney[id];
            
iMoney[id] -= iCashBuffer;
            
cs_set_user_money(idiMoney[id] + iCashBuffer);
        }

        else {
            
iCashBuffer MAXCASH iCash;

            if(
iMoney[id] < iCashBuffer) {
                
cs_set_user_money(idiCash iMoney[id]);
                
iMoney[id] -= iMoney[id];
            }
            else {
                
cs_set_user_money(idiCash iCashBuffer);
                
iMoney[id] -= iCashBuffer;
            }
        }
    }
}

public 
DepositMessageModeHandler(id) {
    new 
szAmount[10], iAmountiCash;
    
read_argv(1szAmountcharsmax(szAmount));

    
iAmount str_to_num(szAmount);
    
iCash cs_get_user_money(id);

    if(
iAmount 0) {
        if(
iAmount <= iCash) {
            
iMoney[id] += iAmount;
            
cs_set_user_money(idclamp(iCash iAmount0_));
        }

        else {
            
ColorChat(idGREEN"[BB]^1 You don't have that much cash.");
        }
    }

    else {
        
ColorChat(idGREEN"[BB]^1 Specify a minimum of 1$");
    }
}

public 
DepositAllCash(id) {
    new 
iCash cs_get_user_money(id);

    if(
iCash 0) {
        
iMoney[id] += iCash;
        
cs_set_user_money(idiCash iCash);
    }

    else {
        
ColorChat(idGREEN"[BB]^1 You don't have any cash to deposit.");
    }
}

public 
DonateCash(id) {
    new 
iPlayerMenu menu_create("Choose a player to donate to:""DonateHandler");

    new 
iPlayers[MAX_PLAYERS], iNumszName[32], iPlayerszUserId[32];
    
get_players(iPlayersiNum"ch");

    for(new 
iiNumi++) {
        
iPlayer iPlayers[i];
        
get_user_name(iPlayerszNamecharsmax(szName));
        
num_to_str(get_user_userid(iPlayer), szUserIdcharsmax(szUserId));
        
menu_additem(iPlayerMenuszNameszUserId);
    }
    
menu_display(idiPlayerMenu);
}

public 
DonateHandler(idiPlayerMenuiItem) {
    if(
iItem != MENU_EXIT) {
        new 
iAccessiCallBack;
        
menu_item_getinfo(iPlayerMenuiItemiAccessszTargetIdcharsmax(szTargetId), __iCallBack);

        
client_cmd(id"messagemode EnterAmount");
    }
    
menu_destroy(iPlayerMenu);
}

public 
DonateMessageModeHandler(id) {
    new 
iUserId str_to_num(szTargetId);
    
iDonateTarget[id] = find_player("k"iUserId);

    if(
iDonateTarget[id] && is_user_connected(iDonateTarget[id])) {
        new 
szInput[32], iAmount;
        
read_argv(1szInputcharsmax(szInput));

        
iAmount str_to_num(szInput);

        if(
iAmount <= iMoney[id]) {
            
iMoney[id] -= iAmount;
            
iMoney[iDonateTarget[id]] += iAmount;

            new 
szName[32], szNameReceiver[32];
            
get_user_name(idszNamecharsmax(szName));
            
get_user_name(iDonateTarget[id], szNameReceivercharsmax(szNameReceiver));

            
ColorChat(idGREEN"[BB]^3 %s^1 donated^4 %i$^1 to^3 %s."szNameiAmountszNameReceiver);
        }

        else {
            
ColorChat(idGREEN"[BB]^1 You don't have enough funds on your bank.");
        }
    }

    else {
        
ColorChat(idGREEN"[BB]^1 Invalid target.");
    }

Thanks for your time, But why you made register account section for register system plugin , i think it must have registered account system for bank only not for server to be better, understand me ?
Supremache is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-01-2020 , 19:15   Re: [Request] Change Ammo Bank To Money Bank
Reply With Quote #17

Quote:
Originally Posted by Supremache View Post
Thanks for your time, But why you made register account section for register system plugin , i think it must have registered account system for bank only not for server to be better, understand me ?
I can remove /register if u want...
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-01-2020 , 19:29   Re: [Request] Change Ammo Bank To Money Bank
Reply With Quote #18

Quote:
Originally Posted by Napoleon_be View Post
I can remove /register if u want...
I Can do it but , if you have idea for make register account for bank only this plugin will be better
Supremache is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-01-2020 , 20:30   Re: [Request] Change Ammo Bank To Money Bank
Reply With Quote #19

Quote:
Originally Posted by Supremache View Post
I Can do it but , if you have idea for make register account for bank only this plugin will be better
Why do u want a "register system" when this plugin already registers data by steamid?
FYI: I don't support non-steam servers if that's what you're going to.
__________________

Last edited by Napoleon_be; 05-01-2020 at 20:37.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-01-2020 , 23:38   Re: [Request] Change Ammo Bank To Money Bank
Reply With Quote #20

Quote:
Originally Posted by Napoleon_be View Post
Why do u want a "register system" when this plugin already registers data by steamid?
FYI: I don't support non-steam servers if that's what you're going to.
I didn't mean that, I was mean if you can make resgster account data for cmd "/Regester" in this bank plagin, do u understand like when I press on manage ur account I got something like
"Bank account"
1. Username:
2. Password:
Regester account for bank only....
Ps: I using steam server
Last question : can u make cvar for this plugin to clean all bank data. "all moneys in the bank"

Last edited by Supremache; 05-01-2020 at 23:52.
Supremache is offline
Reply


Thread Tools
Display Modes

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 04:16.


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