DK22Pac / plugin-sdk

An SDK for developing ASI/CLEO plugins for GTA San Andreas, GTA Vice City and GTA III
zlib License
427 stars 116 forks source link

CFont::SetColor doesn't work; causes text to disappear #103

Open chaitanyathengdi opened 3 years ago

chaitanyathengdi commented 3 years ago

Game: GTA San Andreas 1.0 (HOODLUM)

I'm using Cleo 4.4 as an ASI loader and have the following code to show the user's health:

        static CdeclEvent    <AddressList<0x53E293, H_CALL>, PRIORITY_AFTER,  ArgPickNone, void()> onDraw;
        onDraw.after += [] {
            static char myText[30];
            CFont::SetBackground(false, false);
            CFont::SetProportional(true);
            CFont::SetOrientation(ALIGN_CENTER);
            CFont::SetFontStyle(1);
            CFont::SetCentreSize(SCREEN_COORD_MAX_X);
            CFont::SetScale(SCREEN_MULTIPLIER(1.2f), SCREEN_MULTIPLIER(2.4f));
            /*CFont::SetColor(CRGBA(255, 255, 255, 255));*/
            CPlayerPed* pLocalPlayer = FindPlayerPed();
            float fHealth = pLocalPlayer ? pLocalPlayer->m_fHealth : 0.0f;
            float fmaxHealth = pLocalPlayer ? pLocalPlayer->m_fMaxHealth : 0.0f;
            sprintf(myText, "Health = %d%%", static_cast<int>((100 * fHealth)/fmaxHealth));
            float fX = SCREEN_COORD_MAX_X * 4 / 5;
            float fY = SCREEN_COORD_MAX_Y * 4 / 5;
            CFont::PrintString(fX, fY, myText);

        };

As you can see, line 10 is currently commented out. If I uncomment it, I can't see the string of the user's health percentage anymore.

Commented out: image

Uncommented: image

Why would this happen? I'm using CodeBlocks to build the ASI plugins.

chaitanyathengdi commented 3 years ago

@user-grinch Any idea about this?

user-grinch commented 3 years ago

image Works for me

chaitanyathengdi commented 3 years ago

Okay, still not working for me after fixing #104 :(

chaitanyathengdi commented 3 years ago

@DK22Pac Any way of setting color without using the CRGBA class? I'm thinking that is the issue, and I want to check.

ghost commented 3 years ago

You can set It as an integer number. Consider using hex notation. If you need white, for example, use 0xFFFFFFFF.

chaitanyathengdi commented 3 years ago

Ah okay, I did see a method that used an integer as input, but wasn't sure how I'd use it. I'll try that and report back. BTW, is it the way I'm imagining? the first six FF's for color and last two for alpha?

ghost commented 3 years ago

Yes, exactly.

chaitanyathengdi commented 3 years ago

@MGRCreek No dice :(

chaitanyathengdi commented 3 years ago

It's as if the color is transparent or something.

ghost commented 3 years ago

This is strange,,, Try to edit the content of the variable m_Color in CFont class. I don't think it will solve your problem, but you can try,

Replace your commented line with this *CFont::m_Color = CRGBA(255, 255, 255);

chaitanyathengdi commented 3 years ago

@MGRCreek Wouldn't you know it, that actually worked! image

ghost commented 3 years ago

Glad to hear that!

chaitanyathengdi commented 3 years ago

@MGRCreek Well, I'm going to keep the issue open regardless since it's still there - SetColor doesn't work.

Frouk3 commented 3 years ago

I guess you can make headshot accuracy aswell