Raised This Month: $70 Target: $400
 17% 

Money System [Bank | Donate | Give | Take | Time presents]


Post New Thread Reply   
 
Thread Tools Display Modes
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 09-09-2020 , 01:17   Re: Money System [Donate | Give | Take]
Reply With Quote #11

https://forums.alliedmods.net/showthread.php?t=9720
__________________
+ARUKARI- is offline
Supremache
BANNED
Join Date: Sep 2019
Location: Egypt
Old 09-09-2020 , 20:00   Re: Money System [Donate | Give | Take]
Reply With Quote #12

Quote:
Originally Posted by iceeedr View Post
At no time did I say otherwise, I just left a version for amx 1.9 in case anyone wants to, if you want I delete it.
Why not, Leave it that's make me happy

New Updates v1.1
Code:
— Version: 1.1 New Updates (September, 09,2020 )
			Fixed some codes
			Added bank system
			Added doante money from bank to bank

Last edited by Supremache; 09-09-2020 at 20:19.
Supremache is offline
Supremache
BANNED
Join Date: Sep 2019
Location: Egypt
Old 09-10-2020 , 10:14   Re: Money System [Bank | Donate | Give | Take]
Reply With Quote #13

New Updates: v1.2

Code:
		 Version: 1.2 New Updates (September, 10,2020 )
			Added time presents
Supremache is offline
Supremache
BANNED
Join Date: Sep 2019
Location: Egypt
Old 09-10-2020 , 16:17   Re: Money System [Bank | Donate | Give | Take | Time presents]
Reply With Quote #14

New Updates:
Code:
 Version: 1.3 New Updates (September, 10,2020 )
			Edited Codes to use native native plugins in place of money,
			You can make this plugin work with Ammo Packs, BaseBuilder Credits, JBPacks and others
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-10-2020 , 20:25   Re: Money System [Bank | Donate | Give | Take | Time presents]
Reply With Quote #15

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$
__________________

Last edited by Bugsy; 09-10-2020 at 20:35.
Bugsy is offline
Supremache
BANNED
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
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-10-2020 , 22:19   Re: Money System [Bank | Donate | Give | Take | Time presents]
Reply With Quote #17

1. This is because the issue only impacts bots--it's an efficiency item to not waste calling natives on bots which will never use your money commands. Just add the brackets around the set_task()'s, simple fix.
2. Good
3. Again, get_players() fills the array with only CONNECTED player id's, so you do not need to use is_user_connected(). It's more efficient to add the "ch" flags which automatically excludes bots and hltv, so you can avoid calling is_user_bot() and is_user_hltv() multiple times.
__________________
Bugsy is offline
Supremache
BANNED
Join Date: Sep 2019
Location: Egypt
Old 09-10-2020 , 22:38   Re: Money System [Bank | Donate | Give | Take | Time presents]
Reply With Quote #18

Quote:
Originally Posted by Bugsy View Post
1. This is because the issue only impacts bots--it's an efficiency item to not waste calling natives on bots which will never use your money commands. Just add the brackets around the set_task()'s, simple fix.
2. Good
3. Again, get_players() fills the array with only CONNECTED player id's, so you do not need to use is_user_connected(). It's more efficient to add the "ch" flags which automatically excludes bots and hltv, so you can avoid calling is_user_bot() and is_user_hltv() multiple times.
Okay thanks for your explain i will fix set_task's and do what you said
Supremache is offline
Supremache
BANNED
Join Date: Sep 2019
Location: Egypt
Old 09-14-2020 , 14:30   Re: Money System [Bank | Donate | Give | Take | Time presents]
Reply With Quote #19

New Updates: v1.4
Code:
 Version: 1.4 New Updates (September, 14,2020 )
			Fixed Some codes
			Added Lang file
			Added CFG file
			Transformed define's to cvar's
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-14-2020 , 20:08   Re: Money System [Bank | Donate | Give | Take | Time presents]
Reply With Quote #20

Right now the plugin is pretty much useless since only one player can use it at a time due to your steam ID logic. At your skill level you need to thoroughly test a plugin and be confident it works before posting it for others to use.

Just use #define MAX_PLAYERS 32 , there is no need to first check if its defined doing it this way.
Code:
#if !defined MAX_PLAYERS     const MAX_PLAYERS = 32; #endif
Global variables meant for each player to have a slot in the array should be sized using MAX_PLAYERS + 1. Currently, each time a player connects, his steam id overwrites the last player that connected.
Code:
new szPlayerAuthid[32], szPlayerName[32], //This should be defined as : new szPlayerAuthid[ MAX_PLAYERS + 1 ][32] //Then get_user_authid( id, szPlayerAuthid[ id ] , charsmax(szPlayerAuthid[]))
Why are you getting the same players auth id twice?
Code:
public client_authorized(id) {     get_user_name( id, szPlayerName, charsmax(szPlayerName))
    get_user_authid( id, szPlayerAuthid, charsmax(szPlayerAuthid))
    get_user_authid(id, szAuthID, charsmax(szAuthID));
A disconnected player cannot execute a menu, no need to check if connected
Code:
public BankHandler(id, iBankMenu, iItem) {     if(is_user_connected(id) && iItem != MENU_EXIT)     {
__________________
Bugsy 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 14:13.


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