help me please - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: help me please (
/showthread.php?tid=436463)
help me please -
TomatoRage - 11.05.2013
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);
}
}
}
AW: help me please -
Nero_3D - 11.05.2013
Health is a float, you need to format it with "%f"
Re: help me please -
TomatoRage - 11.05.2013
%f or %s or %d
??
Re: help me please -
feartonyb - 11.05.2013
new Float

health; (See its float)
Use
format(string,sizeof(string),"%f%",phealth1);
Re: help me please -
Rillo - 11.05.2013
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);
}
}
}
Re: help me please -
TomatoRage - 11.05.2013
thanks guys but i have another proplem its came 100.000000 i want 100.0
what can i do ??
Re : help me please -
Rayan_black - 11.05.2013
100.0 or 100.0000000 is the same both of them equals 100.
AW: help me please -
Nero_3D - 11.05.2013
Use "%.1f"
Re: help me please -
Rillo - 11.05.2013
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
with
Which will bring it down to 1 decimal place.
Re: help me please -
TomatoRage - 11.05.2013
Thanks Guys
+Rep