Speedo State
#1

Код:
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.666667));
			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?
Reply
#2

Just use if, else if statements.

Example below.
pawn Код:
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.666667));
            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.
Reply
#3

Works. Ty
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)