AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   Knife Bounty + Secure (v1.5) (https://forums.alliedmods.net/showthread.php?t=294896)

edon1337 03-10-2017 16:55

Knife Bounty + Secure (v1.5)
 
2 Attachment(s)
.: Knife Bounty + Secure v1.5 :.

.: Description :.

When you knife a person, you will take his money (If not secured), if he is secured, you won't be able to take his money. To secure your money type /secure , it will cost you some money (Controlled by CVAR). Secure will last until Death/ New Spawn.

.: CVARs :.
Quote:

knife_bounty_enabled 1 // Plugin enabled <0|1> - <OFF|ON>
knife_bounty_secure 1 // Secure enabled <0|1> - <OFF|ON>
knife_bounty_secure_price 1200 // Secure price
.: Changelog :.
Spoiler


.: Requirements :.
Spoiler


.: Credits :.
Spoiler

edon1337 03-10-2017 16:55

Re: Knife Bounty + Secure
 
Could Someone Please Translate To Their Language , Thanks. :)
Quote:

[en]

VICTIM_SECURED = [Knife Bounty] Victim Was Secured !
VICTIM_DIDNT_LOSE = [Knife Bounty] You Didn't Lose Your Money Because You Was Secured !
VICTIM_MONEY_LOW = [Knife Bounty] Victim's Money Was Low, You Won Nothing !
ATTACKER_BOUNTY = [Knife Bounty] You've Taken %s 's Bounty Of $%d !
VICTIM_LOST_MONEY = [Knife Bounty] %s Has Taken Your Bounty Of $%d !
SECURE_AD = [Knife Bounty] To Secure Your Money Type /secure !
CANT_SECURE_DEAD = [Knife Bounty] You Can't Secure While Dead !
SECURE_DISABLED = [Knife Bounty] Securing Is Currently Disabled !
NOT_ENOUGH_MONEY = [Knife Bounty] Not Enough Money To Secure !
SECURED_MONEY = [Knife Bounty] You Paid $%d To Secure Your Money, You Won't Lose Your Money If You Get Knifed !

Godofwar 03-10-2017 17:18

Re: Knife Bounty + Secure
 
[de]

Code:

VICTIM_SECURED = [Knife Bounty] Opfer wurde gesichert!
VICTIM_DIDNT_LOSE = [Knife Bounty] Du hast dein Geld nicht verloren, weil du gesichert bist!
VICTIM_MONEY_LOW = [Knife Bounty] Das Geld des Opfers war zu niedrig, du hast nichts gewonnen!
ATTACKER_BOUNTY = [Knife Bounty] Du hast das Kopfgeld %s 'von  $%d genommen !
VICTIM_LOST_MONEY = [Knife Bounty] %s hat das Kopfgeld von $%d genommen !
SECURE_AD = [Knife Bounty] Um dein Geld zu sichern benutze /secure !
CANT_SECURE_DEAD = [Knife Bounty] Du kannst dein Geld nicht sichern wenn du nicht tot bist !
SECURE_DISABLED = [Knife Bounty] Das Sichern ist derzeit nicht möglich !
NOT_ENOUGH_MONEY = [Knife Bounty] Du hast nicht genug Geld um es zu sichern !
SECURED_MONEY = [Knife Bounty] Du hast $%d gezahlt um dein Geld zu sichern. Du wirst dein Geld nicht verlieren wenn du gemessert wirst.

:-)

edon1337 03-10-2017 17:28

Re: Knife Bounty + Secure
 
Quote:

Originally Posted by Godofwar (Post 2502504)
[de]

Code:

VICTIM_SECURED = [Knife Bounty] Opfer wurde gesichert!
VICTIM_DIDNT_LOSE = [Knife Bounty] Du hast dein Geld nicht verloren, weil du gesichert bist!
VICTIM_MONEY_LOW = [Knife Bounty] Das Geld des Opfers war zu niedrig, du hast nichts gewonnen!
ATTACKER_BOUNTY = [Knife Bounty] Du hast das Kopfgeld %s 'von  $%d genommen !
VICTIM_LOST_MONEY = [Knife Bounty] %s hat das Kopfgeld von $%d genommen !
SECURE_AD = [Knife Bounty] Um dein Geld zu sichern benutze /secure !
CANT_SECURE_DEAD = [Knife Bounty] Du kannst dein Geld nicht sichern wenn du nicht tot bist !
SECURE_DISABLED = [Knife Bounty] Das Sichern ist derzeit nicht möglich !
NOT_ENOUGH_MONEY = [Knife Bounty] Du hast nicht genug Geld um es zu sichern !
SECURED_MONEY = [Knife Bounty] Du hast $%d gezahlt um dein Geld zu sichern. Du wirst dein Geld nicht verlieren wenn du gemessert wirst.

:-)

Thanks, Credits added :)

F0RCE 03-10-2017 21:01

Re: Knife Bounty + Secure
 
Code:

[pl]
VICTIM_SECURED = [Knife Bounty] Ofiara byla ubezpieczona !
VICTIM_DIDNT_LOSE = [Knife Bounty] Nie straciles pieniedzy poniewaz byles ubezpieczony !
VICTIM_MONEY_LOW = [Knife Bounty] Ofiara miala niewystarczajaca ilosc pieniedzy. Nic nie dostales !
ATTACKER_BOUNTY = [Knife Bounty] Zabrales %s nagrody graczowi $%d !
VICTIM_LOST_MONEY = [Knife Bounty] %s zabral Ci $%d pieniedzy !
SECURE_AD = [Knife Bounty] Aby ubezpieczyc swoje pieniadze wpisz /secure !
CANT_SECURE_DEAD = [Knife Bounty] Nie mozesz ubezpieczyc pieniedzy kiedy nie zjesz  !
SECURE_DISABLED = [Knife Bounty] Ubezpieczenie pieniedzy jest aktualnie wylaczone !
NOT_ENOUGH_MONEY = [Knife Bounty] Niewystarczajaca ilosc pieniedzy do ubezpieczenia !
SECURED_MONEY = [Knife Bounty] Zaplaciles $%d kaucji aby zabezpieczyc swoje pieniadze. Nie stracisz ich jezeli zostaniesz zabity z noza !


HamletEagle 03-11-2017 02:32

Re: Knife Bounty + Secure
 
LANG_PLAYER should be used only when you print to all players at the same time. When you print to a specific player, use player id instead.
Use charsmax().

edon1337 03-11-2017 05:30

Re: Knife Bounty + Secure
 
Quote:

Originally Posted by HamletEagle (Post 2502573)
LANG_PLAYER should be used only when you print to all players at the same time. When you print to a specific player, use player id instead.
Use charsmax().

Done. Should I remove the bool g_HasSafety and use bits?

Quote:

Originally Posted by F0RCE (Post 2502541)
Code:

[pl]
VICTIM_SECURED = [Knife Bounty] Ofiara byla ubezpieczona !
VICTIM_DIDNT_LOSE = [Knife Bounty] Nie straciles pieniedzy poniewaz byles ubezpieczony !
VICTIM_MONEY_LOW = [Knife Bounty] Ofiara miala niewystarczajaca ilosc pieniedzy. Nic nie dostales !
ATTACKER_BOUNTY = [Knife Bounty] Zabrales %s nagrody graczowi $%d !
VICTIM_LOST_MONEY = [Knife Bounty] %s zabral Ci $%d pieniedzy !
SECURE_AD = [Knife Bounty] Aby ubezpieczyc swoje pieniadze wpisz /secure !
CANT_SECURE_DEAD = [Knife Bounty] Nie mozesz ubezpieczyc pieniedzy kiedy nie zjesz  !
SECURE_DISABLED = [Knife Bounty] Ubezpieczenie pieniedzy jest aktualnie wylaczone !
NOT_ENOUGH_MONEY = [Knife Bounty] Niewystarczajaca ilosc pieniedzy do ubezpieczenia !
SECURED_MONEY = [Knife Bounty] Zaplaciles $%d kaucji aby zabezpieczyc swoje pieniadze. Nie stracisz ich jezeli zostaniesz zabity z noza !


Thanks, Credits Added.

HamletEagle 03-11-2017 07:26

Re: Knife Bounty + Secure (v1.1)
 
Not really, I would say to keep your code simple when you are a beginner. Bits are fine, but the bool is fine too and the difference is trivial.

edon1337 03-11-2017 08:13

Re: Knife Bounty + Secure (v1.1)
 
Quote:

Originally Posted by HamletEagle (Post 2502624)
Not really, I would say to keep your code simple when you are a beginner. Bits are fine, but the bool is fine too and the difference is trivial.

Okay, thanks. :) Should I add
Code:
public client_putinserver( id ) g_HasSafety[ id ] = false ;

HamletEagle 03-11-2017 09:13

Re: Knife Bounty + Secure (v1.1)
 
Yes. Because if x has the bool set to true, x disconnects, y connects and y gets the id of x then the bool will be true for him.

OciXCrom 03-11-2017 09:25

Re: Knife Bounty + Secure (v1.1)
 
Code:

[mk]
VICTIM_SECURED = [Knife Bounty] Zhrtvata beshe osigurana !
VICTIM_DIDNT_LOSE = [Knife Bounty] Ne gi zagubi parite zatoa shto beshe osiguran !
VICTIM_MONEY_LOW = [Knife Bounty] Zhrtvata imashe malku pari. Ne dobi nishto od nego !
ATTACKER_BOUNTY = [Knife Bounty] Zema nagradata na %s od $%d !
VICTIM_LOST_MONEY = [Knife Bounty] %s ja zema tvojata nagrada od $%d !
SECURE_AD = [Knife Bounty] Za da gi osigurash tvoite pari, napishi /secure !
CANT_SECURE_DEAD = [Knife Bounty] Ne mozesh da se osigurash dodeka si mrtov !
SECURE_DISABLED = [Knife Bounty] Osiguruvanjeto momentalno e isklucheno !
NOT_ENOUGH_MONEY = [Knife Bounty] Nemash dovolno pari za osiguruvanje !
SECURED_MONEY = [Knife Bounty] Plati $%d za osigiruvanje na parite i istite nema da gi izgubish ako te zakolat !


edon1337 03-11-2017 10:14

Re: Knife Bounty + Secure (v1.1)
 
Quote:

Originally Posted by OciXCrom (Post 2502677)
Code:

[mk]
VICTIM_SECURED = [Knife Bounty] Zhrtvata beshe osigurana !
VICTIM_DIDNT_LOSE = [Knife Bounty] Ne gi zagubi parite zatoa shto beshe osiguran !
VICTIM_MONEY_LOW = [Knife Bounty] Zhrtvata imashe malku pari. Ne dobi nishto od nego !
ATTACKER_BOUNTY = [Knife Bounty] Zema nagradata na %s od $%d !
VICTIM_LOST_MONEY = [Knife Bounty] %s ja zema tvojata nagrada od $%d !
SECURE_AD = [Knife Bounty] Za da gi osigurash tvoite pari, napishi /secure !
CANT_SECURE_DEAD = [Knife Bounty] Ne mozesh da se osigurash dodeka si mrtov !
SECURE_DISABLED = [Knife Bounty] Osiguruvanjeto momentalno e isklucheno !
NOT_ENOUGH_MONEY = [Knife Bounty] Nemash dovolno pari za osiguruvanje !
SECURED_MONEY = [Knife Bounty] Plati $%d za osigiruvanje na parite i istite nema da gi izgubish ako te zakolat !


Thanks, Credits added.

Quote:

Originally Posted by HamletEagle (Post 2502671)
Yes. Because if x has the bool set to true, x disconnects, y connects and y gets the id of x then the bool will be true for him.

Done. Thanks :)

addons_zz 03-11-2017 18:51

Re: Knife Bounty + Secure (v1.2)
 
Brazilian Portuguese
Code:

[bp]
VICTIM_SECURED = [Olha-a-Faca] A Vitima tinha seguro contra facadas!
VICTIM_DIDNT_LOSE = [Olha-a-Faca] Voce nao perdeu o seu dinheiro por que tinha seguro contra facadas!
VICTIM_MONEY_LOW = [Olha-a-Faca] A vitima estava durinha da silva. Voce nao ganhou nenhum dinheiro extra!
ATTACKER_BOUNTY = [Olha-a-Faca] Voce pegou de %s a recompensa de $%d!
VICTIM_LOST_MONEY = [Olha-a-Faca] %s pegou sua recompensa de $%d!
SECURE_AD = [Olha-a-Faca] Para proteger seu dinheiro contra esfaqueadores, digite /secure
CANT_SECURE_DEAD = [Olha-a-Faca] Voce nao pode comprar um seguro quando esta morto!
SECURE_DISABLED = [Olha-a-Faca] A venda de seguros estah desativada!
NOT_ENOUGH_MONEY = [Olha-a-Faca] Voce estah muito duro para comprar um seguro!
SECURED_MONEY = [Olha-a-Faca] Voce pagou $%d para proteger o seu dinheiro. Esfaqueadores nao poderao pegar seu dinheiro!


edon1337 03-12-2017 05:17

Re: Knife Bounty + Secure (v1.2)
 
Quote:

Originally Posted by addons_zz (Post 2502830)
Brazilian Portuguese
Code:

[bp]
VICTIM_SECURED = [Olha-a-Faca] A Vitima tinha seguro contra facadas!
VICTIM_DIDNT_LOSE = [Olha-a-Faca] Voce nao perdeu o seu dinheiro por que tinha seguro contra facadas!
VICTIM_MONEY_LOW = [Olha-a-Faca] A vitima estava durinha da silva. Voce nao ganhou nenhum dinheiro extra!
ATTACKER_BOUNTY = [Olha-a-Faca] Voce pegou de %s a recompensa de $%d!
VICTIM_LOST_MONEY = [Olha-a-Faca] %s pegou sua recompensa de $%d!
SECURE_AD = [Olha-a-Faca] Para proteger seu dinheiro contra esfaqueadores, digite /secure
CANT_SECURE_DEAD = [Olha-a-Faca] Voce nao pode comprar um seguro quando esta morto!
SECURE_DISABLED = [Olha-a-Faca] A venda de seguros estah desativada!
NOT_ENOUGH_MONEY = [Olha-a-Faca] Voce estah muito duro para comprar um seguro!
SECURED_MONEY = [Olha-a-Faca] Voce pagou $%d para proteger o seu dinheiro. Esfaqueadores nao poderao pegar seu dinheiro!


Thanks, credits added, I replaced Olha-a-Face with Knife Bounty just like in the rest of translations :)

OciXCrom 03-12-2017 10:26

Re: Knife Bounty + Secure (v1.2)
 
Why? It's a translation, so why change it?

edon1337 03-12-2017 10:40

Re: Knife Bounty + Secure (v1.2)
 
Quote:

Originally Posted by OciXCrom (Post 2503014)
Why? It's a translation, so why change it?

It changes the identity of the plugin.

FR0NTLINE 03-18-2017 17:16

Re: Knife Bounty + Secure (v1.2)
 
gr8 idea i haven't seen anything like this made yet. good work.

Visinescu 03-18-2017 21:28

Re: Knife Bounty + Secure (v1.2)
 
Romanian
Code:

[ro]

VICTIM_SECURED = [Knife Bounty] Victima a fost Securizata !
VICTIM_DIDNT_LOSE = [Knife Bounty] Nu ai pierdut banii deoarece ai fost Securizat !
VICTIM_MONEY_LOW = [Knife Bounty] Banii victimei erau scazuti, Nu ai castigat nimic !
ATTACKER_BOUNTY = [Knife Bounty] Ai luat Recomenpsa lui %s de $%d !
VICTIM_LOST_MONEY = [Knife Bounty] %s Ti-a luat Recompensa de $%d !
SECURE_AD = [Knife Bounty] Sa-ti securizezi banii scrie /secure !
CANT_SECURE_DEAD = [Knife Bounty] Nu poti sa te securizezi in timp ce esti mort !
SECURE_DISABLED = [Knife Bounty] Securitatea este momentan oprita !
NOT_ENOUGH_MONEY = [Knife Bounty] Nu ai destui bani sa te securizezi !
SECURED_MONEY = [Knife Bounty] Ai platit $%d sa-ti securizezi banii, Nu-ti vei pierde banii daca esti injunghiat !


HamletEagle 03-19-2017 05:38

Re: Knife Bounty + Secure (v1.2)
 
PHP Code:

if( ! get_pcvar_numg_iCvars] ) ) 
    return 
HAM_IGNORED ;
    
    if( ! ( 
is_valid_connectedattacker ) || is_valid_connectedvictim ) ) )
    return 
HAM_IGNORED ;
    
    if( 
get_user_weaponattacker ) != CSW_KNIFE 
    return 
HAM_IGNORED ;

    if( 
attacker == victim )
    return 
HAM_IGNORED 

Indent your code properly. It's nice to always use { } , even for single line, but that's only my opinion. Do it how you want, but indent properly.

PHP Code:

if( attacker == victim )
return 
HAM_IGNORED 

This check looks reduntant. You can't kill yourself with the knife.

I would add a is_user_connected check in client_putinserver.

PHP Code:

if( ! ( get_pcvar_numg_iCvars] ) ) ) 

Way too many spaces. Without extra spaces code looks better and it's easier to read:
PHP Code:

if(!get_pcvar_num(g_iCvars[1])) 

Also notice that the ( after ! is not needed.

edon1337 03-19-2017 08:44

Re: Knife Bounty + Secure (v1.2)
 
Quote:

Originally Posted by HamletEagle (Post 2504760)
Indent your code properly. It's nice to always use { } , even for single line, but that's only my opinion. Do it how you want, but indent properly.

It's already indented?

Quote:

Originally Posted by HamletEagle (Post 2504760)
PHP Code:

if( ! ( get_pcvar_numg_iCvars] ) ) ) 

Way too many spaces. Without extra spaces code looks better and it's easier to read:
PHP Code:

if(!get_pcvar_num(g_iCvars[1])) 

Also notice that the ( after ! is not needed.

It's a style of coding, I removed the extra '('.

Quote:

Originally Posted by HamletEagle (Post 2504760)
[php]
I would add a is_user_connected check in client_putinserver.

Done.

Quote:

Originally Posted by HamletEagle (Post 2504760)
PHP Code:

if( attacker == victim )
return 
HAM_IGNORED 

This check looks reduntant. You can't kill yourself with the knife.

Somehow, I forgot to upload the version without that check, no idea how but I didn't have that in my latest version in desktop.

Thanks!

@Visinescu

Thanks, credits added.

DJEarthQuake 09-18-2018 10:44

Re: Knife Bounty + Secure (v1.3)
 
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.

HamletEagle 09-18-2018 12:22

Re: Knife Bounty + Secure (v1.3)
 
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.

edon1337 09-18-2018 12:40

Re: Knife Bounty + Secure (v1.3)
 
Quote:

Originally Posted by HamletEagle (Post 2615720)
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 (Post 2615720)
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.

HamletEagle 09-18-2018 12:44

Re: Knife Bounty + Secure (v1.4)
 
https://en.wikipedia.org/wiki/De_Morgan%27s_laws
! also negates the operator !(a && b) is !a || !b and !(a || b) is !a && !b.

edon1337 09-18-2018 12:46

Re: Knife Bounty + Secure (v1.4)
 
Quote:

Originally Posted by HamletEagle (Post 2615728)
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.

HamletEagle 09-18-2018 12:54

Re: Knife Bounty + Secure (v1.4)
 
Quote:

Originally Posted by edon1337 (Post 2615729)
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


edon1337 09-18-2018 13:13

Re: Knife Bounty + Secure (v1.4)
 
Quote:

Originally Posted by HamletEagle (Post 2615733)
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.

HamletEagle 09-18-2018 13:37

Re: Knife Bounty + Secure (v1.5)
 
Seems good.

edon1337 09-18-2018 16:36

Re: Knife Bounty + Secure (v1.5)
 
Quote:

Originally Posted by HamletEagle (Post 2615740)
Seems good.

Thanks for the review and approval.

DON KHAN 1 08-12-2020 14:52

Re: Knife Bounty + Secure (v1.5)
 
can anyone set that if any player kill other player so it dont take all money.
it just take 25%.

Sorry for bad English


All times are GMT -4. The time now is 07:32.

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