CFont::SetColor doesn't work; causes text to disappear
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:

Uncommented:

Why would this happen? I'm using CodeBlocks to build the ASI plugins.
@user-grinch Any idea about this?
Works for me
Okay, still not working for me after fixing #104 :(
@DK22Pac Any way of setting color without using the CRGBA class?
I'm thinking that is the issue, and I want to check.
You can set It as an integer number. Consider using hex notation. If you need white, for example, use 0xFFFFFFFF.
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?
Yes, exactly.
@MGRCreek No dice :(
It's as if the color is transparent or something.
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);
@MGRCreek Wouldn't you know it, that actually worked!

Glad to hear that!
@MGRCreek Well, I'm going to keep the issue open regardless since it's still there - SetColor doesn't work.
I guess you can make headshot accuracy aswell