plugin-sdk icon indicating copy to clipboard operation
plugin-sdk copied to clipboard

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

Open chaitanyathengdi opened this issue 5 years ago • 14 comments

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 avatar Nov 27 '20 18:11 chaitanyathengdi

@user-grinch Any idea about this?

chaitanyathengdi avatar Nov 29 '20 16:11 chaitanyathengdi

image Works for me

user-grinch avatar Nov 29 '20 17:11 user-grinch

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

chaitanyathengdi avatar Nov 29 '20 17:11 chaitanyathengdi

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

chaitanyathengdi avatar Nov 30 '20 06:11 chaitanyathengdi

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

ghost avatar Nov 30 '20 08:11 ghost

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?

chaitanyathengdi avatar Nov 30 '20 10:11 chaitanyathengdi

Yes, exactly.

ghost avatar Nov 30 '20 12:11 ghost

@MGRCreek No dice :(

chaitanyathengdi avatar Nov 30 '20 19:11 chaitanyathengdi

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

chaitanyathengdi avatar Nov 30 '20 19:11 chaitanyathengdi

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

ghost avatar Nov 30 '20 19:11 ghost

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

chaitanyathengdi avatar Nov 30 '20 20:11 chaitanyathengdi

Glad to hear that!

ghost avatar Nov 30 '20 20:11 ghost

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

chaitanyathengdi avatar Nov 30 '20 21:11 chaitanyathengdi

I guess you can make headshot accuracy aswell

Frouk3 avatar Jul 08 '21 08:07 Frouk3