SA-MP Forums Archive
Attaching text draw to vehicle - 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)
+--- Thread: Attaching text draw to vehicle (/showthread.php?tid=553028)



Attaching text draw to vehicle - maiky1499 - 27.12.2014

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


Re: Attaching text draw to vehicle - UltraScripter - 27.12.2014

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!



Re: Attaching text draw to vehicle - LetsOWN[PL] - 27.12.2014

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



Re: Attaching text draw to vehicle - maiky1499 - 27.12.2014

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


Re: Attaching text draw to vehicle - Pottus - 27.12.2014

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.


Re: Attaching text draw to vehicle - maiky1499 - 27.12.2014

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



Re: Attaching text draw to vehicle - maiky1499 - 28.12.2014

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.