View Single Post
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 09-10-2020 , 22:10   Re: Money System [Bank | Donate | Give | Take | Time presents]
Reply With Quote #16

Quote:
Originally Posted by Bugsy View Post
Did you test this plugin before releasing? Here's a few things after taking a quick look.

In the below code, ThreeMinutes would not fire for bots or hltv, but Five,Ten,Fifteen, and Twenty would. You need brackets around the code if the code under the if-condition is more than 1 line. In this case, only Three minutes would not fire for bots/hltv but everything else would.
Code:
public client_putinserver( id ) {     if (!is_user_bot(id) && !is_user_hltv(id)) // not in-game or fake     set_task(180.0, "ThreeMinutes", id)  // 3 min     set_task(300.0, "FiveMinutes", id) // 5 min     set_task(600.0, "TenMinutes", id) // 10 min     set_task(900.0, "FifteenMinutes", id) // 15 min     set_task(1200.0, "TwentyMinutes", id) // 20 min }

I would create a global variable to store each players steam ID, retrieve it before calling load. This will eliminate re-calling it throughout the plugin. I would not do this for name since a player can change their name.
Code:
public client_authorized(id) {     LoadData(id); }

How can a disconnected player select a menu item?
Code:
public BankHandler(id, iBankMenu, iItem) {
    if(is_user_connected(id) && iItem != MENU_EXIT)

get_players() only retrieves connected players, no need to check if connected. I'd also add flags to get_players() to exclude bots and hltv.
Code:
        for(new i; i < pnum; i++)         {             tempid = players[i]
            if(is_user_connected(tempid) && !is_user_bot(tempid))

Use num_to_str()
Code:
public SaveData(id) {     new szAuth[35], szTemp[10];     get_user_authid(id, szAuth, charsmax(szAuth));
    formatex(szTemp, charsmax(szTemp), "%i", iMoney[id]);

When the value in the vault record is an integer, you can set the value by doing: var[id] = nvault_get().
Code:
public LoadData(id) {     new szAuth[35], szMoney[10], szTemp[10];     get_user_authid(id, szAuth, charsmax(szAuth));
    nvault_get(iVault, szAuth, szTemp, charsmax(szTemp));
    parse(szTemp, szMoney, charsmax(szMoney));
    iMoney[id] = str_to_num(szMoney);

I'd consider moving all or some of these to cvars so the end-user doesn't need to re-compile if they want to change something.
Code:
#define FLAGS_GIVE ADMIN_KICK       // Flag give money
#define FLAGS_TAKE ADMIN_KICK       // Flag take money
#define FLAGS_RESET_BANK ADMIN_RCON       // Flag reset bank
#define MAXCASH 16000       // Max money to Deposit/Withdraw
#define MAXBANKCASH 9999999999       // Max money can bank Save/Deposit

// Time presents
#define THREE_MINUTES 1000 // 3 min 1000$
#define FIVE_MINUTES 2000 // 5 min 2000$
#define TEN_MINUTES 3000 // 10 min 3000$
#define FIVTEEN_MINUTES 4000 // 15 min 4000$
#define TWENTY_MINUTES 5000 // 20 min 5000$


1. I already tested this plugin on three servers and they owners and players didn't said there's any bugs on it.
2. I understand some things and there's some things i didn't understand.

1. I didn't understand what is the bug will happen with on task "three minute" .
2. I will edit it and creat steam id and name on global var.
3. I edit get_player to show all player connected and disconnected but why you Want to add flag for it and i can exclude bots and hltv without adding flag.
4. I will do another style for save and load data.
5. i will change all defines to cvar just i will leave flags.

Last edited by Supremache; 09-10-2020 at 22:13.
Supremache is offline