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

Knife Bounty + Secure (v1.5)


Post New Thread Reply   
 
Thread Tools Display Modes
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 09-18-2018 , 10:44   Re: Knife Bounty + Secure (v1.3)
Reply With Quote #21

I will test this as I have been lost without the bank/wire your friends or enemy's money plugin from yesteryears and love knifing. Secure is great idea.
DJEarthQuake is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-18-2018 , 12:22   Re: Knife Bounty + Secure (v1.3)
Reply With Quote #22

For approval:

1.Even if the style is subjective, I would recommend you to use braces even when the block has only one instruction:
PHP Code:
for ( new isizeof g_sCommandListi++ )
    
register_clcmdg_sCommandList], "SecurePlayer" ) ; 
For example in my text editor(NP ++) this looks unindented(register_clcmd and for have the same level of indentation).

2.Instead of:
PHP Code:
#define is_valid_connected(%0) ( 1 <= %0 <= g_iMaxPlayers ) 
is_user_connected can be used directly.

3."if( VictimMoney == EMPTY )" EMPTY is badly named. You are checking a variable(not some kind of container), which can't be empty. Probably a better name would be NO_MONEY or ZERO_MONEY.

4.In fw_HamSpawnPost there's a potential logic error.
PHP Code:
if( ! ( get_pcvar_numg_iCvars] ) || get_pcvar_numg_iCvars] ) ) ) 
This translated to !get_pcvar_num(g_iCvars[0]) && !get_pcvar_num(g_iCvars[1]). What this means is that you stop the code from being executed only if the plugin is disabled AND players can't secure their money.
In the case the plugin is enabled but knife_bounty_secure is 0 or the plugin is disabled but knife_bount_secure is 1 then the code will still execute.
You probably meant to do an OR instead of AND.
__________________

Last edited by HamletEagle; 09-18-2018 at 12:24.
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 09-18-2018 , 12:40   Re: Knife Bounty + Secure (v1.3)
Reply With Quote #23

Quote:
Originally Posted by HamletEagle View Post
For approval:

1.Even if the style is subjective, I would recommend you to use braces even when the block has only one instruction:
PHP Code:
for ( new isizeof g_sCommandListi++ )
    
register_clcmdg_sCommandList], "SecurePlayer" ) ; 
For example in my text editor(NP ++) this looks unindented(register_clcmd and for have the same level of indentation).
I don't know why Notepad can't indent blocks of codes which don't have brackets, but that looks proper too, anyways I added brackets.

Quote:
Originally Posted by HamletEagle View Post
4.In fw_HamSpawnPost there's a potential logic error.
PHP Code:
if( ! ( get_pcvar_numg_iCvars] ) || get_pcvar_numg_iCvars] ) ) ) 
This translated to !get_pcvar_num(g_iCvars[0]) && !get_pcvar_num(g_iCvars[1]). What this means is that you stop the code from being executed only if the plugin is disabled AND players can't secure their money.
In the case the plugin is enabled but knife_bounty_secure is 0 or the plugin is disabled but knife_bount_secure is 1 then the code will still execute.
You probably meant to do an OR instead of AND.
I don't see any && here? What I meant to do is disable further execution if either the plugin is disabled or money securing is disabled, anyways I updated it to be separately.

And the rest are done.
__________________

Last edited by edon1337; 09-18-2018 at 12:41.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-18-2018 , 12:44   Re: Knife Bounty + Secure (v1.4)
Reply With Quote #24

https://en.wikipedia.org/wiki/De_Morgan%27s_laws
! also negates the operator !(a && b) is !a || !b and !(a || b) is !a && !b.
__________________

Last edited by HamletEagle; 09-18-2018 at 12:44.
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 09-18-2018 , 12:46   Re: Knife Bounty + Secure (v1.4)
Reply With Quote #25

Quote:
Originally Posted by HamletEagle View Post
https://en.wikipedia.org/wiki/De_Morgan%27s_laws
! also negates the operator !(a && b) is !a || !b and !(a || b) is !a && !b.
Oh, yep, you're right, forgot about the operators being negated, didn't even know that was a thing in Pawn.
__________________
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-18-2018 , 12:54   Re: Knife Bounty + Secure (v1.4)
Reply With Quote #26

Quote:
Originally Posted by edon1337 View Post
Oh, yep, you're right, forgot about the operators being negated, didn't even know that was a thing in Pawn.
It's a thing everywhere.

About braces, you need to be consistent. I still see single instruction blocks without them.

I didn't notice before, but the same logic issue is present here:
PHP Code:
    if( ! ( is_user_connectediAttacker ) || is_user_connectediVictim ) ) )
    return 
HAM_IGNORED
There's still an error in fw_HamSpawnPost.
Let's assume the plugin is turned on and players can secure their money. Someone secures his money and he doesn't die that round, so he still has g_bHasSafety true. Now, at the end of the round knife_bounty_secure is set to 0.
When fw_HamSpawnPost is called the if check will fail, and g_bHasSafety will not reset, meaning player will be able to have his moneys secured for all rounds as long as he doesn't die.

Probably the best layout for this functions is:
Code:
alive check and plugin enabled check
reset g_bHasSafety
knife_bounty_secure check
print SECURE_AD
__________________
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 09-18-2018 , 13:13   Re: Knife Bounty + Secure (v1.4)
Reply With Quote #27

Quote:
Originally Posted by HamletEagle View Post
It's a thing everywhere.

About braces, you need to be consistent. I still see single instruction blocks without them.

I didn't notice before, but the same logic issue is present here:
PHP Code:
    if( ! ( is_user_connectediAttacker ) || is_user_connectediVictim ) ) )
    return 
HAM_IGNORED
There's still an error in fw_HamSpawnPost.
Let's assume the plugin is turned on and players can secure their money. Someone secures his money and he doesn't die that round, so he still has g_bHasSafety true. Now, at the end of the round knife_bounty_secure is set to 0.
When fw_HamSpawnPost is called the if check will fail, and g_bHasSafety will not reset, meaning player will be able to have his moneys secured for all rounds as long as he doesn't die.

Probably the best layout for this functions is:
Code:
alive check and plugin enabled check
reset g_bHasSafety
knife_bounty_secure check
print SECURE_AD
Updated, let me know if there's still something you want me to correct.
__________________
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-18-2018 , 13:37   Re: Knife Bounty + Secure (v1.5)
Reply With Quote #28

Seems good.
__________________
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 09-18-2018 , 16:36   Re: Knife Bounty + Secure (v1.5)
Reply With Quote #29

Quote:
Originally Posted by HamletEagle View Post
Seems good.
Thanks for the review and approval.
__________________

Last edited by edon1337; 09-18-2018 at 16:36.
edon1337 is offline
DON KHAN 1
Senior Member
Join Date: Mar 2019
Location: Pakistan
Old 08-12-2020 , 14:52   Re: Knife Bounty + Secure (v1.5)
Reply With Quote #30

can anyone set that if any player kill other player so it dont take all money.
it just take 25%.

Sorry for bad English
__________________
Facebook
My YouTube
Ro{Y}aL WarLanD CommuniTy
Selling Zombie CSO 4.3 Money System Mod
DON KHAN 1 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 17:54.


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