AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Unapproved/Old Plugins (https://forums.alliedmods.net/forumdisplay.php?f=27)
-   -   Ready /snipers menu (https://forums.alliedmods.net/showthread.php?t=240524)

Flick3rR 05-17-2014 08:35

Ready /snipers menu
 
3 Attachment(s)
Intro:
I've listened to many suggestions and requests about a plugin, which to have a menu only with snipers to buy. I didn't find similar one, but if there already is, please excuse me. I think this plugin may be usefull for CSDM or Surf servers, where the owners doesn't want to have free snipers and campers with them everywhere.

Description:
- The menu includes the 4 snipers: AWP, G3SG1, SG552, Scout.
- Each of them can be turned on/off from the menu with cvars. If the sniper is turned off, it gets unclickable and it's name in the menu changes, also the color.
- Snipers' prices can also be changed via cvars.
- I've also added a bonus deagle option, for the fun servers - whoever likes this add, it could be also turned on/off with cvars.
*That bonus deagle option can refer to givin deagle with every sniper and giving deagle by chance with percent, which is also constrolable vie cvar.
- Also included a chat messages prefix, which you can change with cvar.


CVARs:

1. Turning on/off the snipers:
sniper_awp_on
/Turns on/off the AWP/
sniper_g3sg1_on
/Turns on/off the G3SG1/
sniper_sg552_on
/Turns on/off the SG552/
sniper_scout_on
/Turns on/off the Scout/
*All the snipers are turned on by default.
*1 - sniper will appear in the menu.
*0 - sniper won't be in the menu.

2. The prices of the different snipers:
sniper_awp_cost (default: 10000)
/The price of the AWP/
sniper_g3sg1_cost (default: 12000)
/The price of the G3SG1/
sniper_sg552_cost (default: 12000)
/The price of the SG552/
sniper_scout_cost (default: 7000)
/The price of the Scout/

3. And here is the Bonus Deagle cvar:
sniper_deagle_bonus (default: 0)
/If 0, won't give bonus deagle/
/If 1, it will give a bonus deagle with every sniper/
/If 2, it will give a chance to give sniper, which percent of chance you can control with cvar/

sniper_deagle_chance_percent (default: 25)
/This cvar is important only if the cvar above is set to 2/
/That's the percent of chance to give a deagle bonus with the sniper/
/In every different opening of menu, the chance will be checked again/

4. The chat prefix (it will be green):
sniper_message_prefix (default: [Prefix])

And here is another cvar, which defines the main function - the type of giving the sniper, and deagle if defined by cvars.
5. Giving the sniper type:
sniper_give_type (default: 1)
/0 - Only adds the sniper to the other weapon of the player. And now he will have two guns - the previous weapon and the sniper/
/1 - Will strip user primary weapons and give him only a sniper/

Changelog:
Code:

-------------Version 1.1--------------
- Rewrote the whoole code to a brand new level
- Added the bonus deagle chance option
- Renew the cvar getting type
- Renew the main style of menu
- Renew the checks for turning om/off the snipers

Credits:
- @Blizzard_87 - the whole idea and the helpful example of working with enums. Great idea for this method, thanks a lot!


You should compile the plugin localy, because of the includes needed. They are attached in the thread.

Blizzard_87 05-18-2014 08:09

Re: Ready /snipers menu
 
you havent mentioned about having to compile locally due to the include files.

and you should also attach the includes so people don't have to go looking for them...

your code is messy you could clean it up alot to make it more easily readable.

and you shouldnt use get_pcvar_num in your menu function as checking those cvars each time a player opens menu is very inefficient. should cache those cvars in round start then just check those global variables in the menu function.

Code:
public SniperHandler(id, menu, item) {     get_pcvar_string(CvarPrefix, Prefix, 31)
i dont see why you check the prefix string in a function you dont even use it.?

Flick3rR 05-18-2014 08:49

Re: Ready /snipers menu
 
Now, I've made the code little like this, because I wanted it to look compact and not that spreaded. But if it'll be better and more easy readable, I may expand it to look good.
About the string, I've got it in this function, because of the public messages in the lower part of the plugin. Here I get the string, and I use it in the messages below.
About the includes - I'll attach te stripweapons of course, forgot it!

Blizzard_87 05-18-2014 17:47

Re: Ready /snipers menu
 
Quote:

Originally Posted by Flick3rR (Post 2139418)
Now, I've made the code little like this, because I wanted it to look compact and not that spreaded. But if it'll be better and more easy readable, I may expand it to look good.
About the string, I've got it in this function, because of the public messages in the lower part of the plugin. Here I get the string, and I use it in the messages below.
About the includes - I'll attach te stripweapons of course, forgot it!

You could also cache the prefix into a global variable in the new round event also.

This way if admins change cvars then they get checked every new round to keep them up to date. And your not checking them every time someone opens menu.

ArabicMan 06-02-2014 21:09

Re: Ready /snipers menu
 
Not bad i'll test it.

Flick3rR 06-03-2014 10:16

Re: Ready /snipers menu
 
Any problems, suggestions, notes? I'm going to renew and update the code by Blizzard's example. Hope he didn't get me wrong, because I didn't do this earlier.

ezio_auditore 06-03-2014 10:31

Re: Ready /snipers menu
 
Suggestion..
amx_deagle_bonus.

Try not giving deagle every time, there must be random chances of reciving deagle

Flick3rR 06-03-2014 10:59

Re: Ready /snipers menu
 
Good. Will make two options for the cvar. Every time and with a chance.

Flick3rR 06-03-2014 18:23

Re: Ready /snipers menu
 
A big update is done! Added new features and also rewrote the wohle code, made it more efficient and easy readable. Waiting for your notes! BIG THANKS TO BLIZZARD_87!

EthicalHacker007 06-04-2014 05:44

Re: Ready /snipers menu
 
Quote:

Originally Posted by Flick3rR (Post 2146396)
A big update is done! Added new features and also rewrote the wohle code, made it more efficient and easy readable. Waiting for your notes! BIG THANKS TO BLIZZARD_87!

Should I test it?

Edit: Tested plugin with every cvar value. Everything's fine. But as you've created this for csdm/surf servers, I suggest you to either set bpammo to 200 or unlimited bpammo.


All times are GMT -4. The time now is 01:50.

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