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;
};