AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   bullets problem (https://forums.alliedmods.net/showthread.php?t=54183)

Samurai [/] 04-19-2007 07:53

bullets problem
 
i made one plugin that removes spawn equip, but how is it possible to remove bullets from given gun and then give bullets to it?

Styles 04-19-2007 10:39

Re: bullets problem
 
Yes it has something to do with:
cs_set_weapon_ammo(id , 12);
cs_get_weapon_ammo()

Silencer123 04-19-2007 14:04

Re: bullets problem
 
http://www.amxmodx.org/funcwiki.php?go=func&id=185 // Get Ammo in Backpack
http://www.amxmodx.org/funcwiki.php?go=func&id=186 // Set Ammo in Backpack
http://www.amxmodx.org/funcwiki.php?go=func&id=207 // Get Ammo in current Clip
http://www.amxmodx.org/funcwiki.php?go=func&id=208 // Set Ammo in current Clip
( Those four do not ask for players id - the entity ID of the weapon is meant )

http://www.amxmodx.org/funcwiki.php?go=module&id=4 // Weapon IDs
( NOT the Entity IDs - Entity IDs vary on every weapon on the servers instance of a map, situation and time )

http://www.amxmodx.org/funcwiki.php?go=func&id=156 // Get currently carried Weapon
http://www.amxmodx.org/funcwiki.php?go=func&id=163 // Get list of all owned Weapons
( First get the Weapons ID(s) ( NOT Entity ID(s) ) )

http://www.amxmodx.org/funcwiki.php?go=func&id=617 // Call a Function in the Engine
( This requires Fakemeta - Use this in a loop to get Weapons Entity IDs )
( Use EngFunc_FindEntityByString with "classname" and "weapon_whatever" )
Here is a list of weapon names:
Code:

weapon_knife
weapon_deagle
weapon_usp
weapon_glock
weapon_p228
weapon_elite
weapon_fiveseven
weapon_ak47
weapon_aug
weapon_g3sg1
weapon_m249
weapon_m4a1
weapon_m3
weapon_mac10
weapon_mp5navy
weapon_p90
weapon_scout
weapon_sg552
weapon_sg550
weapon_ump45
weapon_tmp
weapon_xm1014
weapon_awp
weapon_galil
weapon_famas
weapon_hegrenade
weapon_flashbang
weapon_smokegrenade
weapon_c4

Or just use this one:
http://www.amxmodx.org/funcwiki.php?go=func&id=164 // Changes a Weapons ID into its classname,
like into those shown in the code block above - probably easier to use this.

http://www.amxmodx.org/funcwiki.php?go=func&id=609 // Retrieves Keyvalues from Entities
( Use pev_owner on the Weapon Entity IDs retrieved with engfunc to get correct Players Weapon )
( Also uses Fakemeta )


If you are clever enough, you can put these functions together into
a simple function which can change the ammo of one of a players weapon.

Samurai [/] 04-19-2007 14:46

Re: bullets problem
 
if i use this:
cs_set_weapon_ammo ( index, newammo )
will it replace spawn clip?

Samurai [/] 04-20-2007 08:46

Re: bullets problem
 
i dont know how..

Silencer123 04-20-2007 09:41

Re: bullets problem
 
It will change the amount of ammunition in the current clip.
For example the m4a1 can have up to 30 bullets in the current
clip and 90 ammo in backpack. You should not go above 255 as
CS can not display that then. What do you not know how to
do it? I have just written a full manual on how to do what you want.
Please be more precisely if you expect any more help, thanks.

Samurai [/] 04-21-2007 17:17

Re: bullets problem
 
Quote:

Originally Posted by Silencer123 (Post 467551)
It will change the amount of ammunition in the current clip.
For example the m4a1 can have up to 30 bullets in the current
clip and 90 ammo in backpack. You should not go above 255 as
CS can not display that then. What do you not know how to
do it? I have just written a full manual on how to do what you want.
Please be more precisely if you expect any more help, thanks.

I dont really know how to put these together those links are pretty confusing.

VEN 04-22-2007 07:10

Re: bullets problem
 
The problem is that you can't say for sure whether this weapon recieved on spawn or not. Let's say that all weapons that you recieve for a time 0.1 sec after spawn are spawn weapons (see http://forums.alliedmods.net/showthread.php?t=42159 for more info on spawn event). Then after that delay use get_user_weapons(), loop though all player's weapons and do cs_set_weapon_ammo(fm_get_user_weapon_entity( id, weapon_id), 0). Though you should skip weapons that doesn't contain clip (knife, c4 etc).

fm_get_user_weapon_entity() function can be found here: Fakemeta Utilities

Samurai [/] 04-22-2007 09:26

Re: bullets problem
 
Quote:

Originally Posted by VEN
get_user_weapons(), loop though all player's weapons

Im doing this for spawn weapons scripts which have set_task 3.0 after spawn.
(I dont get that get_user_weapons thing.. :shock:)

VEN 04-22-2007 09:48

Re: bullets problem
 
Quote:

new weapons[32], num
get_user_weapons(id, weapons, num)
for (new i = 0; i < num; ++i)
// etc


All times are GMT -4. The time now is 06:43.

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