how to attach 3d text label to all cars in my mode?
#8

With the method he is using, this would go in a command or wherever else you want to add the labels:
pawn Код:
new VehicleTextLabels[MAX_VEHICLES];
// under a command or something
for(new i; i < GetVehiclePoolSize(); i++) {
    if(IsValidVehicle(i)) {
         VehicleTextLabels[i] = CreateDynamic3DTextLabel("text goes here", 0xFFFFFFFF, 0.0, 0.0, 0.0, 30.0, .attachedvehicle = i);
    }
}
And then whenever a vehicle is despawned:
pawn Код:
DeleteDynamic3DTextLabel(VehicleTextLabels[vehicleid]);
This can surely be optimized, however this is just an example. For a more automatic approach to add a label to all vehicles or a certain type, you could consider using Extended Vehicle Functions where you could simply:

pawn Код:
public OnVehicleCreated(vehicleid)
{
    VehicleTextLabels[vehicleid] = CreateDynamic3DTextLabel("text goes here", 0xFFFFFFFF, 0.0, 0.0, 0.0, 30.0, .attachedvehicle = vehicleid);
    return 1;
}

public OnVehicleDestroyed(vehicleid)
{
    DeleteDynamic3DTextLabel(VehicleTextLabels[vehicleid]);
    VehicleTextLabels[vehicleid] = -1;
    return 1;
}
You could also go even further and only create labels for certain vehicle models, e.g:
pawn Код:
public OnVehicleCreated(vehicleid)
{
    if(GetVehicleModel(vehicleid) == 596)
    {
        VehicleTextLabels[vehicleid] = CreateDynamic3DTextLabel("text goes here", 0xFFFFFFFF, 0.0, 0.0, 0.0, 30.0, .attachedvehicle = vehicleid);
    }

    return 1;
}
The above code would only add a text label to LSPD cruisers.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)