[0.3c] License Plate OnGameModeInit
#1

Ok, i want all vehicles to have the same license plate on startup, so i added this to OnGameModeInit:
Код:
for(new i = 0; i < MAX_VEHICLES; i++)
{
      SetVehicleNumberPlate(i, "plate");
      print("PLATES SET");
}
I added the "print("PLATES SET");" so that i know if its being called and it is.

I also tried adding a line to make them respawn but it didnt help, i also tried it under OnVehicleSpawn but that didnt help either, what can i do?
Reply
#2

You need to respawn the vehicles for them to take effect. Add SetVehicleToRespawn(i) after SetVehicleNumberPlate.

Another good place to set plates is under OnVehicleStreamIn.
Reply
#3

That is where you are wrong RandomKid. i have this in my GM after creating all the cars and it works like a charm, the correct thing i think you are talking about is for the player to see the effects it must stream out for atleast 3 seconds and then when it streams back in that player can see it, if it is changing them on the gamemodes entrance then it will work just fine. as for his questions, are you doing this after you are creating the cars, or before or in the middle of creation? if not after you create the vehicles then put it after

- [WF]Demon
Reply
#4

Crodox, you are actually wrong. When a vehicle streams out, it is destroyed on the player's system, and when it streams in, it is recreated with the saved parameters(model, license plate, etc), that's why it works after you stream in and out. If a vehicle never streams out for a player, the plate will never be put on. That's why you must use SetVehicleToRespawn.
Reply
#5

Tried this with no help:
Код:
	for(new i = 0; i < MAX_VEHICLES; i++)
	{
        SetVehicleNumberPlate(i, "PLATE");
        SetVehicleToRespawn(i);
        print("PLATE SET");
	}
Reply
#6

Quote:
Originally Posted by randomkid88
Посмотреть сообщение
You need to respawn the vehicles for them to take effect. Add SetVehicleToRespawn(i) after SetVehicleNumberPlate.

Another good place to set plates is under OnVehicleStreamIn.
Nevermind, this fixed it, Thank you
Reply
#7

W/E you think (sorry for this bump) but it works for me in OnGameModeInit w/o SetVehicleToRespawn, but whatever works for people it works for them, the way i do it it works for me so i use it.
Reply
#8

If you do it in OnGamemodeInit, do you do it like this?

pawn Код:
SetVehicleNumberPlate(CreateVehicle(...), "Plate");
Otherwise, the wiki says:
Quote:

Note: The vehicle must be respawned or restreamed for the changes to take effect.

Reply
#9

ReStreamed, OnGameModeInit is called when the gamemode loads, there will be no players connected at the time so it will work, look here is what i do

pawn Код:
//Create Vehicles Here
    for(new i; i < MAX_VEHICLES; i++)
    {
        if(IsVehicleConnected(i))
        {
            new randnumplate = random(sizeof(RandomPlates));
            SetVehicleNumberPlate(i, RandomPlates[randnumplate]);
        }
    }
since that works the wiki must be wrong
Reply
#10

Quote:
Originally Posted by randomkid88
Посмотреть сообщение
If you do it in OnGamemodeInit, do you do it like this?

pawn Код:
SetVehicleNumberPlate(CreateVehicle(...), "Plate");
Otherwise, the wiki says:
If you do it before the vehicles are created (in OnGameModeInit) then there is no need to respawn them, because they havent spawned and that first spawn will have the set plate.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)