Quote:
Originally Posted by ******
Or only use invalid symbols:
pawn Код:
RandomiseNumberPlate(vehicleid, const form[]) { // Don't forget the NULL character. new numstr[33]; // Don't do calculations you can avoid in the "while" segment. for(new i, j = min(strlen(form), sizeof (numstr) - 1); i != j; ++i) { switch (form[i]) { // Hash for numbers. case '#': numstr[i] = random(10) + '0'; // LOW for LOWer. case '_': numstr[i] = random(26) + 'a'; // Pointing UP for UPper. case '^': numstr[i] = random(26) + 'A'; // Possibly not used (so ??? can generate 0-999). case '?': { new p = i; while (form[++p] == '?') {} p -= i; format(numstr[i], sizeof (numstr) - i, "%*d", p, random(floatround(floatpower(10.0, p)))); i += p - 1; } // Anything else. default: numstr[i] = form[i]; } } SetVehicleNumberPlate(vehicleid, numstr); }
You may not like those but I went for something pointing UP for UPper case, something LOW for LOWer case, and a hash for numbers as that's quite a common representation.
Edit: Added ? for maybe - as in "  " is UP TO a 3 digit number. In England at least the old format was "^  ^^^", but "Y 1ESS" was valid because it was any number in the range 0-999 (guess what my ideal number plate is). Also according to the wiki you can have up to 32 characters, so I changed that.
|
I can't understand what is that function "min".
j = min
What is it?
Is there any further explanation?