Custom Number Plate System
#1

USING DINI
I'm creating a number plate system for my server so that when a player registers their vehicle in the DMV, they get a number plate. I know how to set the number plate but how do I generate the number-plate and add it to a text-document. Then the next person that registers their car it will cycle through the text document a generate a number that is not already taken. How would I do that?
Reply
#2

Well, with dini, this is real hard, but you can easy use SQLite for this

Here an example:

PHP код:
//At top:
new DB:plate;
//OnGameModeInit
plate db_open("Plates.db");
db_free_result(db_query(plate,"CREATE TABLE IF NOT EXISTS `Plates` (`Name`,`Plate`)"));
//OnGameModeExit
db_close(plate);
//The function i made for u :*
stock InsertPlate(playerid,const doc[]) {
    new 
string[128],name[MAX_PLAYER_NAME],DBResult:result;
    
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    
format(string,128,"SELECT `Name` WHERE `Plate`='%s'",doc);
    
result db_query(plate,string);
    if(
db_num_rows(result) != 0) return 0;
    
format(string,128,"INSERT INTO `Plates` ('Name','Plate') VALUES ('%s','%s')",name,doc);
    
db_query(plate,string);
    return 
SendClientMessage(playerid,-1,"Your plate was added.");
}
//How to use
InsertPlate(playerid,"XYZ");
//If this would exist, it would return 0, so you can do sth like this:
new doc[32] = "XYZ";
while(!
InsertPlate(playerid,doc)) {
    
strcat(doc,"c");
    
//So it would add 'c' to the string, till nobody have this plate :)
}
//Or you just let the player type the plate :D 
I hope this helps you

Greekz
Reply
#3

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
Well, with dini, this is real hard, but you can easy use SQLite for this

Here an example:

PHP код:
//At top:
new DB:plate;
//OnGameModeInit
plate db_open("Plates.db");
db_free_result(db_query(plate,"CREATE TABLE IF NOT EXISTS `Plates` (`Name`,`Plate`)"));
//OnGameModeExit
db_close(plate);
//The function i made for u :*
stock InsertPlate(playerid,const doc[]) {
    new 
string[128],name[MAX_PLAYER_NAME],DBResult:result;
    
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    
format(string,128,"SELECT `Name` WHERE `Plate`='%s'",doc);
    
result db_query(plate,string);
    if(
db_num_rows(result) != 0) return 0;
    
format(string,128,"INSERT INTO `Plates` ('Name','Plate') VALUES ('%s','%s')",name,doc);
    
db_query(plate,string);
    return 
SendClientMessage(playerid,-1,"Your plate was added.");
}
//How to use
InsertPlate(playerid,"XYZ");
//If this would exist, it would return 0, so you can do sth like this:
new doc[32] = "XYZ";
while(!
InsertPlate(playerid,doc)) {
    
strcat(doc,"c");
    
//So it would add 'c' to the string, till nobody have this plate :)
}
//Or you just let the player type the plate :D 
I hope this helps you

Greekz
Although it would be hard, I don't know how to use SQLite. If you could show me in DINI that would be great, but if you don't know how, thanks for the help anyways.
Reply
#4

Dini is severely outdated and very slow. It should not under any circumstances be used for any new projects.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)