i do carhealth and do not see the textdraw -
Xeinss - 15.05.2014
codes:
http://pastebin.com/ZpYsagMf
Thanks for helpers
Re: i do carhealth and do not see the textdraw -
Konstantinos - 15.05.2014
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 Код:
format(String, 250,"%.2f",GetVehicleHealth(car, health));
the function will return either 1 (on success) or 0 (on failure).
pawn Код:
new Float: health, car = GetPlayerVehicleID(playerid), szText[10];
if (car)
{
GetVehicleHealth(car, health);
format(szText, sizeof (szText), "%.2f", health);
}
Also use per-player textdraws if you want to show a textdraw for each player who is in vehicle and all you need to do is create the textdraw once on connect and show it when the player enters the vehicle/hide it when the player exits the vehicle. You don't have to destroy and re-create it over and over again.
Re: i do carhealth and do not see the textdraw -
Xeinss - 15.05.2014
Quote:
Originally Posted by Konstantinos
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 Код:
format(String, 250,"%.2f",GetVehicleHealth(car, health));
the function will return either 1 (on success) or 0 (on failure).
pawn Код:
new Float: health, car = GetPlayerVehicleID(playerid), szText[10];
if (car) { GetVehicleHealth(car, health); format(szText, sizeof (szText), "%.2f", health); }
Also use per-player textdraws if you want to show a textdraw for each player who is in vehicle and all you need to do is create the textdraw once on connect and show it when the player enters the vehicle/hide it when the player exits the vehicle. You don't have to destroy and re-create it over and over again.
|
I did not understand
Re: i do carhealth and do not see the textdraw -
Konstantinos - 15.05.2014
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 Код:
// 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;
}
Re: i do carhealth and do not see the textdraw -
Xeinss - 15.05.2014
Quote:
Originally Posted by Konstantinos
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 Код:
// 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; }
|
ty
i try to do kill timer and i get this warning
warning 213: tag mismatch
the line is KillTimer(PlayerTD_Vehicle[playerid]);
Re: i do carhealth and do not see the textdraw -
Konstantinos - 15.05.2014
Don't do that! It's not a timer, it's per-player textdraws and they get destroyed automatically when a player disconnects.
Re: i do carhealth and do not see the textdraw -
Xeinss - 16.05.2014
Quote:
Originally Posted by Konstantinos
Don't do that! It's not a timer, it's per-player textdraws and they get destroyed automatically when a player disconnects.
|
but if i crashed on the wall i see 1000.00 and if i exit and enter i see the real health of the car.
Re: i do carhealth and do not see the textdraw -
Konstantinos - 16.05.2014
I posted an example of per-player textdraws and how you should do that (showing/hiding the textdraw). You need to use a timer for displaying the current vehicle's health.
Re: i do carhealth and do not see the textdraw -
Xeinss - 16.05.2014
i think do timer if the life is not life of 1sec before do hide and show the textdraw i think good?