SA-MP Forums Archive
textlabel problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: textlabel problem (/showthread.php?tid=260716)



textlabel problem - Face9000 - 10.06.2011

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?


Re: textlabel problem - randomkid88 - 10.06.2011

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


Re: textlabel problem - Face9000 - 10.06.2011

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...


Re: textlabel problem - Face9000 - 11.06.2011

BUMP.


Re: textlabel problem - DRIFT_HUNTER - 11.06.2011

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


Re: textlabel problem - Face9000 - 11.06.2011

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.


Re: textlabel problem - randomkid88 - 11.06.2011

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



Re: textlabel problem - Face9000 - 11.06.2011

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

Umh....


Re: textlabel problem - randomkid88 - 11.06.2011

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?