This sometimes only creates one letter. - 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)
+--- Thread: This sometimes only creates one letter. (
/showthread.php?tid=619843)
This sometimes only creates one letter. -
Dokins - 22.10.2016
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.
Re: This sometimes only creates one letter. -
Vince - 23.10.2016
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.