SetVehicleNumberPlate
#1

Im making a cmd where players type /plate and then each new car they make it has that plate for only their car.
But its not working :/

And how can i add color to the plate?

pawn Код:
CMD:plate(playerid,params[])
{
    for(new Vehicles = 1; Vehicles < MAX_VEHICLES; Vehicles++)
    {
    new string[30];
    format(string, sizeof(string),"%d", Vehicles);
    SetVehicleNumberPlate(playerid, string);
    }
    return 1;
    }
and it wont spawn with the cars when server starts only when i respawn cars

pawn Код:
for(new Vehicles = 0; Vehicles < MAX_VEHICLES; Vehicles++)
    {
    new string[30];
    for(new Vehicles = 0; Vehicles < MAX_VEHICLES; Vehicles++)
    format(string, sizeof(string),"{ff00ff}SnG-Fun", Vehicles);
    SetVehicleNumberPlate(Vehicles,string);
    }
Reply
#2

I don't know if I understand you correctly.

You want to write a command "/plate" which can be used to change the text of the number plate?
Reply
#3

Yes. When the player types /plate any new vehicle they spawn it will add that plate to their vehicle
Reply
#4

You could write the current string to a PVar or an array.

Quick 'n Dirty code:
Код:
CMD:plate(playerid, params[])
{
	if (strlen(params))
	{
		SetPVarString(playerid, "PlateText", params);
	}
	else
	{
		SendClientMessage(playerid, 0xA00000AA, "Usage: /plate <Your Text>");
	}
	return true;
}
And if you create the vehicle using CreateVehicle you could set the plate text to the text of the PVar.

Quick 'n Dirty code:
Код:
new plateText[32];
new vehicleID = CreateVehicle(modelID, posX, posY, posZ, angle, color1, color2, respawnDelay);
GetPVarString(playerID, "PlateText", plateText, sizeof(plateText));
SetVehicleNumberPlate(vehicleID, plateText);
WARNING: Untested code! I just want to show you the way I would do it.
Reply
#5

How can i make all cars spawn with the same plate when server starts? I tried adding it to OngameModeInit but it wont change the plates
Reply
#6

Код:
	SetVehicleNumberPlate(AddStaticVehicle(523,-1591.30004883,706.59997559,-5.59999990,274.00000000,252,1), "HPV P02"); //HPV1000
	SetVehicleNumberPlate(AddStaticVehicle(523,-1591.09997559,707.59997559,-5.59999990,273.99902344,252,1), "HPV P03"); //HPV1000
The plates are "HPV P02" & "HPV P03"
Just add before "AddStaticVehicle" -> SetVehicleNumberPlate(
And AFTER -> , "YOUR PLATE (MAX 32 CAR)");
Reply
#7

pawn Код:
.....
Reply
#8

i used this code
pawn Код:
for(new Vehicles = 0; Vehicles < MAX_VEHICLES; Vehicles++)
    {
    new string[30];
    for(new Vehicles = 0; Vehicles < MAX_VEHICLES; Vehicles++)
    format(string, sizeof(string),"{ff00ff}SnG-Fun", Vehicles);
    SetVehicleNumberPlate(Vehicles,string);
    }
that used to work but now it doesnt. I dont under stand why you have different codes.
Reply
#9

That should work (untested!):
pawn Код:
for (new vehicleID = 0; vehicleID < MAX_VEHICLES; vehicleID++)
{
    new string[30];
    format(string, sizeof(string), "{ff00ff}SnG-Fun %d", vehicleID);
    SetVehicleNumberPlate(vehicleID, string);
}
Reply
#10

You have to respawn vehicles after setting the numberplate, or set it straight after creation.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)