Posts: 1,648
Threads: 482
Joined: Jun 2010
pawn Код:
#define MAX_PLATE 8
new charset[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
new newPlate[MAX_PLATE + 1];
for(new i = 0; i < MAX_PLATE; i++)
{
newPlate[i] = charset[RandomEx(0, sizeof(charset)- 1)]; // 62 = strlen of charset
}
format(plate, sizeof(plate), "%s",newPlate);
This is for setting random vehicle plates but I have found vehicle plates to be set to for example: 'E' or something as opposed to 8.
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
I don't really know why you need RandomEx() if the normal random() starts from 0. And in that case you also don't need to do the -1 because random() returns a value between 0 (inclusive) and max (exclusive).
Apart from that I really don't see why it wouldn't work.