PDA

View Full Version : help me please


TomatoRage
11/05/2013, 03:19 PM
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


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

Nero_3D
11/05/2013, 03:24 PM
Health is a float, you need to format it with "%f"

TomatoRage
11/05/2013, 03:29 PM
%f or %s or %d
??

feartonyb
11/05/2013, 03:31 PM
new Float:phealth; (See its float)

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

Rillo
11/05/2013, 03:31 PM
%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);
}
}
}

TomatoRage
11/05/2013, 03:33 PM
thanks guys but i have another proplem its came 100.000000 i want 100.0
what can i do ??

Rayan_black
11/05/2013, 03:53 PM
100.0 or 100.0000000 is the same both of them equals 100.

Nero_3D
11/05/2013, 03:56 PM
Use "%.1f"

Rillo
11/05/2013, 03:57 PM
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.

TomatoRage
11/05/2013, 04:00 PM
Thanks Guys
+Rep

feartonyb
11/05/2013, 04:03 PM
%.1f will bring one decimal spot. Change 1 to number of decimal spots that you want