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

Weapon Return


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Gameplay        Approver:   ConnorMcLeod (74)
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-30-2011 , 00:28   Weapon Return
Reply With Quote #1

Description:
This plugin allows players to return their weapons back to the store for a refund.

Client Commands:
/return - Returns current weapon.

CVars:
rw_percent <percentage> <default:0.80> - How much money players should get back. MUST BE A DECIMAL.
rw_buyzone <0/1> <default:1> - Whether players must be in a buyzone to return their weapons.

Changelog:
Code:
July 30, 2011  - v1.0 - Plugin Release
                    - v1.1 - Few optimizations
                    - v1.2 - Added support for shield return
Credits:
nikhilgupta345 - Code
XxAvalanchexX - ham_strip_weapon stock
Exolent - cs_set_user_shield stock

Installation:
-Click on 'Get Plugin' below
-Place 'weapon_return.amxx' into your plugins folder
-Add the text 'weapon_return.amxx' to the bottom of plugins.ini
-Restart server or change map
Attached Files
File Type: sma Get Plugin or Get Source (weapon_return.sma - 3346 views - 5.1 KB)
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please

Last edited by nikhilgupta345; 07-30-2011 at 21:31.
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
delayedCoder
Junior Member
Join Date: Jul 2011
Location: under binary
Old 07-30-2011 , 00:36   Re: Weapon Return
Reply With Quote #2

Your first '0' constant isn't really necessary.

Otherwise, good work and great idea!
delayedCoder is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-30-2011 , 00:36   Re: Weapon Return
Reply With Quote #3

It's easier to be able to use the users weapon id as an index in the array.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 07-30-2011 , 04:28   Re: Weapon Return
Reply With Quote #4

You have included Hamsandwich just for ham_strip_weapons which is not a good idea, remove ham and include fun and then use strip_user_weapons, bcoz its more effecient and much faster.
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-30-2011 , 04:53   Re: Weapon Return
Reply With Quote #5

You don't need to check for weapon_knife and weapon_c4.
Instead you can :
- check if iWeapon is CSW_C4 or CSW_KNIFE
or
- check weapon cost before you send ham_strip_weapon and then check if price is > 0

You don't need to clamp money, just use min(cs_get_user_money( id ) + iRefund, 16000).

You could add shield return.

Other than that, code is ok.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 07-30-2011 , 04:56   Re: Weapon Return
Reply With Quote #6

Does already exist...

http://forums.alliedmods.net/showthread.php?p=472306
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
Old 07-30-2011, 06:28
delayedCoder
This message has been deleted by ConnorMcLeod. Reason: Offtopic, this is not scripting/help section, and search the wiki for native details.
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 07-30-2011 , 06:44   Re: Weapon Return
Reply With Quote #7

You also should check if user is alive.
__________________
xPaw is offline
Old 07-30-2011, 07:07
bibu
This message has been deleted by ConnorMcLeod. Reason: Reply to a deleted post
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-30-2011 , 11:16   Re: Weapon Return
Reply With Quote #8

Quote:
Originally Posted by abdul-rehman View Post
You have included Hamsandwich just for ham_strip_weapons which is not a good idea, remove ham and include fun and then use strip_user_weapons, bcoz its more effecient and much faster.
I only need to strip the weapon their holding, and strip_user_weapons strips all the weapons that a player has.

Quote:
Originally Posted by ConnorMcLeod View Post
You don't need to check for weapon_knife and weapon_c4.
Instead you can :
- check if iWeapon is CSW_C4 or CSW_KNIFE
or
- check weapon cost before you send ham_strip_weapon and then check if price is > 0

You don't need to clamp money, just use min(cs_get_user_money( id ) + iRefund, 16000).

You could add shield return.

Other than that, code is ok.
Alright, I just couldn't find a way to strip a users shield. Got any ideas?

Quote:
Originally Posted by bibu View Post
Didn't find that before. I guess the only thing that makes mine different is the fact that I have grenade support + will be adding shield support soon if I figure out how to do it xD

Also, my CVar allows you to put a percentage, rather than dividing by a certain amount. And since it must be an integer in the other plugin, you have less choices for prices.

Approvers can determine if the changes suffice to make this plugin approved.

Quote:
Originally Posted by xPaw View Post
You also should check if user is alive.
Easy enough.



Updated to version 1.1
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please

Last edited by nikhilgupta345; 07-30-2011 at 11:19.
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 07-30-2011 , 16:48   Re: Weapon Return
Reply With Quote #9

Will approve under these conditions:
  • If rw_percent is set to 0, it should disable the command/plugin.
  • If iRefund is 0, you should not be able to return the weapon.
  • Name your variables correctly: iPercent -> fPercent
  • Have it print in chat how much money you recieved.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-30-2011 , 17:10   Re: Weapon Return
Reply With Quote #10

Quote:
Originally Posted by Emp` View Post
Will approve under these conditions:
  • If rw_percent is set to 0, it should disable the command/plugin.
  • If iRefund is 0, you should not be able to return the weapon.
  • Name your variables correctly: iPercent -> fPercent
  • Have it print in chat how much money you recieved.
Done.

Any ideas about the stripping of shields by the way?
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
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 15:31.


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