[Tutorial] Random vehicles plate for 0.3c versions
#1

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
Reply
#2

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.
Reply
#3

tnx bro i will edit
Reply
#4

Nice tutorial
Reply
#5

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.
Reply
#6

Tnx guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)