Label problem
#1

Hi guys i got this code:

pawn Код:
for(new i = 0; i < MAX_VEHICLES; i++)
    {
    new Float:vx, Float:vy, Float:vz, Float:vHealth;
    GetVehicleHealth(vehicleid, vHealth);
    new vhp[128];
    new Text3D:V3D = Create3DTextLabel(vhp,COLOR_GREEN,vx,vy,vz, 50, 0,0);
    Attach3DTextLabelToVehicle(V3D,,vx, vy, vz+1.5);
    format(vhp, sizeof(vhp), "HP: %.0f", vHealth);
    }
Placed OnPlayerEnterVehicle,but i get this errors:

Код:
error 029: invalid expression, assumed zero
warning 215: expression has no effect
warning 215: expression has no effect
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

4 Errors.
That code is to show a textlabel on all vehicles with their HP,but seems don't work.
Reply
#2

Oops, one second.
Which lines are the errors??
Reply
#3

All that you see on code ^^
Reply
#4

pawn Код:
//on top of your gamemode (since i think you will be updating this per vehicle, so you need a variable for EVERY vehicle)
    new Text3D:V3D[MAX_VEHICLES];

    //the loop on gamemodeinit/filterscriptinit where ever you want it
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        new Float:vHealth;
        GetVehicleHealth(vehicleid, vHealth);
        new vhp[64];
        format(vhp, sizeof(vhp), "HP: %.0f", vHealth);//first formatting and THEN inserting it into a label
        V3D[i] = Create3DTextLabel(vhp,COLOR_GREEN,0,0,0,40,0,0);
        Attach3DTextLabelToVehicle(V3D[i],i,0,0,1.5);
    }
Please note that you only have to do this loop once, you can use Update3DTextLabelText to update the health status in a timer!
Reply
#5

Try this:

pawn Код:
for(new i = 0; i < MAX_VEHICLES; i++)
    {
        new Float:vHealth, vhp[128];
        GetVehicleHealth(vehicleid, vHealth);
        format(vhp, sizeof(vhp), "HP: %.0f", vHealth);
        new Text3D:V3D[32];
        V3D[playerid] = Create3DTextLabel(vhp,COLOR_GREEN,0.0,0.0,0.0, 50, 0,0);
        Attach3DTextLabelToVehicle(V3D[playerid],GetPlayerVehicleID(playerid),0.0, 0.0, 1.5);
    }
Or just go in game and type /dl .
Reply
#6

Thanks both,i edited the code to adapt it for my GM:

pawn Код:
for(new i = 0; i < MAX_VEHICLES; i++)
    {
     for(new playerid;playerid<MAX_PLAYERS;playerid++)
  {
        new Float:vHealth;
        new vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleHealth(vehicleid, vHealth);
        new vhp[64];
        format(vhp, sizeof(vhp), "HP: %.0f", vHealth);
        V3D[i] = Create3DTextLabel(vhp,COLOR_GREEN,0,0,0,40,0,0);
        Attach3DTextLabelToVehicle(V3D,i,0,0,1.5);
        }
    }
But i get this error:

error 035: argument type mismatch (argument 1)

Error line is

pawn Код:
Attach3DTextLabelToVehicle(V3D,i,0,0,1.5);
Thanks again!
Reply
#7

Attach3DTextLabelToVehicle(V3D,i,0,0,1.5)
to
Attach3DTextLabelToVehicle(V3D[i],i,0,0,1.5)
Reply
#8

LoL fixed but textlabel don't show,why?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)