AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Give a person a weapon with 1 bullet? (https://forums.alliedmods.net/showthread.php?t=222586)

AwesomeMan 08-04-2013 12:02

Give a person a weapon with 1 bullet?
 
Hello, how would i give someone a gun(lets say deagle) with 1bullet?

hleV 08-04-2013 12:10

Re: Give a person a weapon with 1 bullet?
 
Code:
new deagle = give_weapon(player, "weapon_deagle"); if (deagle > 0)     cs_set_weapon_ammo(deagle, 1);

_Pro_ 08-04-2013 12:29

Re: Give a person a weapon with 1 bullet?
 
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


AwesomeMan 08-04-2013 13:14

Re: Give a person a weapon with 1 bullet?
 
Thank you! The "fun" way works great! :D

YamiKaitou 08-04-2013 13:21

Re: Give a person a weapon with 1 bullet?
 
The fakemeta_util way is NOT recommended

ConnorMcLeod 08-04-2013 13:59

Re: Give a person a weapon with 1 bullet?
 
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

_Pro_ 08-04-2013 17:23

Re: Give a person a weapon with 1 bullet?
 
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... 



All times are GMT -4. The time now is 15:48.

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