SA-MP Forums Archive
[Tutorial] Random vehicles plate for 0.3c versions - 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: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Random vehicles plate for 0.3c versions (/showthread.php?tid=614007)



Random vehicles plate for 0.3c versions - Dejan12345 - 03.08.2016

Hey Guys i Today show how to make a random venhicle plate

You dont need any include only /include <a_samp>

now found Function called OnVehicleSpawn

now under OnVehicleSpawn put these code

Код:
public OnVehicleSpawn(vehicleid)
 {
new rand = random(3000) + 1500;
new string[24];
format(string, sizeof(string), "{D20000}LS-{FFFFFF}%d", rand);
SetVehicleNumberPlate(vehicleid, string);

	return true;
}
explanation

Код:
new rand = random(3000); + 1500;
it says variable with random numbers to 3000 and then adds the random number 1500, for example . If the number comes out randomly in 1234 then added in 1500 and it comes out 2734.
Код:
new string[24];
it makes new string with 24 cell
Код:
format(string, sizeof(string), "{D20000}LS-{FFFFFF}%d", rand);
Format functions including string variables and other strings . D20000 LS- } { { FFFFFF } % d explained to be " LS " in red colours , a random number ( rand variable) is written in white , Color Embedding ( 0.3c )
sorry for My bad languange i Serbian


Re: Random vehicles plate for 0.3c versions - Stinged - 03.08.2016

It makes very little difference, but doing this:
Код:
new rand = random(3000) + 1500;
is better than this:
Код:
new rand = random(3000); rand += 1500;
32 cells is too much for that small string.
24 is enough.

{D20000}LS-{FFFFFF} = 19 characters
The max number is 4499, which means 4 characters.
1 for NULL.

19 + 4 + 1 = 24 cells.


Re: Random vehicles plate for 0.3c versions - Dejan12345 - 03.08.2016

tnx bro i will edit


Re: Random vehicles plate for 0.3c versions - Deadpoop - 03.08.2016

Nice tutorial


Re: Random vehicles plate for 0.3c versions - Luicy. - 03.08.2016

1.
Why would you color a vehicle plate?
2.
Fix the damn intention.
3.
If you'd read wiki, OnVehicleSpawn, calls only when it respawns. Better use a loop on OnGameModeInit.



Re: Random vehicles plate for 0.3c versions - Dejan12345 - 04.08.2016

Tnx guys