Attaching text draw to vehicle
#1

Basically I want a command like /vehiclead [text] while in a vehicle, will create a textdraw and attach it to the rear of the vehicle...
Reply
#2

pawn Код:
new car;
new Text3D:draw;
car = CreateVehicle(411, x, y, z, a, -1, -1, -1); //the car
Create3DTextLabel("yourtext", 0x00FF00FF, x, y, z, 40, 0, 0); //adding textlabel
Attach3DTextLabelToVehicle(car, draw); //attaching text label to vehicle!
Reply
#3

Quote:
Originally Posted by maiky1499
Посмотреть сообщение
Basically I want a command like /vehiclead [text] while in a vehicle, will create a textdraw and attach it to the rear of the vehicle...
Hello maiky,
You can not attach textdraw to vehicle (or to anything else).

However, you can attach 3D Text Label. Here you go:
SAMP Wiki: Attach3DTextLabelToVehicle

Now it is just the matter of finding the right offsets.

Greetings.

Edit:
UltraScripter was quicker, stick to his solution
Reply
#4

Thanks, helps alot. Just how I destroy it on vehicle respawn, "OnVehicleSpawn" lines...
Reply
#5

Pretty easy to do this just make an enum to store all your vehicle data you can use variables but I prefer it this way because it keeps your data grouped and makes it easy to add more if you need to.


// enum variable example
pawn Код:
enum VINFO
{
    Text3D:v_Text, // Text label
    v_OwnerID, // OwnerID of the vehicle
    bool:v_Used // Marks if used
}

new VehicleData[MAX_VEHICLES][VINFO];
pawn Код:
// Destroy vehicle when player disconnects
public OnPlayerDisconnect(playerid, reason)
{
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        if(VehicleData[i][v_Used] && VehicleData[i][v_OwnerID] == playerid)
        {
            DestroyVehicle(i);
            Delete3DTextLabel(VehicleData[i][v_OwnerID]);
            VehicleData[i][v_OwnerID] = false;
        }
    }
}
pawn Код:
// Add a new vehicle also creates and attaches 3D Text label.
AddVehicle(ownerid, modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay, Float:offsetx, Float:offsety, Float:offsetz, text[], color, virtualworld = 0, Float:DrawDistance = 100.0, testLOS, = 1)
{
    vid = CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay);
    if(vid == INVALID_VEHICLE_ID) return INVALID_VEHICLE_ID;
    VehicleData[vid][v_OwnerID] = ownerid;
    VehicleData[vid][v_Used] = true;
    VehicleData[vid][v_Text] = Create3DTextLabel(text, color, 0.0, 0.0, 0.0, DrawDistance, virtualworld, testLOS);
    Attach3DTextLabelToVehicle(VehicleData[vid][v_Text], vid, offsetx, offsety, offsetz);
    return vid;
}
That should give you an idea of what to do.
Reply
#6

Kinda lost you back there;
I have this
Код:
format(string, sizeof(string), "%s", params);
VehSign[veh] = 1;
vcallsign[veh] = Create3DTextLabel(string, COLOR_WHITE, 0, 0, 0, 10, 0, 0); //adding textlabel
Attach3DTextLabelToVehicle(vcallsign[veh], veh, -0.5, -2.8, 0); //attaching text label to vehicle!
All of that works pretty well, now what I want to do is to remove the 3DText when the vehicle spawns again (respawns or destroy).

I tried this:
Код:
OnVehicleSpawn
if(VehSign[vehicleid])
{
Delete3DTextLabel(vcallsign[vehicleid]);
}
Reply
#7

Quote:
Originally Posted by maiky1499
Посмотреть сообщение
Kinda lost you back there;
I have this
Код:
format(string, sizeof(string), "%s", params);
VehSign[veh] = 1;
vcallsign[veh] = Create3DTextLabel(string, COLOR_WHITE, 0, 0, 0, 10, 0, 0); //adding textlabel
Attach3DTextLabelToVehicle(vcallsign[veh], veh, -0.5, -2.8, 0); //attaching text label to vehicle!
All of that works pretty well, now what I want to do is to remove the 3DText when the vehicle spawns again (respawns or destroy).

I tried this:
Код:
OnVehicleSpawn
if(VehSign[vehicleid])
{
Delete3DTextLabel(vcallsign[vehicleid]);
}
...BUMPED.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)