Custom Number Plate System - 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: Custom Number Plate System (
/showthread.php?tid=566489)
Custom Number Plate System -
Ciarannn - 06.03.2015
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?
AW: Custom Number Plate System -
Kaliber - 06.03.2015
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
Re: AW: Custom Number Plate System -
Ciarannn - 06.03.2015
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.
Re: Custom Number Plate System -
Vince - 06.03.2015
Dini is severely outdated and very slow. It should not under any circumstances be used for any new projects.