help me please
#1

hello

i wanted to make textdraw to show you the heath i mad every thing and i made colors even but when i tested it the num of my health was 121323236 i don't know why i seted my health to 1 its changed to 5525633 i don't know why can you help me btw here is the code

pawn Код:
//Health Text Draw check
            if(IsPlayerConnected(i))
            {
                if(IsSpawned[i])
                {
                    new Float:phealth;
                    GetPlayerHealth(i,phealth);
                    if(phealth >=0 && phealth <= 30)
                    {
                        new Float:phealth1;
                        GetPlayerHealth(i,phealth1);
                        format(string,sizeof(string),"%d%",phealth1);
                        TextDrawSetString(HealthTD[i],string);
                        TextDrawColor(HealthTD[i],-16776961);
                    }
                    if(phealth >=70)
                    {
                        new Float:phealth1;
                        GetPlayerHealth(i,phealth1);
                        format(string,sizeof(string),"%d%",phealth1);
                        TextDrawSetString(HealthTD[i],string);
                        TextDrawColor(HealthTD[i],16711935);
                    }
                    if(phealth < 70 && phealth > 30)
                    {
                        new Float:phealth1;
                        GetPlayerHealth(i,phealth1);
                        format(string,sizeof(string),"%d%",phealth1);
                        TextDrawSetString(HealthTD[i],string);
                        TextDrawColor(HealthTD[i],-65281);
                    }
                }
            }
Reply
#2

Health is a float, you need to format it with "%f"
Reply
#3

%f or %s or %d
??
Reply
#4

new Floathealth; (See its float)

Use format(string,sizeof(string),"%f%",phealth1);
Reply
#5

Quote:
Originally Posted by TomatoRage
Посмотреть сообщение
%f or %s or %d
??
%f

Like this;
Код:
            if(IsPlayerConnected(i))
            {
                if(IsSpawned[i])
                {
                    new Float:phealth;
                    GetPlayerHealth(i,phealth);
                    if(phealth >=0 && phealth <= 30)
                    {
                        new Float:phealth1;
                        GetPlayerHealth(i,phealth1);
                        format(string,sizeof(string),"%f%",phealth1);
                        TextDrawSetString(HealthTD[i],string);
                        TextDrawColor(HealthTD[i],-16776961);
                    }
                    if(phealth >=70)
                    {
                        new Float:phealth1;
                        GetPlayerHealth(i,phealth1);
                        format(string,sizeof(string),"%f%",phealth1);
                        TextDrawSetString(HealthTD[i],string);
                        TextDrawColor(HealthTD[i],16711935);
                    }
                    if(phealth < 70 && phealth > 30)
                    {
                        new Float:phealth1;
                        GetPlayerHealth(i,phealth1);
                        format(string,sizeof(string),"%f%",phealth1);
                        TextDrawSetString(HealthTD[i],string);
                        TextDrawColor(HealthTD[i],-65281);
                    }
                }
            }
Reply
#6

thanks guys but i have another proplem its came 100.000000 i want 100.0
what can i do ??
Reply
#7

100.0 or 100.0000000 is the same both of them equals 100.
Reply
#8

Use "%.1f"
Reply
#9

Quote:
Originally Posted by TomatoRage
Посмотреть сообщение
thanks guys but i have another proplem its came 100.000000 i want 100.0
what can i do ??
It's the same thing but you can replace
Код:
%f
with

Код:
%.1f
Which will bring it down to 1 decimal place.
Reply
#10

Thanks Guys
+Rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)