Custom Number Plate System
#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


Messages In This Thread
Custom Number Plate System - by Ciarannn - 06.03.2015, 14:06
AW: Custom Number Plate System - by Kaliber - 06.03.2015, 14:29
Re: AW: Custom Number Plate System - by Ciarannn - 06.03.2015, 14:41
Re: Custom Number Plate System - by Vince - 06.03.2015, 14:44

Forum Jump:


Users browsing this thread: 2 Guest(s)