SA-MP Forums Archive
Weird Vehicle Health Bug - 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: Weird Vehicle Health Bug (/showthread.php?tid=400144)



Weird Vehicle Health Bug - WinterAce - 17.12.2012



^ 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



Re: Weird Vehicle Health Bug - YoYo123 - 17.12.2012

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.


Re: Weird Vehicle Health Bug - Herald_Groove - 17.12.2012

Take away the Float variable.


Re: Weird Vehicle Health Bug - Konstantinos - 17.12.2012

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