29.01.2017, 20:27
With the method he is using, this would go in a command or wherever else you want to add the labels:
And then whenever a vehicle is despawned:
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:
You could also go even further and only create labels for certain vehicle models, e.g:
The above code would only add a text label to LSPD cruisers.
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);
}
}
pawn Код:
DeleteDynamic3DTextLabel(VehicleTextLabels[vehicleid]);
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;
}
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;
}