So you don't know how to check which weapons a player have.
You can check get_pdata_cbase(id, with slots offsets (m_rgpPlayerItems), you will retrieve the first weapon a player have on each slot.
Then, if there is another weapon in this slot, the next weapon is linked to first weapon with weapon offset m_pNext (cbase), etc...
Player offsets, linux diff = 5
367-372 m_rgpPlayerItems[MAX_ITEM_TYPES] // 6 (cbase)
367 is not used, 368 is first slot.
Weapon offset, linux extra offset = 4
#define m_pNext 42
So, suppose i have an ak47 (entity 53 for example), a m4a1 (ent 57), a deagle (60), a glock (63) and an usp (65)
get_pdata_cbase(id, m_rgpPlayerItems_1 /* 368 */, 5) == 53
get_pdata_cbase(53, m_pNext, 4) == 57
get_pdata_cbase(57, m_pNext, 4) == 0 or -1 depending on linux/windows
get_pdata_cbase(id, m_rgpPlayerItems_2 /* 369 */, 5) == 60
get_pdata_cbase(60, m_pNext, 4) == 63
get_pdata_cbase(63, m_pNext, 4) == 65
get_pdata_cbase(65, m_pNext, 4) == 0 or -1 depending on linux/windows
Same method is used to know which weapons are in a weaponbox (if no plugin/addon change normal cs behavior, only 1 weapon is stored in a weaponbox).
For player weapons, you can also check pev_weapons bitsum, but it can, if you don't check it at the right moment (during strip process for example) return false results, should be reliable though, it's the way amxx uses for get_user_weapons and has_user_weapon natives.
__________________
Last edited by ConnorMcLeod; 08-14-2011 at 06:15.
|