i do carhealth and do not see the textdraw
#4

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;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)