Number plate bug - 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)
+--- Thread: Number plate bug (
/showthread.php?tid=326226)
Number plate bug -
Dripac - 16.03.2012
pawn Код:
public OnVehicleSpawn(vehicleid)
{
new rand = random(3000); rand += 1500;
new string[32];
format(string, sizeof(string), "{D20000}SC-{FFFFFF}%d", rand);
SetVehicleNumberPlate(vehicleid, string);
return 1;
}
Does anyone know what's wrong here? because it won't change the number plates from default
Re: Number plate bug -
admantis - 16.03.2012
OnVehicleSpawn is called when the vehicle re-spawns, not when it's created, your fix is to respawn the vehicles after it's added. Good luck!
Re: Number plate bug -
AndreT - 16.03.2012
I don't think doing SetVehicleToRespawn in OnVehicleSpawn is a good idea. Instead you should set the vehicle's plate after you spawn the vehicle.
For example, I have around 1100 vehicle spawns and after it, I run a loop and then generate a random number plate for it.
pawn Код:
CreateVehicle(...);
new string[32];
for(new i = 0; i != MAX_VEHICLES; i++)
{
new rand = random(3000) + 1500;
format(string, sizeof(string), "{D20000}SC-{FFFFFF}%d", rand);
SetVehicleNumberPlate(i, string);
SetVehicleToRespawn(i);
}
Respuesta: Re: Number plate bug -
admantis - 17.03.2012
Quote:
Originally Posted by AndreT
I don't think doing SetVehicleToRespawn in OnVehicleSpawn is a good idea. Instead you should set the vehicle's plate after you spawn the vehicle.
For example, I have around 1100 vehicle spawns and after it, I run a loop and then generate a random number plate for it.
pawn Код:
CreateVehicle(...);
new string[32]; for(new i = 0; i != MAX_VEHICLES; i++) { new rand = random(3000) + 1500; format(string, sizeof(string), "{D20000}SC-{FFFFFF}%d", rand); SetVehicleNumberPlate(i, string); SetVehicleToRespawn(i); }
|
I didn't ever say that. When you have finished adding all your static vehicles, respawn them using a loop at OnGameModeInit. Your plates will work.