Raised This Month: $32 Target: $400
 8% 

JailBreak Reasons [JailBreak Reason Menu | JB Reasons]


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Gameplay        Approver:   HamletEagle (36)
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-24-2016 , 09:42   JailBreak Reasons [JailBreak Reason Menu | JB Reasons]
Reply With Quote #1



JailBreak Reasons

Description
  • Since there is no approved version of this plugin in AlliedMods, I decided to make one and post it here. This plugin is meant for JailBreak servers, as stated in the title. When a guard kills a prisoner, the plugin opens up a menu for the guard from which he needs to choose a reason for killing that prisoner. You can set and edit the kill reasons fast and easy, by opening the configuration file. This version of the plugin contains some additional options. The first one is entering a custom reason by pressing the button "t" (spray), and the other one is "denying" the kill with the button "n" (nightvision), which can automatically revive the prisoner if the cvar is enabled.

Cvars
  • jbreasons_custom <default: "1"> -- Enables/Disables the custom reason option.
  • jbreasons_deny <default: "2">
    • "0" = Disables the option to "deny" a kill.
    • "1" = Enables the option, but doesn't revive the prisoner.
    • "2" = Enables the option and automatically revives the killed prisoner.
  • jbreasons_exit <default: "1"> -- If enabled, the guard won't be able to close the menu.

Editing the reasons
  • The kill reasons can be changed from the file configs/JailReasons.ini:

    PHP Code:
    Didn't obey the order
    Entered the gun room
    Lost in the given game
    Attacked a guard
    Weapon/grenade possession
    Prevents command execution
    Regenerates health/armor
    Gets in way of teammates
    Uses map/server bugs 

Images









Languages
  • English: by me (OciXCrom)
  • Macedonian: by me (OciXCrom)
  • Bulgarian: by me (OciXCrom)
  • Serbian: by MihailoZ
  • Romanian: by HamletEagle
  • Dutch: by Napoleon_be
  • Brazil Portuguese: by EFFx
  • Danish: by ImYourBro
  • Italian: by iNdio
  • Spanish: by sirerick
  • Hungarian: by RaZ_HU
  • Slovakian: by Belo95135
  • German: by Godofwar





Last edited by OciXCrom; 07-17-2018 at 09:05. Reason: 08.07.2016 - Added [it] language.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-24-2016 , 11:12   Re: JailBreak Reasons
Reply With Quote #2

1.g_szConfigsName should not be global(it's used only in plugin_init). Since you are reading the file only one time, retrieve configsdir in fileRead and declare the needed vars there.
2.Destroy g_aJailReasons in [tt]plugin_end[tt].
3.I think I told you before, don't put blindly public in front of everything. fileRead should not be public. Really, what's the point in improving current plugin if you don't learn anything and keep doing same mistakes again and again ?
4.In fileRead:
  • Do trim(szData) before checking for comments. If you don't, a space would break your checks.
  • Remove the replace line.
  • iLine is not used.
5.In menuReasons:
  • Cache ArraySize before the loop. You should cache it when you read the file and save it in a global variable.
  • PHP Code:
    formatex(szKeycharsmax(szKey), "%i"i
    ever heard of num_to_str?
6.Check g_cvExit when creating the menu and simply don't add an "Exit" button if it's the case.
7.if(!equal(szArgs, "")) -> if(szArgs != EOS).
8.get_user_msgid and get_maxplayers should be cached.

Again, try to learn something from this stuffs.
__________________
HamletEagle is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-24-2016 , 13:40   Re: JailBreak Reasons
Reply With Quote #3

1. Done.
2. I thought that arrays are destroyed automatically at plugin_end. Done.
3. Don't worry, I remember what you told me, but I guess I missed that one. You can see that I didn't put public in front of all functions this time.
4.1. Done.
4.2. Done.
4.3. Forgot to remove that one from before, since I tried using a different method at the beginning. Done.
5.1. Done.
5.2. Guess I haven't. However, I figured that I don't need szKey at all and removed it completelly.
6. Done.
7. Done.
8. Done.

Thank you again for the help. I'll try to be more careful next time.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-24-2016 , 14:45   Re: JailBreak Reasons
Reply With Quote #4

All handles should be cleaned automatically, but depending on context this may fail. Also, it is considered good practice to free anything you used.

Quote:
You can add up to 32 reasons.
What are you talking about? You are using dynamic arrays so you can add as many entries as you want. That's why they are called "dynamic". So delete this non sense.

PHP Code:
g_aJailReasons ArrayCreate(12832
The "32" from here is not the number of items that array can store. Check API: http://amxmodx.org/api/cellarray/ArrayCreate

Quote:
Pre-allocates space in the array for the specified
number of items. The items are not valid to read or set
until they have actually been pushed into the array.
Initially the "reserved" parameter was intended to create blank entries
that would immediately be usable with Array[Get|Set] functions. This
functionality was never working as intended, and can now be achieved
using ArrayResize().
In eventPlayerKilled, I think there can be issues since you close the menu. If the guard killed a tero and he did not choose an option yet, then he kills another tero, the first kill won't have a reason. Probably, you could assign a default action(via cvar) in case guard fail to select a reason(like auto selection), or maybe punish him? That way, guard will be motivated to answer.
You could also add a timer, if x seconds pass and nothing was selected, do as above.
Well, just some suggestions, you decide how it will be, I never played jailbreak.

Also, make sure iAttacker and iVictim are still connected before retrieving teams..
__________________

Last edited by HamletEagle; 04-24-2016 at 14:48.
HamletEagle is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-25-2016 , 09:30   Re: JailBreak Reasons
Reply With Quote #5

I don't think an option like that is a good idea. There are many cases in which the guard can kill more than one prisoner at a time and doesn't have time to choose a reason. I can't force him to choose one if he's in the middle of a fight. A default reason won't have any effect, since it be incorrect most of the time.

I fixed all the others things. Let me know if there's something else you want me to improve.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
JusTGo
Veteran Member
Join Date: Mar 2013
Old 04-25-2016 , 09:37   Re: JailBreak Reasons
Reply With Quote #6

instead of press "t" and "n" you can make the first and second option in the menu like
1. Choose your costume reason
2. Deny this kill
3. Didn't obey order
...

this is just a suggestion you can keep it this way if you want.
__________________
JusTGo is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-25-2016 , 12:18   Re: JailBreak Reasons
Reply With Quote #7

People are used to having the reasons set up in this order, so it would be rather uncomfortable mixing up the numbers like that. In addition, doing that will shorten the available options on the first page and we all know that not many people will bother going to the second page if there are enough reasons added for more than one page.

Last edited by OciXCrom; 04-25-2016 at 12:20.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
JusTGo
Veteran Member
Join Date: Mar 2013
Old 04-25-2016 , 12:31   Re: JailBreak Reasons
Reply With Quote #8

Quote:
Originally Posted by OciXCrom View Post
People are used to having the reasons set up in this order, so it would be rather uncomfortable mixing up the numbers like that. In addition, doing that will shorten the available options on the first page and we all know that not many people will bother going to the second page if there are enough reasons added for more than one page.
you can also put them at the end of list but thats up to you.
__________________
JusTGo is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-25-2016 , 12:34   Re: JailBreak Reasons
Reply With Quote #9

Fastly checked, updates appears to be in good order. With the hope that I did not overlook something, approved.

Code:
[ro]
TITLE_WHY = \r[Motive JailBreak]^n\yDe ce l-ai omorat pe \r%s\y?\d
TITLE_CUSTOM = ^n\yApasa \r't' \ypentru a introduce alt motiv.\d
TITLE_DENY = ^n\yApasa \r'n' \yto pentru a anula acest kill.\d
MENU_BACK = Pagina anterioara
MENU_NEXT = Pagina urmatoare
MENU_EXIT = Inchide meniul
DENY = !t%s !na anulat moartea lui !t%s !n%L.
REVIVE = astfel a fost reinviat
SORRY = si spune "Imi pare rau"
KILL = !t%s !nl-a omorat pe !t%s!n. Motiv: !g%s
__________________

Last edited by HamletEagle; 04-25-2016 at 12:38.
HamletEagle is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-25-2016 , 13:25   Re: JailBreak Reasons
Reply With Quote #10

Thank you for approving and translating.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Reply



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 03:06.


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