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

Give a person a weapon with 1 bullet?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AwesomeMan
Member
Join Date: Jun 2013
Old 08-04-2013 , 12:02   Give a person a weapon with 1 bullet?
Reply With Quote #1

Hello, how would i give someone a gun(lets say deagle) with 1bullet?
AwesomeMan is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 08-04-2013 , 12:10   Re: Give a person a weapon with 1 bullet?
Reply With Quote #2

Code:
new deagle = give_weapon(player, "weapon_deagle"); if (deagle > 0)     cs_set_weapon_ammo(deagle, 1);
__________________
hleV is offline
_Pro_
Senior Member
Join Date: Mar 2012
Location: Argentina
Old 08-04-2013 , 12:29   Re: Give a person a weapon with 1 bullet?
Reply With Quote #3

PHP Code:
// With fun
cs_set_weapon_ammo(give_item(index"weapon_deagle"), 1)
// With fakemeta_util
cs_set_weapon_ammo(fm_give_item(index"weapon_deagle"), 1
_Pro_ is offline
Send a message via MSN to _Pro_ Send a message via Skype™ to _Pro_
AwesomeMan
Member
Join Date: Jun 2013
Old 08-04-2013 , 13:14   Re: Give a person a weapon with 1 bullet?
Reply With Quote #4

Thank you! The "fun" way works great!

Last edited by AwesomeMan; 08-04-2013 at 13:23.
AwesomeMan is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 08-04-2013 , 13:21   Re: Give a person a weapon with 1 bullet?
Reply With Quote #5

The fakemeta_util way is NOT recommended
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-04-2013 , 13:59   Re: Give a person a weapon with 1 bullet?
Reply With Quote #6

Problem if user already has this weapon is that give_item gonna returns 0 or -1 and cs_set_weapon_ammo gonna throw an error, and player won't have ammo = 1
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
_Pro_
Senior Member
Join Date: Mar 2012
Location: Argentina
Old 08-04-2013 , 17:23   Re: Give a person a weapon with 1 bullet?
Reply With Quote #7

Add before cs_set_weapon_ammo this if (!user_has_weapon(index, CSW_DEAGLE))
PHP Code:
 if (!user_has_weapon(indexCSW_DEAGLE)) cs_set_weapon_ammo... 
_Pro_ is offline
Send a message via MSN to _Pro_ Send a message via Skype™ to _Pro_
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:18.


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