This sometimes only creates one letter.
#1

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)