SQLite problem, don't create player
#1

Hey, guy!

I need a little help. So i'm using sqlite. When i register, my player account don't show up in database. Maybe you can help me:

So, under OnGameModeInit:
Код:
Database = db_open("PARTYtest.db");
db_query(Database, "CREATE TABLE IF NOT EXISTS `Accounts` (`Userid` INTEGER PRIMARY KEY AUTOINCREMENT, `Username`, `Password`, `IP`, `Skin`, `AdminLevel`, `Score`, `Points`, `Money`, `Kills`, `Deaths`, `Drugs`, `Exported`, `Muted`, `Jailed`)");
Under OnPlayerDisconnect:
Код:
new Query[200];
format(Query,sizeof(Query),"UPDATE `Acounts` SET Skin = '%d', AdminLevel = '%d', Score = '%d', Points = '%d', Money = '%d', Kills = '%d', Deaths = '%d', Drugs = '%d', Exported = '%d', Muted = '%d', Jailed = '%d' WHERE `Username` = '%s'",GetPlayerSkin(UserStats[playerid][Skin]),UserStats[playerid][Admin],GetPlayerScore(playerid),UserStats[playerid][Points],GetPlayerMoney(playerid),UserStats[playerid][Kills],UserStats[playerid][Deaths],UserStats[playerid][Drugs],UserStats[playerid][Exported],UserStats[playerid][Muted],UserStats[playerid][Jailed],DB_Escape(UserStats[playerid][Name]));
db_query(Database, Query);
And OnDialogResponse:
Код:
	new Query[256], DBResult: Result, ip[16];
	GetPlayerIp(playerid, ip, sizeof(ip));
	if(dialogid == 1) //Login
	{
	    if(response) 
	    {
		   	format(Query, sizeof(Query), "SELECT * FROM `Accounts` WHERE `Username` = '%s' AND `Password` = '%s'", DB_Escape(UserStats[playerid][Name]), DB_Escape(inputtext));
			Result = db_query(Database, Query);
			if(db_num_rows(Result))
			{
				new szValue[64];
				
				db_get_field_assoc(Result, "Skin", szValue, sizeof(szValue));
				UserStats[playerid][Skin] = strval(szValue);

				db_get_field_assoc(Result, "AdminLevel", szValue, sizeof(szValue));
				UserStats[playerid][Admin] = strval(szValue);
				
				db_get_field_assoc(Result, "Score", szValue, sizeof(szValue));
				SetPlayerScore(playerid, strval(szValue));
				
				db_get_field_assoc(Result, "Points", szValue, sizeof(szValue));
				UserStats[playerid][Points] = strval(szValue);

				db_get_field_assoc(Result, "Money", szValue, sizeof(szValue));
				GivePlayerMoney(playerid, strval(szValue));
				
				db_get_field_assoc(Result, "Kills", szValue, sizeof(szValue));
				UserStats[playerid][Kills] = strval(szValue);

				db_get_field_assoc(Result, "Deaths", szValue, sizeof(szValue));
				UserStats[playerid][Deaths] = strval(szValue);
				
				db_get_field_assoc(Result, "Drugs", szValue, sizeof(szValue));
				UserStats[playerid][Drugs] = strval(szValue);

				db_get_field_assoc(Result, "Exported", szValue, sizeof(szValue));
				UserStats[playerid][Exported] = strval(szValue);
				
		        db_get_field_assoc(Result, "Muted", szValue, sizeof(szValue));
		        UserStats[playerid][Muted] = strval(szValue);

		        db_get_field_assoc(Result, "Jailed", szValue, sizeof(szValue));
		        UserStats[playerid][Jailed] = strval(szValue);

    			UserStats[ playerid ][ USER_LOGGED_IN ] = true;

    			SendClientMessage(playerid, COLOR_GREEN,"^Tu veiksmīgi ielogojies savā kontā!");
			}
			else //Kad parole nepareizi ievadīta:
			{
				ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD,"Ielogљanās serverī","Tu ievadīji nepareizu paroli!\nIevadi savu paroli, lai pieslēgtos kontam!","Ielogoties","Iziet");
			}
			db_free_result(Result);
	    }
	    else return Kick(playerid);
	}
	if(dialogid == 0) //Register
	{
		if(response) 
	    {
			if(strlen(inputtext) > 24 || strlen(inputtext) < 3)
			{
				ShowPlayerDialog(playerid, 0, DIALOG_STYLE_PASSWORD, "Reģistrēљanās serverī","Tu ievadīji par īsu vai par garu paroli!\nIevadi savu paroli, lai reģistrētos!","Reģistrēties","Iziet");
			}
			else
			{
			    format(Query, sizeof(Query), "INSERT INTO `Accounts` (`Username`, `Password`, `IP`, `Skin`, `AdminLevel`, `Score`, `Points`, `Money`, `Kills`, `Deaths`, `Drugs`, `Exported`, `Muted`, `Jailed`) VALUES('%s','%s','%s', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')", DB_Escape(UserStats[playerid][Name]), DB_Escape(inputtext), DB_Escape(ip));
				db_query(Database, Query);
				UserStats[ playerid ][ USER_LOGGED_IN ] = true;
				SetPlayerScore(playerid, 0);
				SendClientMessage(playerid, COLOR_GREEN,"Paldies, ka reģistrējies PARTY SA:MP serverī! Patīkamu spēlēљanu! :)");
			}
	    }
	    else return Kick(playerid);
	}
What's the reason for not creating?

Thank you, Grindzo.
Reply
#2

Someone?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)