PDA

View Full Version : Weapon entity -> weapon index


Schmarotzer
01-25-2012, 02:37
How I can get weapon index if I know weapon entity?

Tylerst
01-25-2012, 02:53
new weaponindex = GetEntProp(weaponentity, Prop_Send, "m_iItemDefinitionIndex");

Schmarotzer
01-26-2012, 00:45
got
L 01/25/2012 - 23:39:29: [SM] Native "CS_GetWeaponPrice" reported: Failed to get weaponinfo


new wpnent = GetCurrentWeaponEnt(client);
new WID = GetEntProp(wpnent, Prop_Send, "m_iItemDefinitionIndex");
new price = CS_GetWeaponPrice(client,WID,false);


what's wrong?

Schmarotzer
01-26-2012, 02:02
I need do it for CSS

Tylerst
01-26-2012, 08:04
got
L 01/25/2012 - 23:39:29: [SM] Native "CS_GetWeaponPrice" reported: Failed to get weaponinfo


new wpnent = GetCurrentWeaponEnt(client);
new WID = GetEntProp(wpnent, Prop_Send, "m_iItemDefinitionIndex");
new price = CS_GetWeaponPrice(client,WID,false);


what's wrong?

Sorry, thought you were asking for TF2.

The CS_GetWeaponPrice (http://docs.sourcemod.net/api/index.php?fastload=show&id=1015&) Function uses the CSWeaponID enum


enum CSWeaponID
{
CSWeapon_NONE,
CSWeapon_P228,
CSWeapon_GLOCK,
CSWeapon_SCOUT,
CSWeapon_HEGRENADE,
CSWeapon_XM1014,
CSWeapon_C4,
CSWeapon_MAC10,
CSWeapon_AUG,
CSWeapon_SMOKEGRENADE,
CSWeapon_ELITE,
CSWeapon_FIVESEVEN,
CSWeapon_UMP45,
CSWeapon_SG550,
CSWeapon_GALIL,
CSWeapon_FAMAS,
CSWeapon_USP,
CSWeapon_AWP,
CSWeapon_MP5NAVY,
CSWeapon_M249,
CSWeapon_M3,
CSWeapon_M4A1,
CSWeapon_TMP,
CSWeapon_G3SG1,
CSWeapon_FLASHBANG,
CSWeapon_DEAGLE,
CSWeapon_SG552,
CSWeapon_AK47,
CSWeapon_KNIFE,
CSWeapon_P90,
CSWeapon_SHIELD,
CSWeapon_KEVLAR,
CSWeapon_ASSAULTSUIT,
CSWeapon_NIGHTVISION
};

Dr!fter
01-26-2012, 11:28
If you want to grab the id based on entity you need to create something to convert them. Weapon restrict implemented a weapon tracking code to keep track of them. I'll post it in snippets and a link to it here when I get out of class :p

Dr!fter
01-26-2012, 13:05
http://forums.alliedmods.net/showthread.php?p=1638789#post1638789 Posted.