Attaching text draw to vehicle
#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


Messages In This Thread
Attaching text draw to vehicle - by maiky1499 - 27.12.2014, 19:48
Re: Attaching text draw to vehicle - by UltraScripter - 27.12.2014, 20:03
Re: Attaching text draw to vehicle - by LetsOWN[PL] - 27.12.2014, 20:06
Re: Attaching text draw to vehicle - by maiky1499 - 27.12.2014, 21:30
Re: Attaching text draw to vehicle - by Pottus - 27.12.2014, 21:54
Re: Attaching text draw to vehicle - by maiky1499 - 27.12.2014, 22:21
Re: Attaching text draw to vehicle - by maiky1499 - 28.12.2014, 23:06

Forum Jump:


Users browsing this thread: 1 Guest(s)