Raised This Month: $ Target: $400
 0% 

OFFSET_PRIMARYWEAPON issue


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-14-2011 , 06:10   Re: OFFSET_PRIMARYWEAPON issue
Reply With Quote #6

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.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 08-14-2011 at 06:15.
ConnorMcLeod is offline
 



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 03:27.


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