Results 1 to 2 of 2
  1. #1
    CamxxCore's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    21
    Reputation
    10
    Thanks
    264

    HUD Elems - Where did I go wrong?

    If anyone can help me with this, I will appreciate it very much. I've been trying to get HUD elements working on the latest patch but haven't had much luck. Everything looks right to me, but I still can't get anything to actually show up in-game. If there is something clearly wrong with how I am doing this, please tell me. I'm using the exact same method that has been used on consoles to achieve the same result. I am new and still learning, so please go easy!

    Code:
    int GetMaterialIndex(const char* materialName)
    {
    	return ((int(__cdecl*)(const char*))0x54D620)(materialName);
    }
    
    int G_LocalizedStringIndex(const char* text)
    {
    	return ((int(__cdecl*)(const char*))0x54D490)(text);
    }
    
    game_hudelem_s* HudElemAlloc(int client, int teamNum)
    {
    	return ((game_hudelem_s*(__cdecl*)(int, int))0x5293E0)(client, teamNum);
    }
    
    void func()
    {
    	// spawn a hud element
    	game_hudelem_s* elem = HudElemAlloc(0, 0);
    	elem->clientNum = 0;
    	elem->elem.type = 1;
    	elem->elem.text = G_LocalizedStringIndex("Hello, world.");
    	elem->elem.font = 1;
    	elem->elem.fontScale = 10;
    	elem->elem.x = 250;
    	elem->elem.y = 100;
    	elem->elem.alignOrg = 1;
    	elem->elem.alignScreen = 6;
    	elem->elem.color.r = 255;
    	elem->elem.color.g = 255;
    	elem->elem.color.b = 255;
    	elem->elem.color.a = 255;
    	elem->elem.glowColor.r = 255;
    	elem->elem.glowColor.g = 255;
    	elem->elem.glowColor.b = 255;
    	elem->elem.glowColor.a = 255;
    
    	// nothing! :(
    }
    Code:
    union color_s
    {
    	struct
    	{
    		int8_t r;
    		int8_t g;
    		int8_t b;
    		int8_t a;
    	};
    	int32_t rgba;
    };
    
    struct hudelem_s
    {
    	int type;                     // 0x00-0x04
    	float y;                      // 0x04-0x08
    	float x;                      // 0x08-0x0C
    	float z;                      // 0x0C-0x10
    	int targetEntNum;             // 0x10-0x14
    	float fontScale;              // 0x14-0x18
    	float fromFontScale;          // 0x18-0x1C
    	int fontScaleStartTime;       // 0x1C-0x20
    	int fontScaleTime;            // 0x20-0x24
    	int label;                    // 0x24-0x28
    	int font;                     // 0x28-0x2C
    	int alignOrg;                 // 0x2C-0x30
    	int alignScreen;              // 0x30-0x34
    	color_s color;                  // 0x34-0x38
    	color_s fromColor;              // 0x38-0x3C
    	int fadeStartTime;            // 0x3C-0x40
    	int fadeTime;                 // 0x40-0x44
    	int height;                   // 0x44-0x48
    	int width;                    // 0x48-0x4C
    	int materialIndex;            // 0x4C-0x50
    	int fromHeight;               // 0x50-0x54
    	int fromWidth;                // 0x54-0x58
    	int scaleStartTime;           // 0x58-0x5C
    	int scaleTime;                // 0x5C-0x60
    	float fromY;                  // 0x60-0x64
    	float fromX;                  // 0x64-0x68
    	int fromAlignOrg;             // 0x68-0x6C
    	int fromAlignScreen;          // 0x6C-0x70
    	int moveStartTime;            // 0x70-0x74
    	int moveTime;                 // 0x74-0x78
    	float value;                  // 0x78-0x7C
    	int time;                     // 0x7C-0x80
    	int duration;                 // 0x80-0x84
    	int text;                     // 0x84-0x88
    	float sort;                   // 0x88-0x8C
    	color_s glowColor;              // 0x8C-0x90
    	int fxBirthTime;              // 0x90-0x94
    	int fxLetterTime;             // 0x94-0x98
    	int fxDecayStartTime;         // 0x98-0x9C
    	int fxDecayDuration;          // 0x9C-0xA0
    	int soundID;                  // 0xA0-0xA4
    	int flags;                    // 0xA4-0xA8
    };
    
    struct game_hudelem_s
    {
    	hudelem_s elem;
    	long clientNum;
    	long team;
    	long archived;
    };

  2. #2
    __Xen0's Avatar
    Join Date
    Dec 2015
    Gender
    male
    Posts
    116
    Reputation
    14
    Thanks
    321
    My Mood
    Sneaky
    Quote Originally Posted by CamxxCore View Post
    If anyone can help me with this, I will appreciate it very much. I've been trying to get HUD elements working on the latest patch but haven't had much luck. Everything looks right to me, but I still can't get anything to actually show up in-game. If there is something clearly wrong with how I am doing this, please tell me. I'm using the exact same method that has been used on consoles to achieve the same result. I am new and still learning, so please go easy!

    Code:
    int GetMaterialIndex(const char* materialName)
    {
    	return ((int(__cdecl*)(const char*))0x54D620)(materialName);
    }
    
    int G_LocalizedStringIndex(const char* text)
    {
    	return ((int(__cdecl*)(const char*))0x54D490)(text);
    }
    
    game_hudelem_s* HudElemAlloc(int client, int teamNum)
    {
    	return ((game_hudelem_s*(__cdecl*)(int, int))0x5293E0)(client, teamNum);
    }
    
    void func()
    {
    	// spawn a hud element
    	game_hudelem_s* elem = HudElemAlloc(0, 0);
    	elem->clientNum = 0;
    	elem->elem.type = 1;
    	elem->elem.text = G_LocalizedStringIndex("Hello, world.");
    	elem->elem.font = 1;
    	elem->elem.fontScale = 10;
    	elem->elem.x = 250;
    	elem->elem.y = 100;
    	elem->elem.alignOrg = 1;
    	elem->elem.alignScreen = 6;
    	elem->elem.color.r = 255;
    	elem->elem.color.g = 255;
    	elem->elem.color.b = 255;
    	elem->elem.color.a = 255;
    	elem->elem.glowColor.r = 255;
    	elem->elem.glowColor.g = 255;
    	elem->elem.glowColor.b = 255;
    	elem->elem.glowColor.a = 255;
    
    	// nothing! :(
    }
    Code:
    union color_s
    {
    	struct
    	{
    		int8_t r;
    		int8_t g;
    		int8_t b;
    		int8_t a;
    	};
    	int32_t rgba;
    };
    
    struct hudelem_s
    {
    	int type;                     // 0x00-0x04
    	float y;                      // 0x04-0x08
    	float x;                      // 0x08-0x0C
    	float z;                      // 0x0C-0x10
    	int targetEntNum;             // 0x10-0x14
    	float fontScale;              // 0x14-0x18
    	float fromFontScale;          // 0x18-0x1C
    	int fontScaleStartTime;       // 0x1C-0x20
    	int fontScaleTime;            // 0x20-0x24
    	int label;                    // 0x24-0x28
    	int font;                     // 0x28-0x2C
    	int alignOrg;                 // 0x2C-0x30
    	int alignScreen;              // 0x30-0x34
    	color_s color;                  // 0x34-0x38
    	color_s fromColor;              // 0x38-0x3C
    	int fadeStartTime;            // 0x3C-0x40
    	int fadeTime;                 // 0x40-0x44
    	int height;                   // 0x44-0x48
    	int width;                    // 0x48-0x4C
    	int materialIndex;            // 0x4C-0x50
    	int fromHeight;               // 0x50-0x54
    	int fromWidth;                // 0x54-0x58
    	int scaleStartTime;           // 0x58-0x5C
    	int scaleTime;                // 0x5C-0x60
    	float fromY;                  // 0x60-0x64
    	float fromX;                  // 0x64-0x68
    	int fromAlignOrg;             // 0x68-0x6C
    	int fromAlignScreen;          // 0x6C-0x70
    	int moveStartTime;            // 0x70-0x74
    	int moveTime;                 // 0x74-0x78
    	float value;                  // 0x78-0x7C
    	int time;                     // 0x7C-0x80
    	int duration;                 // 0x80-0x84
    	int text;                     // 0x84-0x88
    	float sort;                   // 0x88-0x8C
    	color_s glowColor;              // 0x8C-0x90
    	int fxBirthTime;              // 0x90-0x94
    	int fxLetterTime;             // 0x94-0x98
    	int fxDecayStartTime;         // 0x98-0x9C
    	int fxDecayDuration;          // 0x9C-0xA0
    	int soundID;                  // 0xA0-0xA4
    	int flags;                    // 0xA4-0xA8
    };
    
    struct game_hudelem_s
    {
    	hudelem_s elem;
    	long clientNum;
    	long team;
    	long archived;
    };




    Good job on reversing that struct

    Here is what's missing:
    Code:
    game_hudelem_s* elem = HudElemAlloc(0, 3); //Specify the team for which it should be displayed 3 is spec
    elem->clientNum = IW4::cg->predictedPlayerState.clientNum; //Specify the clientNum of the player you want to display it at

Similar Threads

  1. [Solved] Why this hack always get DC when im use it. help TUT where did i get Wrong?
    By lhord in forum WarRock Philippines Help & Discussions
    Replies: 12
    Last Post: 12-14-2014, 10:32 AM
  2. What did I do wrong???
    By ltkort213 in forum WarRock - International Hacks
    Replies: 7
    Last Post: 06-11-2007, 09:50 AM
  3. Where did Elly go? I HAVE THE ANSWER
    By Dave84311 in forum General
    Replies: 21
    Last Post: 03-29-2007, 06:59 PM
  4. Where did debate fort go?
    By Calard in forum General
    Replies: 8
    Last Post: 12-18-2006, 07:08 PM
  5. Where did the old hax go
    By System79 in forum WarRock - International Hacks
    Replies: 8
    Last Post: 07-09-2006, 01:58 PM