SQLite Login/Register problem
#1

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new Query[512], DBResult: Result, name[MAX_PLAYER_NAME], Field[20], string[64];
    GetPlayerName(playerid, name, sizeof(name));

    if(dialogid == 1)
    {
        if(response)
        {
            format(Query, sizeof(Query), "SELECT * FROM `USERS` WHERE `NAME` = '%s' COLLATE NOCASE AND `PASSWORD` = '%s'", DB_Escape(name), DB_Escape(inputtext));
			Result = db_query(Database, Query);
            if(db_num_rows(Result))
            {
                db_get_field_assoc(Result, "ADMIN", Field, 30);
				PlayerInfo[playerid][Admin] = strval(Field);
				db_get_field_assoc(Result, "GM", Field, 30);
				PlayerInfo[playerid][GM] = strval(Field);
				db_get_field_assoc(Result, "LEVEL", Field, 30);
				PlayerInfo[playerid][Level] = strval(Field);
				db_get_field_assoc(Result, "NOVAC", Field, 30);
				PlayerInfo[playerid][Novac] = strval(Field);
				db_get_field_assoc(Result, "BANKA", Field, 30);
				PlayerInfo[playerid][Banka] = strval(Field);
				db_get_field_assoc(Result, "POSAO", Field, 30);
				PlayerInfo[playerid][Posao] = strval(Field);
				db_get_field_assoc(Result, "UGOVOR", Field, 30);
				PlayerInfo[playerid][Ugovor] = strval(Field);
				db_get_field_assoc(Result, "MOBITEL", Field, 30);
				PlayerInfo[playerid][Mobitel] = strval(Field);
				db_get_field_assoc(Result, "LIDER", Field, 30);
				PlayerInfo[playerid][Lider] = strval(Field);
				db_get_field_assoc(Result, "CLAN", Field, 30);
				PlayerInfo[playerid][Clan] = strval(Field);
				db_get_field_assoc(Result, "RANK", Field, 30);
				PlayerInfo[playerid][Rank] = strval(Field);
				db_get_field_assoc(Result, "KAZNAUGOVOR", Field, 30);
				PlayerInfo[playerid][Kaznaugovor] = strval(Field);
				db_get_field_assoc(Result, "SATIUBANDI", Field, 30);
				PlayerInfo[playerid][Satiubandi] = strval(Field);
				db_get_field_assoc(Result, "SATIIGRE", Field, 30);
				PlayerInfo[playerid][Satiigre] = strval(Field);
				db_get_field_assoc(Result, "DRZAVA", Field, 30);
				PlayerInfo[playerid][Drzava] = strval(Field);
				db_get_field_assoc(Result, "SPOL", Field, 30);
				PlayerInfo[playerid][Spol] = strval(Field);
				db_get_field_assoc(Result, "DOB", Field, 30);
				PlayerInfo[playerid][Dob] = strval(Field);
				db_get_field_assoc(Result, "EXP", Field, 30);
				PlayerInfo[playerid][Exp] = strval(Field);
				db_get_field_assoc(Result, "VDP", Field, 30);
				PlayerInfo[playerid][VDP] = strval(Field);
				db_get_field_assoc(Result, "UBOJSTVA", Field, 30);
				PlayerInfo[playerid][Ubojstva] = strval(Field);
				db_get_field_assoc(Result, "SMRTI", Field, 30);
				PlayerInfo[playerid][Smrti] = strval(Field);
				db_get_field_assoc(Result, "TRAVA", Field, 30);
				PlayerInfo[playerid][Trava] = strval(Field);
                db_get_field_assoc(Result, "DUHAN", Field, 30);
				PlayerInfo[playerid][Duhan] = strval(Field);
				db_get_field_assoc(Result, "RIZLE", Field, 30);
				PlayerInfo[playerid][Rizle] = strval(Field);
				db_get_field_assoc(Result, "KOKAIN", Field, 30);
				PlayerInfo[playerid][Kokain] = strval(Field);
				db_get_field_assoc(Result, "KREDIT", Field, 30);
				PlayerInfo[playerid][Kredit] = strval(Field);
				db_get_field_assoc(Result, "KREDITIZNOS", Field, 30);
				PlayerInfo[playerid][KreditIznos] = strval(Field);
				db_get_field_assoc(Result, "KUCA", Field, 30);
				PlayerInfo[playerid][Kuca] = strval(Field);
				db_get_field_assoc(Result, "FIRMA", Field, 30);
				PlayerInfo[playerid][Firma] = strval(Field);
				db_get_field_assoc(Result, "VOZILO", Field, 30);
				PlayerInfo[playerid][Vozilo] = strval(Field);
				db_get_field_assoc(Result, "MOTOR", Field, 30);
				PlayerInfo[playerid][Motor] = strval(Field);
				db_get_field_assoc(Result, "BICKIKLA", Field, 30);
				PlayerInfo[playerid][Bicikla] = strval(Field);
				db_get_field_assoc(Result, "LETJELICA", Field, 30);
				PlayerInfo[playerid][Letjelica] = strval(Field);
				db_get_field_assoc(Result, "PLOVILO", Field, 30);
				PlayerInfo[playerid][Plovilo] = strval(Field);
				db_get_field_assoc(Result, "VIKENDICA", Field, 30);
				PlayerInfo[playerid][Vikendica] = strval(Field);
				db_get_field_assoc(Result, "KLJUC1", Field, 30);
				PlayerInfo[playerid][Kljuc][0] = strval(Field);
				db_get_field_assoc(Result, "KLJUC2", Field, 30);
				PlayerInfo[playerid][Kljuc][1] = strval(Field);
				db_get_field_assoc(Result, "KLJUC3", Field, 30);
				PlayerInfo[playerid][Kljuc][2] = strval(Field);
				db_get_field_assoc(Result, "UPOZORENJA", Field, 30);
				PlayerInfo[playerid][Upozorenja] = strval(Field);
				db_get_field_assoc(Result, "NAOCALE", Field, 30);
				PlayerInfo[playerid][Naocale] = strval(Field);
				db_get_field_assoc(Result, "MASKA", Field, 30);
				PlayerInfo[playerid][Maska] = strval(Field);
				db_get_field_assoc(Result, "KAPA", Field, 30);
				PlayerInfo[playerid][Kapa] = strval(Field);
				db_get_field_assoc(Result, "SJEME", Field, 30);
				PlayerInfo[playerid][Sjeme] = strval(Field);
				db_get_field_assoc(Result, "MATERIJALI", Field, 30);
				PlayerInfo[playerid][Materijali] = strval(Field);
				db_get_field_assoc(Result, "ORUZJE", Field, 30);
				PlayerInfo[playerid][Oruzije] = strval(Field);
				db_get_field_assoc(Result, "MUNICIJA", Field, 30);
				PlayerInfo[playerid][Municija] = strval(Field);
				db_get_field_assoc(Result, "CARLIC", Field, 30);
				PlayerInfo[playerid][CarLic] = strval(Field);
				db_get_field_assoc(Result, "BOATLIC", Field, 30);
				PlayerInfo[playerid][BoatLic] = strval(Field);
				db_get_field_assoc(Result, "FLYLIC", Field, 30);
				PlayerInfo[playerid][FlyLic] = strval(Field);
				db_get_field_assoc(Result, "TRUCKLIC", Field, 30);
				PlayerInfo[playerid][TruckLic] = strval(Field);
				db_get_field_assoc(Result, "BIKELIC", Field, 30);
				PlayerInfo[playerid][BikeLic] = strval(Field);
				db_get_field_assoc(Result, "KACIGA", Field, 30);
				PlayerInfo[playerid][Kaciga] = strval(Field);
				db_get_field_assoc(Result, "SPAWN", Field, 30);
				PlayerInfo[playerid][Spawn] = strval(Field);
				db_get_field_assoc(Result, "SKIN", Field, 30);
				PlayerInfo[playerid][Skin] = strval(Field);
				db_get_field_assoc(Result, "ZDRAVSTVENO", Field, 30);
				PlayerInfo[playerid][Zdravstveno] = strval(Field);
				db_get_field_assoc(Result, "MEHMATS", Field, 30);
				PlayerInfo[playerid][MehMats] = strval(Field);
                db_get_field_assoc(Result, "BOMBA", Field, 30);
				PlayerInfo[playerid][Bomba] = strval(Field);
				db_get_field_assoc(Result, "BON", Field, 30);
				PlayerInfo[playerid][Bon] = strval(Field);
                Logged[playerid] = true;
                SendClientMessage(playerid, -1, "* "COL_GREEN"You have succesfuly"BIJELA" logged in! ");
				format(string, sizeof string, PlayerInfo[playerid][Spawn]);
				SCM(playerid, -1, string);
				format(string, sizeof string, PlayerInfo[playerid][Level]);
				SCM(playerid, -1, string);
				PlayerInfo[playerid][Spawn] = 123;
				format(string, sizeof string, PlayerInfo[playerid][Spawn]);
				SCM(playerid, -1, string);
				SpawnThisPlayer(playerid);
            }
            else
            {
                format(dialogstring, sizeof(dialogstring), "Welcome to server "SVIJETLOPLAVA"%s"BIJELA", vi ste registrirani\n\nMolimo da se prijavite upisujuci svoju lozinku.", name, playerid);
        		ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Prijava", dialogstring, "Login", "Leave");
                SendClientMessage(playerid, -1, ""COL_RED"Kriva"BIJELA" lozinka, pokusajte opet!");
            }
            db_free_result(Result);
        }
        else { SendClientMessage(playerid, -1, "* Canceld! "); Kick(playerid); }
    }
I have problem with this,it does not load sh*t from database.
Reply
#2

Are you trying to make all those things on login?
If so you need to edit "SELECT * FROM `USERS` WHERE `NAME`

Also if your too new to mysql you should use dini or something else!
Reply
#3

I m not new, i just always have a problem with that
Reply
#4

You need to edit:
format(Query, sizeof(Query), "SELECT * FROM `USERS` WHERE `NAME` = '%s' COLLATE NOCASE AND `PASSWORD` = '%s'", DB_Escape(name), DB_Escape(inputtext));

So that all the things you want can load at login.
Reply
#5

You seems raging when scripting it . hahah, why do you have to put COLLATE NOCASE AND `PASSWORD` = '%s' ?
Reply
#6

I have removed COLLATE NOCASE but still the same.
Reply
#7

You need to edit:
format(Query, sizeof(Query), "SELECT * FROM `USERS` WHERE `NAME` = '%s' COLLATE NOCASE AND `PASSWORD` = '%s'", DB_Escape(name), DB_Escape(inputtext));

And put all the things you want to in!

So that all the things you want can load at login.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)