Unique Licence Plates
#1

Hey,

I'm looking to create something to ensure the license plates are totally unique. I have some code that I have been using here:

pawn Код:
new LetterList[22][] =
{
     "A", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "T", "U", "V", "W", "X", "Y", "Z"
};
           
for(new i = 0; i < MAX_VEHICLES; ++i)
{
      while(vInfo[i][vPlate] == randomplate)
     {
        format(randomplate, sizeof(randomplate), "%d%d%d %s%s%s", random(9),random(9), random(9),LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))]);
      }
}
Right now ofcourse it tells me that 'randomplate' is not indexed.
error 033: array must be indexed (variable "randomplate")

I don't want to base it off vehicle ID's either. Can someone help me make this work? or propose a better solution?

BTW, It doesn't have the full alphabet because I dident want to see confusion between letters.

Cheers!
- James
Reply
#2

Not sure but when the Error is "Must be indexed" i just put something like

pawn Код:
UsingMortar[playerid]
In your case,

pawn Код:
while(vInfo[i][vPlate] == randomplate[vehicleid])
Reply
#3

Quote:
Originally Posted by Aira
Посмотреть сообщение
Not sure but when the Error is "Must be indexed" i just put something like

pawn Код:
UsingMortar[playerid]
In your case,

pawn Код:
while(vInfo[i][vPlate] == randomplate[vehicleid])
Nah, Its not an array. It's only a string I use to compile the plate.
Reply
#4

Quick bump. Still can't figure out the best way to go about this.
Reply
#5

Not sure, but is your variable actually a string?

pawn Код:
new randomplate; //Wrong

new randomplate[stringlengthhere]; //Correct
Reply
#6

Quote:
Originally Posted by Kindred
Посмотреть сообщение
Not sure, but is your variable actually a string?

pawn Код:
new randomplate; //Wrong

new randomplate[stringlengthhere]; //Correct
Yahh, it's a string.
Reply
#7

bumpp
Reply
#8

pawn Код:
while(vInfo[i][vPlate] == randomplate)
what is this supposed to do? compare strings? 1 char maybe? does creating a string to assign it to the plate require any presumptions?
Reply
#9

Quote:
Originally Posted by Babul
Посмотреть сообщение
pawn Код:
while(vInfo[i][vPlate] == randomplate)
what is this supposed to do? compare strings? 1 char maybe? does creating a string to assign it to the plate require any presumptions?
Thats a quick mock-up I made ofc^ I'd be using strcmp.
Reply
#10

Post all of the code relating to this. We can't do much with just that.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)