21.02.2011, 20:17
OnVehicleSpawn isn't called when the vehicle is created.
It only gets called when the vehicle respawns after it has been used.
So, when you create the vehicle during OnGameModeInit, use this code to respawn it with the changed plate:
The check "if(vehicleid >= 0 && vehicleid <= 2000)" isn't needed as there can only be 2000 vehicles spawned.
Replace the values after "AddStaticVehicleEx" to some meaningfull values.
It only gets called when the vehicle respawns after it has been used.
So, when you create the vehicle during OnGameModeInit, use this code to respawn it with the changed plate:
pawn Код:
public OnGameModeInit()
{
// Create a new static vehicle during GameModeInit
new vehicleid = AddStaticVehicleEx(Model, X, Y, Z, Rotation, C1, C2, SpawnDelay);
new string[32];
new randnumb = 1000 + random(8999);
format(string, sizeof(string),"LS - %d",randnumb);
SetVehicleNumberPlate(vehicleid, string);
SetVehicleToRespawn(vehicleid);
}
Replace the values after "AddStaticVehicleEx" to some meaningfull values.