new num_plate[9];
for(new i; i < 3; i++) // 1,2,3 pos are letters
num_plate[i] = 'a'+random('z'-'a');
num_plate[3] = '-'; // 4 pos is '-'
for(new i=4; i < sizeof(num_plate); i++) // 5,6,7,8 pos are numbers
num_plate[i] = '0'+random('9'-'0');
new string[32];
new randnumb = 1 + random(9);
format(string, sizeof(string),"Text-%d%d%d",randnumb,randnumb,randnumb);
SetVehicleNumberPlate(vehicleid, string);
SetVehicleToRespawn(vehicleid);
PHP Code:
|
stock getRandomLetter() {
return 65 + random(52); // ASCII Code of capital A is 65 + 2 * 26 for all other chars in alphabet.
}
//...
format(someString, 128, "%c, %c, %c", getRandomLetter(), getRandomLetter(), getRandomLetter());
SetVehicleNumberPlate(cCar, string);
VehicleInfo[Total_Veh_Created][vPlate] = string;
SetVehicleToRespawn(cCar);
new LetterList[26][] =
{
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
};
stock SetVehicleRandomNumberPlate(vehicleid)
{
new string[10];
format(string, sizeof(string), "%s%s%s%s %d%d%d", LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))], random(10), random(10), random(10));
SetVehicleNumberPlate(vehicleid, string);
return 1;
}
for(new i=0;i<MAX_VEHICLES;i++)
{
new engine, lights, alarm, doors, bonnet, boot, objective; //This is defining the vehicles current items.
SetVehicleRandomNumberPlate(i);
return 1;
// (By ******)
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
strcpy(VehicleInfo[Total_Veh_Created][vPlate], string, sizeof(VehicleInfo[Total_Veh_Created][vPlate]));
//or...
format(VehicleInfo[Total_Veh_Created][vPlate], sizeof(VehicleInfo[Total_Veh_Created][vPlate]), string);