Vehicle Health - 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: Vehicle Health (
/showthread.php?tid=486338)
Vehicle Health -
ScRipTeRi - 08.01.2014
hello i want to make vehicle health only for one vehicle with 3DTextLabelText and i have do it, but health say all time 0 here is my code
pawn Код:
public OnGameModeInit()
{
SetTimer("rhinoHP", 250, true);
return 1;
}
forward rhinoHP(playerid);
public rhinoHP(playerid)
{
new rstr[30];
new Float:health;
format(rstr, sizeof(rstr), "health: %.2f", GetVehicleHealth(432, health));
Update3DTextLabelText(vehicle3Dtext[ Rhino1 ], 0xFFFFFFAA, rstr);
}
Re: Vehicle Health -
Konstantinos - 08.01.2014
https://sampwiki.blast.hk/wiki/SetTimer
https://sampwiki.blast.hk/wiki/SetTimerEx
First of all, learn how to use timers with or without parameters. SetTimer does not have parameters, even though you used playerid for no reason. You also try to return the health directly but that way, it only returns 1 on success and 0 on failure (invalid vehicle ID). SA-MP Wiki also says: The vehicle's health is stored in the referenced variable, not in the return value - in your case health.
Re: Vehicle Health -
HardRock - 08.01.2014
PHP код:
public OnVehicleSpawn(vehicleid)
{
SetTimerEx("rhinoHP", 250, true, "i", vehicleid);
return 1;
}
forward rhinoHP(vehicleid);
public rhinoHP(vehicleid)
{
new rstr[30], Float:health;
if(GetVehicleModel(vehicleid) == 432)
{
format(rstr, sizeof(rstr), "health: %.2f", GetVehicleHealth(vehicleid, health));
Update3DTextLabelText(vehicle3Dtext[ Rhino1 ], 0xFFFFFFAA, rstr);
}
return 1;
}