[STOCK] cs_drop_user_weapon
Posted: Sat Oct 03, 2026 3:33 pm
cs_drop_user_weapon
This stock is specify for Counter-Strike, it's a little stock based on 'ham_strip_weapon' one, honestly being i just take that one and edit it for making something else and add some optimizations.
You need to note that this stock already contain some checks for safety ( Like if user is alive or if has already the weapon ) so you will need just to put directly the function without any checks.
* As Hamlet says, what's the difference betwen this and ham_strip_weapon, As i say not so much because ham_strip_weapon is the original, i take it, modifing and making something different, but let's see a few differences betwen that one and mine :
You can DROP the weapon or if you want you also can STRIP IT( Remove/destroy ).
Return properly the weapon Entity ID.
Comparing the Nades using the 'Bits' insteand of CSW_ weapons.
For my this list is useless, you have here the stock, just open and see the diferences, have fun.
Credits: Bugsy(helping me with previous stock) & Avalanche( The original author ).
The stock:
Example
Modules Required
- Amxmodx
- Hamsandwich
- Cstrike
- Fakemeta
A Plugin Way
- You may note with this 'stock' you can not drop nades or knife ( Only striping them by setting the 3rd parameter as 1 ) But i made a shourt plugin wich enable all the time droping nades/knife and include the native cs_drop_user_weapon + a little forward called when you drop a weapon, just go here.<to be added>
- But you may prefer this plugin<to be added> instead of my stock/plugin native because it's much better coded and stable to use, thanks.
This stock is specify for Counter-Strike, it's a little stock based on 'ham_strip_weapon' one, honestly being i just take that one and edit it for making something else and add some optimizations.
You need to note that this stock already contain some checks for safety ( Like if user is alive or if has already the weapon ) so you will need just to put directly the function without any checks.
* As Hamlet says, what's the difference betwen this and ham_strip_weapon, As i say not so much because ham_strip_weapon is the original, i take it, modifing and making something different, but let's see a few differences betwen that one and mine :
You can DROP the weapon or if you want you also can STRIP IT( Remove/destroy ).
Return properly the weapon Entity ID.
Comparing the Nades using the 'Bits' insteand of CSW_ weapons.
For my this list is useless, you have here the stock, just open and see the diferences, have fun.
Credits: Bugsy(helping me with previous stock) & Avalanche( The original author ).
The stock:
Code: Select all
/*********************************
cs_drop_user_weapon:
@param id: The Player Index .
@param szWeaponName[]: The Weapon Name you wanne drop/strip( See Weapon list ).
@param bStrip: if "1" will strip that weapon not only drop, if "0" will just drop it.
@return: Weapon Entity ID.
*********************************/
stock cs_drop_user_weapon( const id, const szWeaponName[]="", const bStrip=0, )
{
new wEnt = -1 , WeaponId = get_weaponid( szWeaponName );
const NadeBits = ( ( 1 << CSW_HEGRENADE ) | ( 1 << CSW_FLASHBANG ) | ( 1 << CSW_SMOKEGRENADE ) );
if( ( 0 < WeaponId < 30 ) && is_user_alive( id ) && user_has_weapon( id, WeaponId ) )
{
if( bStrip > 0 )
{
while( ( wEnt = engfunc( EngFunc_FindEntityByString , wEnt , "classname" , szWeaponName ) ) && pev( wEnt , pev_owner ) != id ) {}
if( !wEnt )
return -1;
ExecuteHamB( Ham_Weapon_RetireWeapon , wEnt);
if( !ExecuteHamB( Ham_RemovePlayerItem , id , wEnt ) )
return -1;
ExecuteHamB( Ham_Item_Kill , wEnt );
// this is for 'Grenades'.
if( WeaponId == CSW_C4 )
{
cs_set_user_plant( id , 0 , 0 );
cs_set_user_bpammo( id , CSW_C4 , 0 );
}
else if ( NadeBits & ( 1 << WeaponId ) )
cs_set_user_bpammo(id,WeaponId,0);
}
else
engclient_cmd( id, "drop", szWeaponName );
// thanks to Connor here:
user_has_weapon( id, WeaponId, 0 );
}
return wEnt;
} Code: Select all
// Striping USP from user inventory:
cs_drop_user_weapon(id, "weapon_usp", 1);
// Droping glock without striping it.
cs_drop_user_weapon( id, "weapon_glock18", 0 );
// Striping a nade( Note that you always need to put "1" for bStrip when you deals with Nades, because nades can't be just dropped, you really need to strip it.
cs_drop_user_weapon( id, "weapon_hegrenade", 1 )- Amxmodx
- Hamsandwich
- Cstrike
- Fakemeta
A Plugin Way
- You may note with this 'stock' you can not drop nades or knife ( Only striping them by setting the 3rd parameter as 1 ) But i made a shourt plugin wich enable all the time droping nades/knife and include the native cs_drop_user_weapon + a little forward called when you drop a weapon, just go here.<to be added>
- But you may prefer this plugin<to be added> instead of my stock/plugin native because it's much better coded and stable to use, thanks.