Making vehicle plates random LS-%d
#7

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:
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);
}
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.
Reply


Messages In This Thread
Making vehicle plates random LS-%d - by Spiral - 19.02.2011, 17:16
Re: Making vehicle plates random LS-%d - by Hal - 19.02.2011, 17:25
Re: Making vehicle plates random LS-%d - by Hash [NL-RP] - 19.02.2011, 18:08
Re: Making vehicle plates random LS-%d - by jameskmonger - 19.02.2011, 18:20
Re: Making vehicle plates random LS-%d - by Hash [NL-RP] - 19.02.2011, 18:22
Re: Making vehicle plates random LS-%d - by thimo - 21.02.2011, 18:25
Re: Making vehicle plates random LS-%d - by PowerPC603 - 21.02.2011, 20:17
Re: Making vehicle plates random LS-%d - by speed258 - 08.07.2011, 19:33

Forum Jump:


Users browsing this thread: 2 Guest(s)