Random Plate? - 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: Random Plate? (
/showthread.php?tid=253969)
Random Plate? -
Tommy_Mandaz - 08.05.2011
Would that produce the random letters that I want and then how would I be able to make random numbers and then mix the two together to make a plate like this: L3S - E9R7
Re: Random Plate? -
KoczkaHUN - 08.05.2011
Is this good for you, or you want a very random plate mixed by numbers and letters?
Код:
new plate[8];
plate[0] = 65 + random(26);
plate[1] = random(10);
plate[2] = 65 + random(26);
plate[3] = '-';
plate[4] = 65 + random(26);
plate[5] = random(10);
plate[6] = 65 + random(26);
plate[7] = random(10);
Re: Random Plate? -
xDeadlyBoy - 08.05.2011
pawn Код:
#define MAX_VEHICLE_PLATE 8
new string[MAX_VEHICLE_PLATE];
new const charset[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for(new i; i < MAX_VEHICLE_PLATE; i++)
{
if(i == 3)string[i] = '-';
else string[i] = charset[RandomEx(0, sizeof(charset) - 1)];
}
RandomEx(min, max)return random(max - min) + min;
Re: Random Plate? -
Joe Staff - 08.05.2011
California's license plate template goes as follows: 1ABC234
I'm explaining California's plates because Los Santos mimicks Los Angeles, California
Re: Random Plate? -
Tommy_Mandaz - 08.05.2011
So will they be random as in it will make random letters and number mixed together?
Re: Random Plate? -
KoczkaHUN - 09.05.2011
Код:
const len = 7, hyphenpos = 4;
new plate[len+1];
for (new i = 0; i < len; i++)
{
if (i + 1 == hyphenpos)
{
plate[i] = '-';
continue;
}
if (random(2)) // letter or number?
{ // letter
plate[i] = 'A' + random(26);
}
else
{ // number
plate[i] = '0' + random(10);
}
}
printf("randomPlate 7: %s", plate);