Raised This Month: $51 Target: $400
 12% 

tfcx bug


Post New Thread Reply   
 
Thread Tools Display Modes
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-01-2014 , 03:22   Re: tfcx bug
Reply With Quote #11

To get the current weapon index, you can use m_pActiveItem offset (get_pdata_cbase). It should be probably 569.

What does TFC_SetWeaponAmmo() is basically setting the m_iClip offset. You could for sure use set_pdata_int, it's exactly the same thing except for first you don't need to provide the offset.

Here some weapons offsets:

PHP Code:
    int                        m_iPlayEmptySound;       /*  1180     4 */
    
int                        m_fFireOnEmpty;          /*  1184     4 */
    
float                      m_flNextPrimaryAttack;   /*  1188     4 */
    
float                      m_flNextSecondaryAttack/*  1192     4 */
    
float                      m_flTimeWeaponIdle;      /*  1196     4 */
    
float                      m_flNextReload;          /*  1200     4 */
    
float                      m_flPumpTime;            /*  1204     4 */
    
float                      m_fReloadTime;           /*  1208     4 */
    
float                      m_fAimedDamage;          /*  1212     4 */
    
float                      m_fNextAimBonus;         /*  1216     4 */
    
int                        m_fInZoom;               /*  1220     4 */
    
int                        m_iWeaponState;          /*  1224     4 */
    
int                        m_fInReload;             /*  1228     4 */
    
int                        m_fInSpecialReload;      /*  1232     4 */
    
int                        m_iPrimaryAmmoType;      /*  1236     4 */
    
int                        m_iSecondaryAmmoType;    /*  1240     4 */
    
int                        m_iClip;                 /*  1244     4 */
    
int                        m_iClientClip;           /*  1248     4 */
    
int                        m_iClientWeaponState;    /*  1252     4 */
    
int                        m_iDefaultAmmo;          /*  1256     4 */
    
float                      m_flPrevPrimaryAttack;   /*  1260     4 */
    
float                      m_flLastFireTime;        /*  1264     4 */ 


What you see is the full offset in linux.
To use this with set|get_pdata_*, you need to provide the windows offset.

For example: m_iClip. Windows offset = (1244 / 4) - 4 = 307. You always /4 from full offset if you need to use set|get_pdata_int/float. It's generally written in documentation.
And -4 is because there is a difference of +4 between windows and linux for weapon offsets.

In the module, you see well it uses "#define PD_WEAPON_AMMO 307"


Bonus, offsets for players:

PHP Code:
    class EHANDLE              m_hObserverTarget;           /*  1720     8 */
    
float                      m_flNextObserverInput;       /*  1728     4 */
    
int                        m_iObserverWeapon;           /*  1732     4 */
    
int                        m_iObserverLastMode;         /*  1736     4 */
    
int                        random_seed;                 /*  1740     4 */
    
int                        m_iPlayerSound;              /*  1744     4 */
    
int                        m_iTargetVolume;             /*  1748     4 */
    
int                        m_iWeaponVolume;             /*  1752     4 */
    
int                        m_iExtraSoundTypes;          /*  1756     4 */
    
int                        m_iWeaponFlash;              /*  1760     4 */
    
float                      m_flStopExtraSoundTime;      /*  1764     4 */
    
float                      m_flFlashLightTime;          /*  1768     4 */
    
int                        m_iFlashBattery;             /*  1772     4 */
    
int                        m_afButtonLast;              /*  1776     4 */
    
int                        m_afButtonPressed;           /*  1780     4 */
    
int                        m_afButtonReleased;          /*  1784     4 */
    
edict_t *                  m_pentSndLast;               /*  1788     4 */
    
float                      m_flSndRoomtype;             /*  1792     4 */
    
float                      m_flSndRange;                /*  1796     4 */
    
float                      m_flFallVelocity;            /*  1800     4 */
    
int                        m_rgItems[5];                /*  1804    20 */
    
int                        m_fKnownItem;                /*  1824     4 */
    
int                        m_fNewAmmo;                  /*  1828     4 */
    
unsigned int               m_afPhysicsFlags;            /*  1832     4 */
    
float                      m_fNextSuicideTime;          /*  1836     4 */
    
float                      m_fDontPackItemsUntil;       /*  1840     4 */
    
float                      m_fNextTeamOrClassChange;    /*  1844     4 */
    
float                      m_flTimeStepSound;           /*  1848     4 */
    
float                      m_flTimeWeaponIdle;          /*  1852     4 */
    
float                      m_flSwimTime;                /*  1856     4 */
    
float                      m_flDuckTime;                /*  1860     4 */
    
float                      m_flWallJumpTime;            /*  1864     4 */
    
float                      m_flSuitUpdate;              /*  1868     4 */
    
int                        m_rgSuitPlayList[4];         /*  1872    16 */
    
int                        m_iSuitPlayNext;             /*  1888     4 */
    
int                        m_rgiSuitNoRepeat[32];       /*  1892   128 */
    
float                      m_rgflSuitNoRepeatTime[32];  /*  2020   128 */
    
int                        m_lastDamageAmount;          /*  2148     4 */
    
float                      m_tbdPrev;                   /*  2152     4 */
    
float                      m_flgeigerRange;             /*  2156     4 */
    
float                      m_flgeigerDelay;             /*  2160     4 */
    
int                        m_igeigerRangePrev;          /*  2164     4 */
    
int                        m_iStepLeft;                 /*  2168     4 */
    
char                       m_szTextureName[13];         /*  2172    13 */
    
char                       m_chTextureType;             /*  2185     1 */
    
int                        m_idrowndmg;                 /*  2188     4 */
    
int                        m_idrownrestored;            /*  2192     4 */
    
int                        m_bitsHUDDamage;             /*  2196     4 */
    
BOOL                       m_fInitHUD;                  /*  2200     4 */
    
BOOL                       m_fGameHUDInitialized;       /*  2204     4 */
    
int                        m_iTrain;                    /*  2208     4 */
    
BOOL                       m_fWeapon;                   /*  2212     4 */
    
class EHANDLE              m_pTank;                     /*  2216     8 */
    
float                      m_fDeadTime;                 /*  2224     4 */
    
BOOL                       m_fNoPlayerSound;            /*  2228     4 */
    
BOOL                       m_fLongJump;                 /*  2232     4 */
    
int                        m_iGLClip;                   /*  2236     4 */
    
float                      m_tSneaking;                 /*  2240     4 */
    
int                        m_iUpdateTime;               /*  2244     4 */
    
int                        m_iClientHealth;             /*  2248     4 */
    
int                        m_iClientBattery;            /*  2252     4 */
    
int                        m_iHideHUD;                  /*  2256     4 */
    
int                        m_iClientHideHUD;            /*  2260     4 */
    
int                        m_iFOV;                      /*  2264     4 */
    
int                        m_iClientFOV;                /*  2268     4 */
    
class CBasePlayerItem *    m_rgpPlayerItems[6];         /*  2272    24 */
    
class CBasePlayerItem *    m_pActiveItem;               /*  2296     4 */
    
class CBasePlayerItem *    m_pClientActiveItem;         /*  2300     4 */
    
class CBasePlayerItem *    m_pLastItem;                 /*  2304     4 */
    
const char  *              m_pszLastItem;               /*  2308     4 */
    
int                        m_rgAmmo[32];                /*  2312   128 */
    
int                        m_rgAmmoLast[32];            /*  2440   128 */
    
class Vector              m_vecAutoAim;                 /*  2568    12 */
    
BOOL                       m_fOnTarget;                 /*  2580     4 */
    
int                        m_iDeaths;                   /*  2584     4 */
    
int                        m_iClientDeaths;             /*  2588     4 */
    
int                        m_iClientFrags;              /*  2592     4 */
    
int                        m_iClientPlayerClass;        /*  2596     4 */
    
int                        m_iClientTeam;               /*  2600     4 */
    
int                        m_iClientItems;              /*  2604     4 */
    
float                      m_iRespawnFrames;            /*  2608     4 */
    
int                        m_iTimeCheckAllowed;         /*  2612     4 */
    
int                        m_lastx;                     /*  2616     4 */
    
int                        m_lasty;                     /*  2620     4 */
    
int                        m_iConcussion;               /*  2624     4 */
    
int                        m_iClientConcussion;         /*  2628     4 */
    
int                        m_iConcStartVal;             /*  2632     4 */
    
float                      m_flConcStartTime;           /*  2636     4 */
    
float                      m_flConcDuration;            /*  2640     4 */
    
int                        m_iBeingTeleported;          /*  2644     4 */
    
int                        m_nCustomSprayFrames;        /*  2648     4 */
    
float                      m_flNextDecalTime;           /*  2652     4 */
    
BOOL                       m_bDisplayedMOTD;            /*  2656     4 */
    
BOOL                       m_bSentBuildingEvents;       /*  2660     4 */
    
char                       m_MenuStringBuffer[512];     /*  2664   512 */
    
int                        m_MenuSelectionBuffer;       /*  3176     4 */
    
float                      m_MenuUpdateTime;            /*  3180     4 */
    
char                       m_SbarString0[128];          /*  3184   128 */
    
char                       m_SbarString1[128];          /*  3312   128 */
    
char                       m_SbarString2[128];          /*  3440   128 */
    
TYPEDESCRIPTION            m_playerSaveData[38];        /*     0   608 */
    
char                       m_szAnimExtention[32];       /*  3568    32 */
    
int                        m_iCurrentAnimationState;    /*  3600     4 */
    
int                        m_iCurrentAnimationSequence/*  3604     4 */
    
char                       m_szSavedAnimExtention[32];  /*  3608    32 */
    
char *                     m_pszSavedWeaponModel;       /*  3640     4 */
    
int                        m_iTeamToDisguiseAs;         /*  3644     4 */
    
float                      m_DB_LastTimingTestTime;     /*  3648     4 */
    
int                        m_nFirstSpawn;               /*  3652     4 */
    
string_t                   delayed_spawn_message;       /*  3656     4 */
    
int                        forced_spawn;                /*  3660     4 */
    
int                        no_sentry_message;           /*  3664     4 */
    
int                        no_dispenser_message;        /*  3668     4 */
    
int                        m_iPipebombCount;            /*  3672     4 */
    
int                        m_iAmmoboxCount;             /*  3676     4 */
    
int                        m_iMaxArmor;                 /*  3680     4 */
    
int                        no_entry_teleporter_message/*  3684     4 */
    
int                        no_exit_teleporter_message;  /*  3688     4 */
    
int                        m_iFadeDirection;            /*  3692     4 */
    
float                      m_flFadeAmount;              /*  3696     4 */
    
float                      m_flGagTime;                 /*  3700     4 */
    
float                      m_flLastTalkTime;            /*  3704     4 */
    
int                        m_cSpamPoints;               /*  3708     4 */
    
float                      m_flNextSBarUpdateTime;      /*  3712     4 */
    
int                        m_izSBarState[7];            /*  3716    28 */
    
float                      m_flStatusBarDisappearDelay/*  3744     4 */
    
class EHANDLE             m_hLastIDTarget;              /*  3748     8 */
    
BOOL                       m_bUpdatedCommandMenu;       /*  3756     4 */
    
int                        m_iClientIsFeigning;         /*  3760     4 */
    
int                        m_iClientIsDetpacking;       /*  3764     4 */
    
int                        m_iClientDetpackAmmo;        /*  3768     4 */
    
int                        m_iClientBuildState;         /*  3772     4 */
    
int                        m_iClientRandomPC;           /*  3776     4 */
    
float                      m_flTeleporterEffectEndTime/*  3780     4 */ 


Example: m_pActiveItem. 569 = (2296 / 4) - 5 = 569. -5 because there is difference of +5 between windows and linux for players offsets.
__________________

Last edited by Arkshine; 05-01-2014 at 17:28.
Arkshine is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 05-01-2014 , 03:36   Re: tfcx bug
Reply With Quote #12

[QUOTE=urban_ninja;2131889]So theres no singular function for getting weapon entity? If I remember correctly, find entity by class only returns the 1st match it finds and then stops there.[QUOTE]

It's a loop. It takes all owned weapons from the beginning to the end. You can add more checks, of course.
__________________

Last edited by claudiuhks; 05-01-2014 at 03:36.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-01-2014 , 03:53   Re: tfcx bug
Reply With Quote #13

Which is an horrible way to get a weapon index.
__________________
Arkshine is offline
urban_ninja
Senior Member
Join Date: Feb 2009
Old 05-01-2014 , 18:23   Re: tfcx bug
Reply With Quote #14

Quote:
Originally Posted by Arkshine View Post
To get the current weapon index, you can use m_pActiveItem offset (get_pdata_cbase). It should be probably 569.

Example: m_pActiveItem. 569 = (2296 / 4) - 5 = 569. -5 because there is difference of +5 between windows and linux for players offsets.
Thanks. Just the reliable method I need. Got it working.
urban_ninja is offline
Reply



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 09:22.


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