Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chaitanyathengdi opened this issue Nov 27, 2020 · 14 comments
Open

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

chaitanyathengdi opened this issue Nov 27, 2020 · 14 comments

Comments

@chaitanyathengdi
Copy link

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
Copy link
Author

@user-grinch Any idea about this?

@user-grinch
Copy link
Contributor

user-grinch commented Nov 29, 2020

image
Works for me

@chaitanyathengdi
Copy link
Author

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

@chaitanyathengdi
Copy link
Author

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

@ghost
Copy link

ghost commented Nov 30, 2020

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

@chaitanyathengdi
Copy link
Author

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
Copy link

ghost commented Nov 30, 2020

Yes, exactly.

@chaitanyathengdi
Copy link
Author

@MGRCreek No dice :(

@chaitanyathengdi
Copy link
Author

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

@ghost
Copy link

ghost commented Nov 30, 2020

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
Copy link
Author

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

@ghost
Copy link

ghost commented Nov 30, 2020

Glad to hear that!

@chaitanyathengdi
Copy link
Author

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

@Frouk3
Copy link

Frouk3 commented Jul 8, 2021

I guess you can make headshot accuracy aswell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants