15.05.2014, 10:48
codes:http://pastebin.com/ZpYsagMf
Thanks for helpers
Thanks for helpers
format(String, 250,"%.2f",GetVehicleHealth(car, health));
new Float: health, car = GetPlayerVehicleID(playerid), szText[10];
if (car)
{
GetVehicleHealth(car, health);
format(szText, sizeof (szText), "%.2f", health);
}
https://sampwiki.blast.hk/wiki/GetVehicleHealth
The vehicle's health is stored to the variable "health" and that is what you need to use as argument. By doing this (which is incorrect): pawn Код:
pawn Код:
|
// global:
new PlayerText: PlayerTD_Vehicle[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
PlayerTD_Vehicle[playerid] = CreatePlayerTextDraw(playerid, 491.000000, 322.000000, "0.0");
PlayerTextDrawBackgroundColor(playerid, PlayerTD_Vehicle[playerid], 255);
PlayerTextDrawFont(playerid, PlayerTD_Vehicle[playerid], 2);
PlayerTextDrawLetterSize(playerid, PlayerTD_Vehicle[playerid], 0.500000, 1.000000);
PlayerTextDrawColor(playerid, PlayerTD_Vehicle[playerid], 1367916799);
PlayerTextDrawSetOutline(playerid, PlayerTD_Vehicle[playerid], 0);
PlayerTextDrawSetProportional(playerid, PlayerTD_Vehicle[playerid], 1);
PlayerTextDrawSetShadow(playerid, PlayerTD_Vehicle[playerid], 1);
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new Float: health, szText[10];
GetVehicleHealth(vehicleid, health);
format(szText, sizeof (szText), "%.2f", health);
PlayerTextDrawSetString(playerid, PlayerTD_Vehicle[playerid], szText);
PlayerTextDrawShow(playerid, PlayerTD_Vehicle[playerid]);
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
PlayerTextDrawHide(playerid, PlayerTD_Vehicle[playerid]);
return 1;
}
You re-create the textdraw over and over again when you can just create it once and show/hide it when the player enters/exits the vehicle. It has to be as per-player textdraw because the vehicle's health to display to each player is different.
pawn Код:
|