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

hello
how can i attach 3d text label to all cars in my mode?
thanks
Reply
#2

1 3D Text Label for whole server vehicles?
Reply
#3

If you want to create a 3D Text Label for every vehicle you spawn, New SA-MP Callbacks provides an OnVehicleCreated callback where you can create the label for all vehicles spawned in. This requires that vehicles be spawned in through the gamemode (or whatever script the include is attached to), though.
Reply
#4

Quote:
Originally Posted by RyderX
Посмотреть сообщение
1 3D Text Label for whole server vehicles?
Yeah
Reply
#5

up :/
Reply
#6

Loop through all vehicles and use preferably a streamer (****** 'samp streamer plugin') and add a text label to them by attaching them to the vehicle:
Код:
native STREAMER_TAG_3D_TEXT_LABEL CreateDynamic3DTextLabel(const text[], color, Float:x, Float:y, Float:z, Float:drawdistance, attachedplayer = INVALID_PLAYER_ID, attachedvehicle = INVALID_VEHICLE_ID, testlos = 0, worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = STREAMER_3D_TEXT_LABEL_SD, STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1, priority = 0);
On .attachedvehicle you place the vehicle id. Also do this everytime you spawn a new car anywhere in the script. Do not forget to remove the 3D text label once you decide to somehow destroy/delete a vehicle. You cannot use only 1 3D Text Label creation to magically be on every single vehicle, as Abagail indirectly indicated above.
Reply
#7

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
Loop through all vehicles and use preferably a streamer (****** 'samp streamer plugin') and add a text label to them by attaching them to the vehicle:
Код:
native STREAMER_TAG_3D_TEXT_LABEL CreateDynamic3DTextLabel(const text[], color, Float:x, Float:y, Float:z, Float:drawdistance, attachedplayer = INVALID_PLAYER_ID, attachedvehicle = INVALID_VEHICLE_ID, testlos = 0, worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = STREAMER_3D_TEXT_LABEL_SD, STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1, priority = 0);
On .attachedvehicle you place the vehicle id. Also do this everytime you spawn a new car anywhere in the script. Do not forget to remove the 3D text label once you decide to somehow destroy/delete a vehicle. You cannot use only 1 3D Text Label creation to magically be on every single vehicle, as Abagail indirectly indicated above.
I didn't use pawn for around 3 years , I didn't understood what you said that well.
Can you send me the codes and explain me what every code does? thanks.
Reply
#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
#9

Quote:
Originally Posted by Abagail
Посмотреть сообщение
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.
thanks alot but i meant something else.
i need 1 text label for ALL of the cars in my mode , it gotta be simple xD
Reply
#10

Quote:
Originally Posted by WorldPro
Посмотреть сообщение
thanks alot but i meant something else.
i need 1 text label for ALL of the cars in my mode , it gotta be simple xD
Didn't know you were actually trying to do this. Simple answer is that you can't attach the same text label to more than one vehicle, that's not how text labels work. You have to create a text label for each vehicle you want to add one to. What you're asking is impossible to do, there's not really any reason I can think of that would require it be done this way anyway.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)