PDA

View Full Version : Speedo State


wumpyc
25/07/2013, 05:05 AM
public SpeedoUpdate()
{
for(new i = 0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
new Float:x,Float:y,Float:z,Float:hp,string[24],vehicleid = GetPlayerVehicleID(i);
TextDrawShowForPlayer(i,box[i]);
TextDrawShowForPlayer(i,speed[i]);
TextDrawShowForPlayer(i,health[i]);
GetVehicleVelocity(vehicleid,x,y,z);
GetVehicleHealth(vehicleid,hp);
format(string,sizeof(string),"Speed: %dmph",floatround(floatsqroot(((x*x)+(y*y))+(z*z))*156.6 66667));
TextDrawSetString(speed[i],string);
format(string,sizeof(string),"Health: %d",floatround(hp));
TextDrawSetString(health[i],string);
}
if(!IsPlayerInAnyVehicle(i))
{
TextDrawHideForPlayer(i,box[i]);
TextDrawHideForPlayer(i,speed[i]);
TextDrawHideForPlayer(i,health[i]);
}
}
}

I would like Health to not in numbers, but for example 350 health would say=bad, 1000=perfect, <1000=good.. How would I do that? :confused:

Tayab
25/07/2013, 05:19 AM
Just use if, else if statements.

Example below.

public SpeedoUpdate()
{
for(new i = 0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
new Float:x,Float:y,Float:z,Float:hp,string[24],vehicleid = GetPlayerVehicleID(i);
TextDrawShowForPlayer(i,box[i]);
TextDrawShowForPlayer(i,speed[i]);
TextDrawShowForPlayer(i,health[i]);
GetVehicleVelocity(vehicleid,x,y,z);
GetVehicleHealth(vehicleid,hp);
format(string,sizeof(string),"Speed: %dmph",floatround(floatsqroot(((x*x)+(y*y))+(z*z))*156.6 66667));
TextDrawSetString(speed[i],string);
if(hp <= 350)
{
format(string,sizeof(string),"Health: %d - Bad",floatround(hp));
}
else if(hp < 1000)
{
format(string,sizeof(string),"Health: %d - Good",floatround(hp));
}
else if(hp == 1000)
{
format(string,sizeof(string),"Health: %d - Perfect",floatround(hp));
}
TextDrawSetString(health[i],string);
}
if(!IsPlayerInAnyVehicle(i))
{
TextDrawHideForPlayer(i,box[i]);
TextDrawHideForPlayer(i,speed[i]);
TextDrawHideForPlayer(i,health[i]);
}
}
}


Hope it helps, if not I am sorry. :|

wumpyc
25/07/2013, 06:15 AM
Works. Ty :)