Raised This Month: $ Target: $400
 0% 

[HELP] Explaining Strip Stock


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 02-13-2017 , 11:59   [HELP] Explaining Strip Stock
Reply With Quote #1

So i found this weapon strip stock, and i was looking over to learn couple things from it when i got the the lines i marked with red

What i don't understand is why get the weapon's name using it's index, in order to pass it to the next stock to retrieve it's index using it's name when you could simply pass directly the index ? o.O

Code:
stock strip_weapons(iPlayer, iType)
{
	new iWeapons[32], iNum, iWeaponID
	get_user_weapons(iPlayer, iWeapons, iNum)

	for (new x = 0; x < iNum; x++)
	{
		iWeaponID = iWeapons[x]

		if ((1<<iWeaponID) & iType)
		{
			new szWeaponName[32]
			get_weaponname(iWeaponID, szWeaponName, charsmax(szWeaponName))

			ham_strip_weapon(iPlayer, szWeaponName)

			cs_set_user_bpammo(iPlayer, iWeaponID, 0)
		}
	}
}

stock ham_strip_weapon(iPlayer, const szWeapon[])
{
	new iWeaponID = get_weaponid(szWeapon)

	if (!pev_valid(iWeaponID))
		return false;

	new iEntity = ks_get_entity_owner(-1, szWeapon, iPlayer)

	if (!pev_valid(iEntity))
		return false;

	new iWeaponEntity = ks_get_weapon_owner(iPlayer)
	new iWeapon = pev_valid(iWeaponEntity) ? cs_get_weapon_id(iWeaponEntity) : -1

	if (iWeapon == iEntity)
		ExecuteHamB(Ham_Weapon_RetireWeapon, iEntity)

	if(!ExecuteHamB(Ham_RemovePlayerItem, iPlayer, iEntity))
		return false;

	ExecuteHamB(Ham_Item_Kill, iEntity)

	set_pev(iPlayer, pev_weapons, pev(iPlayer, pev_weapons) & ~(1<<iWeaponID))

	return true;
}
__________________

Last edited by Depresie; 02-13-2017 at 12:02.
Depresie is offline
 


Thread Tools
Display Modes

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 21:00.


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