11.05.2017, 21:39
Hey all,
So i was trying to create a custom car ownership system and once I had finished it I added a random number plate generator, but with this I want it to search the database so it doesn't repeat the same plate over and over so that way the LEO's can find who the plate really belongs to, but when I try it, it just keeps repeating the stock over and over when I want it to return the plate that isn't taken, can someone please help me?
So i was trying to create a custom car ownership system and once I had finished it I added a random number plate generator, but with this I want it to search the database so it doesn't repeat the same plate over and over so that way the LEO's can find who the plate really belongs to, but when I try it, it just keeps repeating the stock over and over when I want it to return the plate that isn't taken, can someone please help me?
pawn Код:
stock GetRandomPlate()
{
new string[128];
format(string, sizeof(string), "%d%s%s%s%d%d%d", random(10), LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))], random(10), random(10), random(10));
mysql_format(Mysql_users, GlobalQuery, sizeof(GlobalQuery), "SELECT * FROM `playervehicles` WHERE `Plate` = '%s'", string);
mysql_query(Mysql_users, GlobalQuery);
if(cache_get_row_count() == 1)
{
GetRandomPlate();
}
return string;
}