help me with my code

0x73616D

Active member
Joined
Apr 18, 2021
Messages
135
Solutions
1
Reaction score
68
Location
0x73616D
What's wrong? The color should change but it doesn't.
C++:
            char piluluall[64] = { 0 };
            int pshow = (int)PEDSELF->GetHealth() + (int)PEDSELF->GetArmor();

            if ((int)pshow <= 30)
            {
                sprintf(piluluall, "%d", (int)pshow);
                pFont->Print(piluluall, D3DCOLOR_ARGB(0XFF, 255, 0, 0), 500, 400, false); // {FF0000} | R = 255 | G = 0 | B = 0 |
            }
            else if ((int)pshow > 30)
            {
                sprintf(piluluall, "%d", (int)pshow);
                pFont->Print(piluluall, D3DCOLOR_ARGB(0XFF, 255, 110, 0), 500, 400, false); // {FF6E00} | R = 255 | G = 110 | B = 0 |
            }
            else if ((int)pshow > 49)
            {
                sprintf(piluluall, "%d", (int)pshow);
                pFont->Print(piluluall, D3DCOLOR_ARGB(0XFF, 255, 180, 0), 500, 400, false); // {FFB400} | R = 255 | G = 180 | B = 0 |
            }
            else if ((int)pshow > 74)
            {
                sprintf(piluluall, "%d", (int)pshow);
                pFont->Print(piluluall, D3DCOLOR_ARGB(0XFF, 255, 255, 0), 500, 400, false); // {FFFF00} | R = 255 | G = 255 | B = 0 |
            }
            else if ((int)pshow > 99)
            {
                sprintf(piluluall, "%d", (int)pshow);
                pFont->Print(piluluall, D3DCOLOR_ARGB(0XFF, 150, 255, 0), 500, 400, false); // {96FF00} | R = 150 | G = 255 | B = 0 |
            }
            else if ((int)pshow > 124)
            {
                sprintf(piluluall, "%d", (int)pshow);
                pFont->Print(piluluall, D3DCOLOR_ARGB(0XFF, 0, 255, 0), 500, 400, false); // {00FF00} | R = 0 | G = 255 | B = 0 |
            }
            else if ((int)pshow > 149)
            {
                sprintf(piluluall, "%d", (int)pshow);
                pFont->Print(piluluall, D3DCOLOR_ARGB(0XFF, 0, 255, 255), 500, 400, false); // {00FFFF} | R = 0 | G = 255 | B = 255 |
            }
            else if ((int)pshow > 174)
            {
                sprintf(piluluall, "%d", (int)pshow);
                pFont->Print(piluluall, D3DCOLOR_ARGB(0XFF, 0, 0, 255), 500, 400, false); // {0000FF} | R = 0 | G = 0 | B = 255 |
            }
 

SobFoX

Expert
Joined
Jul 14, 2015
Messages
1,463
Solutions
5
Reaction score
916
Location
Israel
What's wrong? The color should change but it doesn't.
C++:
            char piluluall[64] = { 0 };
            int pshow = (int)PEDSELF->GetHealth() + (int)PEDSELF->GetArmor();

            if ((int)pshow <= 30)
            {
                sprintf(piluluall, "%d", (int)pshow);
                pFont->Print(piluluall, D3DCOLOR_ARGB(0XFF, 255, 0, 0), 500, 400, false); // {FF0000} | R = 255 | G = 0 | B = 0 |
            }
            else if ((int)pshow > 30)
            {
                sprintf(piluluall, "%d", (int)pshow);
                pFont->Print(piluluall, D3DCOLOR_ARGB(0XFF, 255, 110, 0), 500, 400, false); // {FF6E00} | R = 255 | G = 110 | B = 0 |
            }
            else if ((int)pshow > 49)
            {
                sprintf(piluluall, "%d", (int)pshow);
                pFont->Print(piluluall, D3DCOLOR_ARGB(0XFF, 255, 180, 0), 500, 400, false); // {FFB400} | R = 255 | G = 180 | B = 0 |
            }
            else if ((int)pshow > 74)
            {
                sprintf(piluluall, "%d", (int)pshow);
                pFont->Print(piluluall, D3DCOLOR_ARGB(0XFF, 255, 255, 0), 500, 400, false); // {FFFF00} | R = 255 | G = 255 | B = 0 |
            }
            else if ((int)pshow > 99)
            {
                sprintf(piluluall, "%d", (int)pshow);
                pFont->Print(piluluall, D3DCOLOR_ARGB(0XFF, 150, 255, 0), 500, 400, false); // {96FF00} | R = 150 | G = 255 | B = 0 |
            }
            else if ((int)pshow > 124)
            {
                sprintf(piluluall, "%d", (int)pshow);
                pFont->Print(piluluall, D3DCOLOR_ARGB(0XFF, 0, 255, 0), 500, 400, false); // {00FF00} | R = 0 | G = 255 | B = 0 |
            }
            else if ((int)pshow > 149)
            {
                sprintf(piluluall, "%d", (int)pshow);
                pFont->Print(piluluall, D3DCOLOR_ARGB(0XFF, 0, 255, 255), 500, 400, false); // {00FFFF} | R = 0 | G = 255 | B = 255 |
            }
            else if ((int)pshow > 174)
            {
                sprintf(piluluall, "%d", (int)pshow);
                pFont->Print(piluluall, D3DCOLOR_ARGB(0XFF, 0, 0, 255), 500, 400, false); // {0000FF} | R = 0 | G = 0 | B = 255 |
            }
First check that "IF" work for you properly
If you see that everyone is working properly and only color is the problem, then you have a problem in the way you come to the screen leaf (the same function)
 

0x73616D

Active member
Joined
Apr 18, 2021
Messages
135
Solutions
1
Reaction score
68
Location
0x73616D
First check that "IF" work for you properly
If you see that everyone is working properly and only color is the problem, then you have a problem in the way you come to the screen leaf (the same function)
the IF function works correctly, the code seems to make sense, I don't know what could be wrong
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
The logic is wrong, the order of conditions specifically. If the number is not higher than 30 (e.g. 29), then it can't be higher than any other number higher than 30, (29 isn't higher than 49, 76 etc...), so all conditions are never "true" under the " ((int)pshow > 30)" condition.
 

SobFoX

Expert
Joined
Jul 14, 2015
Messages
1,463
Solutions
5
Reaction score
916
Location
Israel
As I told you to check the "if" :X

The way you wrote the "if" is very logically cumbersome
 
Top