textlabel problem
#1

Hi guys,i've added a textdraw to show at Hydra,Rhino,Hunter,Seasparrow a textlabel "War Vehicle",but this doesn't show.

pawn Код:
for ( new i; i < MAX_VEHICLES; i ++ )
  {
       switch ( GetVehicleModel( i ) )
       {
           case 432,447,520,425:
           {
               new vehicle_id;
               new Text3D: vehicle3Dtext;
               vehicle3Dtext = Create3DTextLabel( "War Vehicle", 0xFF0000AA, 0.0, 0.0, 0.0, 50.0, 0, 1 );
               Attach3DTextLabelToVehicle( vehicle3Dtext, vehicle_id, 0.0, 0.0, 2.0);
           }
       }
   }
I got no errors while compiling,what's wrong?
Reply
#2

pawn Код:
for ( new i; i < MAX_VEHICLES; i ++ )
  {
       switch ( GetVehicleModel( i ) )
       {
           case 432,447,520,425:
           {
               new Text3D: vehicle3Dtext;
               vehicle3Dtext = Create3DTextLabel( "War Vehicle", 0xFF0000AA, 0.0, 0.0, 0.0, 50.0, 0, 1 );
               Attach3DTextLabelToVehicle( vehicle3Dtext, i, 0.0, 0.0, 2.0);
           }
       }
   }
Since you are looping through all the vehicles, using "i" as your variable for vehicleid, just use "i" wherever you would normally use vehicle id. You didn't need to declare a new variable for that
Reply
#3

Quote:
Originally Posted by randomkid88
Посмотреть сообщение
[pawn]
Since you are looping through all the vehicles, using "i" as your variable for vehicleid, just use "i" wherever you would normally use vehicle id. You didn't need to declare a new variable for that
Same problem...
Reply
#4

BUMP.
Reply
#5

pawn Код:
new warvehicles[5]
new Text3D:vLabel[MAX_VEHICLES];

public OnGameModeInit()
{
    warvehicle[0] = CreateVehicle(.....);
    warvehicle[1] = CreateVehicle(.....);
    //same...........
    return 1;
}

public OnVehicleSpawn(vehicleid);
{
    if(warvehicle[0] == vehicleid)
    {
        vLabel = Create3DTextLabel( "War Vehicle", 0xFF0000AA, 0.0, 0.0, 0.0, 50.0, 0, 1 );
        Attach3DTextLabelToVehicle( vLabel , vehicleid, 0.0, 0.0, 2.0);
    }
    return 1;
}
As you can see i didnt finished the code and i suggest you to destroy vLabel on vehicle death co if you dont it will bug
Reply
#6

Thanks for your help but u dont get it...

I've loads of Hydra/Hunter/Rhino/Sea Sparrow,i cant define everytime the warvehicle,so i was finding a way to do it faster (in this case by the id of vehicle).

The code of randomkid88 is correct,but the textlabel doesn't show,so i need help to fix,thanks.
Reply
#7

Try This. I think you're creating the same textdraw and then attaching it to different vehicles, so its never on the same vehicle.

pawn Код:
//Outside of your function:
new Text3D: WarLabel[MAX_WAR_VEHICLES]; //You would have to count how many vehicles you have and define it,
//or you can use MAX_VEHICLES too.

for ( new i; i < MAX_VEHICLES; i ++ )
  {
       switch ( GetVehicleModel( i ) )
       {
           case 432,447,520,425:
           {
               WarLabel[i] = Create3DTextLabel( "War Vehicle", 0xFF0000AA, 0.0, 0.0, 0.0, 50.0, 0, 1 );
               Attach3DTextLabelToVehicle( WarLabel[i], i, 0.0, 0.0, 2.0);
           }
       }
   }
Reply
#8

error 017: undefined symbol "MAX_WAR_VEHICLES"
error 009: invalid array size (negative, zero or out of bounds)

Umh....
Reply
#9

Yeah, I said you'll have to define it. Just use MAX_VEHICLES, its easier. And actually, I don't know whats wrong with your original code. I tried it in my mode and it works just fine. Maybe change the color so you can see it better?
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)