THREAD: [1.16/C++] HudElements [SPRX]
  1. 03-04-2015, 01:05 PM
    214
    Posts
    12,613
    Reputation
    Mar 2014
    NextGenUpdate
    Hey NGU, Here are Ghosts 1.16 HudElements for c++/sprx enjoy!


    #define TOC 0xA7F3C8
    struct opd_s
    {
    uint32_t sub;
    uint32_t toc;
    };


    HudElements:

    typedef unsigned char byte;
    typedef unsigned int uint;
    typedef unsigned long long QWORD;
    #define G_LocalizeStringIndex(Text) ((int(*)(const char*))&ParseAddr(0x3434Cool Man (aka Tustin))(Text)
    #define G_MaterialIndex(Text) ((int(*)(const char*))&ParseAddr(0x32334))(Text)
    #define Leveltime *(int*)(0xDB5D04 + 0x540)
    union color_s
    {
    struct
    {
    byte r, g, b, a;
    };
    uint rgba;
    };

    struct hudelem_s
    {
    int type;
    float x;
    float y;
    float z;
    int targetEntNum;
    float fontScale;
    float fromFontScale;
    float fontScaleStartTime;
    float fontScaleTime;
    int font;
    int alignOrg;
    int alignScreen;
    color_s color;
    color_s fromColor;
    int fadeStartTime;
    int fadeTime;
    int label;
    int width;
    int height;
    int materialIndex;
    int fromWidth;
    int fromHeight;
    int scaleStartTime;
    int scaleTime;
    float fromX;
    float fromY;
    int fromAlignOrg;
    int fromAlignScreen;
    int moveStartTime;
    int moveTime;
    int time;
    int duration;
    float value;
    int text;
    float sort;
    color_s glowColor;
    int fxBirthTime;
    int fxLetterTime;
    int fxDecayStartTime;
    int fxDecayDuration;
    int soundID;
    int flags;
    };

    struct game_hudelem_s
    {
    hudelem_s elem;
    int clientNum;
    int team;
    int archived;
    int currentShowInKillcam;
    };

    struct Hud
    {
    Hud(game_hudelem_s* Element);
    game_hudelem_s* PrecacheElem(int ClientID);
    void setText(char* Text, int font, float fontScale, float x, float y, int alignOrg, int alignScreen, float sort = 1, byte r = 255, byte g = 255, byte b = 255, byte a = 255);
    void setShader(char* Shader, float x, float y, int width, int height, int alignOrg, int alignScreen, float sort = 0, byte r = 255, byte g = 255, byte b = 255, byte a = 255);
    void ScaleOverTime(int time, float width, float height);
    void setColor(byte r = 255, byte g = 255, byte b = 255, byte a = 255, bool IsGlow = false);
    void moveOverTime(float time);
    void ChangeText(char* Option);
    void ChangeMaterial(char* Text);
    void MoveOverTime(char* axis, float calc, float time);
    void ChangeFontScaleOverTime(int Time, float Scale);
    void FadeOverTime(int time, byte red, byte green, byte blue, byte alpha);
    void TypeWriterText(char* Text, float YPos = 90, float FontScale = 2);
    game_hudelem_s* Element;
    };

    game_hudelem_s* HudElem_Alloc(int Client, int Team = 0)
    {
    game_hudelem_s* Temp = (game_hudelem_s*)0xD87C88;
    for(int i = 0; i < 0x400; i++)
    {
    if(Temp->elem.type == 0)
    break;
    Temp = (game_hudelem_s*)(0xD87C88 + (i* sizeof(game_hudelem_s)));
    if(i >= 0x3FF)
    return 0;
    }
    ((void(*)(game_hudelem_s*))&ParseAddr(0x2456DCool Man (aka Tustin))(Temp); //HudElem_SetDefaults
    Temp->team = Team;
    Temp->clientNum = Client == -1 ? 0x7FF : Client;
    Temp->archived = true;
    return Temp;
    }

    Hud::Hud(game_hudelem_s* elem)
    {
    Element = elem;
    }

    game_hudelem_s* PrecacheElem(int ClientID)
    {
    return HudElem_Alloc(ClientID);
    }

    void Hud::setText(char* Text, int font, float fontScale, float x, float y, int alignOrg, int alignScreen, float sort, byte r , byte g, byte b, byte a)
    {
    Element->elem.type = 0x1;
    Element->elem.alignOrg = alignOrg;
    Element->elem.alignScreen = alignScreen;
    Element->elem.font = font;
    Element->elem.fontScale = fontScale;
    Element->elem.x = x;
    Element->elem.y = y;
    Element->elem.color.r = r;
    Element->elem.color.g = g;
    Element->elem.color.b = b;
    Element->elem.color.a = a;
    Element->elem.sort = sort;
    Element->elem.text = G_LocalizeStringIndex(Text);
    }

    void Hud::setShader(char* Shader, float x, float y, int width, int height, int alignOrg, int alignScreen, float sort, byte r, byte g, byte b, byte a)
    {
    Element->elem.type = 0x4;
    Element->elem.alignOrg = alignOrg;
    Element->elem.alignScreen = alignScreen;
    Element->elem.x = x;
    Element->elem.y = y;
    Element->elem.color.r = r;
    Element->elem.color.g = g;
    Element->elem.color.b = b;
    Element->elem.color.a = a;
    Element->elem.width = width;
    Element->elem.height = height;
    Element->elem.sort = sort;
    Element->elem.materialIndex = G_MaterialIndex(Shader);
    }

    void Hud::ScaleOverTime(int time, float width, float height)
    {
    Element->elem.fromHeight = Element->elem.height;
    Element->elem.fromWidth = Element->elem.width;
    Element->elem.scaleStartTime = Leveltime;
    Element->elem.scaleTime = time;
    Element->elem.height = height;
    Element->elem.width = width;
    }

    void Hud::setColor(byte r, byte g, byte b, byte a, bool IsGlow)
    {
    if(IsGlow){
    Element->elem.glowColor.r = r;
    Element->elem.glowColor.g = g;
    Element->elem.glowColor.b = b;
    Element->elem.glowColor.a = a;
    }else{
    Element->elem.color.r = r;
    Element->elem.color.g = g;
    Element->elem.color.b = b;
    Element->elem.color.a = a;
    }
    }

    void Hud::moveOverTime(float time)
    {
    Element->elem.fromAlignOrg = Element->elem.alignOrg;
    Element->elem.fromAlignScreen = Element->elem.alignScreen;
    Element->elem.fromX = Element->elem.x;
    Element->elem.fromY = Element->elem.y;
    Element->elem.moveStartTime = Leveltime;
    Element->elem.moveTime = time;
    }

    void Hud::MoveOverTime(char* axis, float calc, float time)
    {
    moveOverTime(time);
    !strcmp(axis, "X") ? Element->elem.x = calc : Element->elem.y = calc;
    }

    void Hud::ChangeText(char* Text)
    {
    Element->elem.text = G_LocalizeStringIndex(Text);
    }

    void Hud::ChangeMaterial(char* Text)
    {
    Element->elem.materialIndex = G_MaterialIndex(Text);
    }

    void Hud::ChangeFontScaleOverTime(int Time, float Scale)
    {
    Element->elem.fromFontScale = Element->elem.fontScale;
    Element->elem.fontScaleStartTime = Leveltime;
    Element->elem.fontScaleTime = Time;
    Element->elem.fontScale = Scale;
    }

    void Hud::FadeOverTime(int time, byte red, byte green, byte blue, byte alpha)
    {
    Element->elem.fromColor = Element->elem.color;
    Element->elem.fadeStartTime = Leveltime;
    Element->elem.fadeTime = time;
    Element->elem.color.r = red;
    Element->elem.color.g = green;
    Element->elem.color.b = blue;
    Element->elem.color.a = alpha;
    }

    void Hud::TypeWriterText(char* Text, float YPos, float FontScale)
    {
    Hud(Element).setText(Text, 3, FontScale, 320, YPos, 0x5, 0x1, 1);
    Hud(Element).setColor(128, 0, 128, 255, true);
    Element->elem.fxBirthTime = Leveltime;
    Element->elem.fxLetterTime = 100;
    Element->elem.fxDecayStartTime = 7000;
    Element->elem.fxDecayDuration = 1000;
    Element->elem.flags |= 0x4;
    }


    How To Use:

    game_hudelem_s* ExampleShader[12];
    game_hudelem_s* ExampleText[12];

    void StoreHuds(int client)
    {
    WriteByte(0x34348 + 0x48, 0x41);
    ExampleShader[client] = PrecacheElem(client);
    ExampleText[client] = PrecacheElem(client);
    Hud(ExampleShader[client]).setShader("white", 220, 0, 200, 600, 0, 0, 0, 0, 0, 0, 180);
    Hud(ExampleText[client]).setText("Example", 1, 2, 250, 50, 5, 0, 0, 255, 255, 255, 255);
    }


    Credits:

    Xx jAmes t xX - HudElem_Alloc
    Maybe Ethernet
    Last edited by oStankyModz ; 03-04-2015 at 08:24 PM.

  2. 03-04-2015, 05:26 PM
    ItzMatriix's Avatar
    ItzMatriix
    Are you high?
    ItzMatriix's Avatar
    ItzMatriix
    Are you high?
    425
    Posts
    1,340
    Reputation
    Dec 2012
    NextGenUpdate
    when i put this into a SPRX it says "byte" is undefined identifier? what needs to happen?
  3. 03-04-2015, 07:48 PM
    214
    Posts
    12,613
    Reputation
    Mar 2014
    NextGenUpdate
    add this above your huds:
    typedef unsigned char byte;
    typedef unsigned int uint;
    typedef unsigned long long QWORD;
  4. 03-04-2015, 09:30 PM
    ItzMatriix's Avatar
    ItzMatriix
    Are you high?
    ItzMatriix's Avatar
    ItzMatriix
    Are you high?
    425
    Posts
    1,340
    Reputation
    Dec 2012
    NextGenUpdate
    Originally Posted by oStankyModz View Post
    add this above your huds:
    typedef unsigned char byte;
    typedef unsigned int uint;
    typedef unsigned long long QWORD;


    thanks!
  5. 04-13-2016, 12:11 AM
    ItzMatriix's Avatar
    ItzMatriix
    Are you high?
    ItzMatriix's Avatar
    ItzMatriix
    Are you high?
    425
    Posts
    1,340
    Reputation
    Dec 2012
    NextGenUpdate
    someone convert this to C# for tools
  6. 07-08-2018, 03:41 PM
    29
    Posts
    -21
    Reputation
    Oct 2015
    NextGenUpdate
    Text does not work