Making vehicle plates random LS-%d - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Making vehicle plates random LS-%d (
/showthread.php?tid=228436)
Making vehicle plates random LS-%d -
Spiral - 19.02.2011
Hey so I need a code which sets every car's license plate to LS-%d, %d is the number between 1000 and 9999, any help?
Re: Making vehicle plates random LS-%d -
Hal - 19.02.2011
https://sampwiki.blast.hk/wiki/Random read the example the wiki gives, it isnt hard at all to make.
Re: Making vehicle plates random LS-%d -
Hash [NL-RP] - 19.02.2011
Код:
public OnVehicleSpawn(vehicleid)
{
new string[32];
if(vehicleid >= 0 && vehicleid <= 2000)
{
new randnumb = 1000 + random(9999);
format(string, sizeof(string),"LS - %d",randnumb);
SetVehicleNumberPlate(vehicleid, string);
SetVehicleToRespawn(vehicleid);
}
}
It should work, if it don't respawn all the cars when you start the server.
Re: Making vehicle plates random LS-%d -
jameskmonger - 19.02.2011
Hash, fixed:
pawn Код:
public OnVehicleSpawn(vehicleid)
{
new string[32];
if(vehicleid >= 0 && vehicleid <= 2000)
{
new randnumb = 1000 + random(8999);
format(string, sizeof(string),"LS - %d",randnumb);
SetVehicleNumberPlate(vehicleid, string);
SetVehicleToRespawn(vehicleid);
}
}
Otherwise you could get 10999.
Re: Making vehicle plates random LS-%d -
Hash [NL-RP] - 19.02.2011
Ow yeah lol,
Re: Making vehicle plates random LS-%d -
thimo - 21.02.2011
Its weird but at me it just keeps the normal plate how is this possible? :O
Re: Making vehicle plates random LS-%d -
PowerPC603 - 21.02.2011
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.
Re: Making vehicle plates random LS-%d -
speed258 - 08.07.2011
so if i want to my plate changing random and saving in file like aaa 001 or aba 021 how to make it?