Unique Licence Plates -
jamesb93 - 17.06.2012
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
Re: Unique Licence Plates -
Aira - 17.06.2012
Not sure but when the Error is "Must be indexed" i just put something like
In your case,
pawn Код:
while(vInfo[i][vPlate] == randomplate[vehicleid])
Re: Unique Licence Plates -
jamesb93 - 17.06.2012
Quote:
Originally Posted by Aira
Not sure but when the Error is "Must be indexed" i just put something like
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.
Re: Unique Licence Plates -
jamesb93 - 17.06.2012
Quick bump. Still can't figure out the best way to go about this.
Re: Unique Licence Plates -
Kindred - 17.06.2012
Not sure, but is your variable actually a string?
pawn Код:
new randomplate; //Wrong
new randomplate[stringlengthhere]; //Correct
Re: Unique Licence Plates -
jamesb93 - 17.06.2012
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.
Re: Unique Licence Plates -
jamesb93 - 17.06.2012
bumpp
Re: Unique Licence Plates -
Babul - 17.06.2012
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?
Re: Unique Licence Plates -
jamesb93 - 17.06.2012
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.
Re: Unique Licence Plates -
SuperViper - 18.06.2012
Post all of the code relating to this. We can't do much with just that.