Weird Vehicle Health Bug
#1



^ I don't get this, my vehicle health is supposed to be showing 1000/1000.
Here is my code:
pawn Код:
forward HealthTima(playerid);
public HealthTima(playerid)
{
    new engine, lights, alarm, doors, bonnet, boot, objective, string[64], Float:Health, vehicleid;
    vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleHealth(GetPlayerVehicleID(playerid), Health);
    GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
    if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) // Health TextDraw
    {
        if(Health < 30)
        {
            SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
            SendClientMessage(playerid, COLOR_LIME, "VEHICLE INFORMATION: Your vehicle has broken down, call a mechanic.");
            return 1;
        }
        TextDrawShowForPlayer(playerid, HealthTD[playerid]);
        format(string, sizeof(string), "~r~Health~w~: %d/1000", Health);
        TextDrawSetString(HealthTD[playerid], string);
    }
    else
    {
        TextDrawHideForPlayer(playerid, HealthTD[playerid]);
    }
    return 1;
}
I have a timer set up for it in OnGameModeInIt too
pawn Код:
SetTimer("HealthTima", 80, true); // Health TextDraw
Reply
#2

Happened to me when tried making /sethealth for an admin system. Just don't declare the Health variable as a Float. Hope this works

P.S. If that doesn't work replace %d in the formatted string with %f.
Reply
#3

Take away the Float variable.
Reply
#4

Quote:
Originally Posted by YoYo123
Посмотреть сообщение
Happened to me when tried making /sethealth for an admin system. Just don't declare the Health variable as a Float. Hope this works
Quote:
Originally Posted by Herald_Groove
Посмотреть сообщение
Take away the Float variable.
It should be float.
Quote:
Originally Posted by YoYo123
Посмотреть сообщение
P.S. If that doesn't work replace %d in the formatted string with %f.
This is the correct answer, however it'll show 1000.00000, so change it to the following for 1000/1000 (an example).
pawn Код:
format(string, sizeof(string), "~r~Health~w~: %.0f/1000", Health);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)