Balkan SA:MP

PAWN skriptanje, gamemodovi, filterskripte, include fajlovi, mape, pluginovi => Razgovor u vezi PAWN - skriptanja => Temu započeo: FireMan poslato Jul 04, 2011, 17:34:03 POSLE PODNE

Naslov: [Pomoc]MySQL
Poruka od: FireMan poslato Jul 04, 2011, 17:34:03 POSLE PODNE
Mod:MojMod od 0
Problem:Koristim MySQL system spremanja podataka i napravio sam da mi sprema admin i GM level,on ga spremi ali na loginu ga ne ucita,kad izaÄ'em i pogledam preko phpMyAdmin pise da imam admin level a kad odem u igru ne ucita i onda kad izaÄ'em opet admin level bude 0
Dio Skripte: public OnPlayerConnect(playerid)
{
    new Query[200], Pname[24], escpname[24]; //Creates the Query string and the Pname
    GetPlayerName(playerid, Pname, 24); //Gets the players name
    mysql_real_escape_string(Pname, escpname); //escapes the string so you cant MySQL inject
    format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `user` = '%s'", escpname); //Selects the line where the playername is the player
    mysql_query(Query); //Querys the string
    mysql_store_result(); //Stores the result
    if(mysql_num_rows() != 0) //If the user is found
    {
        new PIP[56]; //Creates the IP string
        GetPlayerIp(playerid, PIP, 56); //Gets the players IP
        format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `user` = '%s' AND `IP` = '%s'", escpname, PIP); //Checks if the players IP is the same, if so it will auto login :)
        mysql_query(Query); //Queries the result
        mysql_store_result(); //Stores the result
        if(mysql_num_rows() != 0) // If the players IP is the same in the DB
        {
            new line[750];
            SetPVarInt(playerid, "Logged", 1); //Sets the logged variable to 1
            SendClientMessage(playerid, 0x009600AA, "Auto Logged in!");
            if(mysql_fetch_row(line)) //Fetches the line
            {
                   new data[3][50]; //The data strings
                   new data2[10]; //The data variables
                   sscanf(line, "p|ssdddds", data[0], data[1], data2[0], data2[1], data2[2], data2[3], data[2], data2[4], data2[5]); //Splits the line with sscanf
                   SetPVarInt(playerid, "Kills", data2[0]); //Sets Pvar ints
                   SetPVarInt(playerid, "Logged", 1); //Sets Pvar ints
                   SetPVarInt(playerid, "Deaths", data2[1]); //Sets Pvar ints
                   SetPlayerScore(playerid, data2[2]); //Sets players score
                   GivePlayerMoney(playerid, data2[3]); //Sets players cash
                   SetPVarInt(playerid, "Admin", data2[4]);
                   SetPVarInt(playerid, "GameMaster", data2[5]);
                   mysql_free_result();
               }
        }
        if(!mysql_num_rows())
        {
            SendClientMessage(playerid, 0x009600AA, "This account is registered, please login"); //User is registered but IP does not match
            ShowPlayerDialog(playerid, 15000, DIALOG_STYLE_INPUT , "Login", "This account is registered, please login", "OK", "Cancel");
        }
    }
    else
    {
        ShowPlayerDialog(playerid, 14600, DIALOG_STYLE_INPUT , "Register", "This account is not registered, please register!", "OK", "Cancel");
        SendClientMessage(playerid, 0x009600AA, "This account is not registered, please register!"); // User is not registed
    }
    mysql_free_result(); //Frees the result :)
    return 1;
}



if(dialogid == 15000)
    {
       if(response)
       {
           new Query[200], Pname[24];
           GetPlayerName(playerid, Pname, 24);
           new escpname[24];
           mysql_real_escape_string(Pname, escpname);
           format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `user` = '%s' AND `password` = '%s'", escpname, inputtext);
           mysql_query(Query);
           mysql_store_result();
           if(!mysql_num_rows())
           {
               SendClientMessage(playerid, 0xF60000AA, "Invalid password!");
               SetPVarInt(playerid, "WrongPass", GetPVarInt(playerid, "WrongPass") + 1);
               ShowPlayerDialog(playerid, 15000, DIALOG_STYLE_INPUT , "Login", "This account is registered, please login", "OK", "Cancel");
               if(GetPVarInt(playerid, "WrongPass") == 3)
               {
                   SendClientMessage(playerid, 0xF60000AA, "Max password tries exceeded!!");
                   Kick(playerid);
               }
           }
           else
           {
               new line[750]; //I know it's big D=
               if(mysql_fetch_row(line)) //Fetches the line
               {
                   new data[10][50]; //The data strings
                   new data2[30]; //The data variables
                   sscanf(line, "p|ssdddds", data[0], data[1], data2[0], data2[1], data2[2], data2[3], data[2], data2[4], data2[5]); //Splits the line with sscanf
                   SetPVarInt(playerid, "Kills", data2[0]); //Sets Pvar ints
                   SetPVarInt(playerid, "Logged", 1); //Sets Pvar ints
                   SetPVarInt(playerid, "Deaths", data2[1]); //Sets Pvar ints
                   SetPlayerScore(playerid, data2[2]); //Sets players score
                   SetPVarInt(playerid, "MoneyGiven", data2[3]); //Sets players cash
                   SetPVarInt(playerid, "Admin", data2[4]); //Sets Pvar ints
                   SetPVarInt(playerid, "GameMaster", data2[5]); //Sets Pvar ints
                   SendClientMessage(playerid, 0x0000D9AA, "Prijavljen!");
                   mysql_free_result();
               }
           }
       }
    }
    return 1;
}
Naslov: Odg: [Pomoc]MySQL
Poruka od: Zarathos poslato Jul 04, 2011, 19:30:44 POSLE PODNE
Uvijek fulis vrstu varijable, procitaj malo sscanf2 dokumentaciju...

http://forum.sa-mp.com/showthread.php?t=120356

i

http://wiki.sa-mp.com/wiki/Scripting_Basics#Variables

prije nego sto pocnes raditi sa necim kao sto je mysql...
Naslov: Odg: [Pomoc]MySQL
Poruka od: FireMan poslato Jul 04, 2011, 19:33:51 POSLE PODNE
Kako sam fulo varijablu kad je je to broj ko i ono drugo pa sam isto napravio jer je isto broj ko ono do
Naslov: Odg: [Pomoc]MySQL
Poruka od: Zarathos poslato Jul 04, 2011, 19:36:12 POSLE PODNE
gledaj, ti kod sebe ovdje nemas SetPVarString... a deklarisao si u sscanf-u da uzima string:

sscanf(line, "p|ssdddds", data[0], data[1], data2[0], data2[1], data2[2], data2[3], data[2], data2[4], data2[5]); //Splits the line with sscanf 
                   SetPVarInt(playerid, "Kills", data2[0]); //Sets Pvar ints 
                   SetPVarInt(playerid, "Logged", 1); //Sets Pvar ints 
                   SetPVarInt(playerid, "Deaths", data2[1]); //Sets Pvar ints 
                   SetPlayerScore(playerid, data2[2]); //Sets players score 
                   GivePlayerMoney(playerid, data2[3]); //Sets players cash 
                   SetPVarInt(playerid, "Admin", data2[4]); 
                   SetPVarInt(playerid, "GameMaster", data2[5]); 


rekao sam ti procitaj prvo, nesto ces nauciti i skontati, ovako samo u prazno ides, nista neces nauciti...
Naslov: Odg: [Pomoc]MySQL
Poruka od: FireMan poslato Jul 04, 2011, 19:40:34 POSLE PODNE
Sta trebam koristit GetValue?
Naslov: Odg: [Pomoc]MySQL
Poruka od: Zarathos poslato Jul 04, 2011, 19:44:32 POSLE PODNE
gledaj kako to ide:

sscanf(line, "p|ssdddds", data[0], data[1], data2[0], data2[1], data2[2], data2[3], data[2], data2[4], data2[5]); //Ovo cita liniju pomocu sscanf-a, a pritom svaku vrijednost dijeli sa pregradom |, medutim ako je sscanf2 potrebno je koristiti p<|>, ovo je oznaka za delimiter...
// ti si trebao ovo ovako definisati:

sscanf(line, "p<|>dddddd", data2[0], data2[1], data2[2], data2[3], data2[4], data2[5]);

                   SetPVarInt(playerid, "Kills", data2[0]); //Sets Pvar ints 
                   SetPVarInt(playerid, "Logged", 1); //Sets Pvar ints 
                   SetPVarInt(playerid, "Deaths", data2[1]); //Sets Pvar ints 
                   SetPlayerScore(playerid, data2[2]); //Sets players score 
                   GivePlayerMoney(playerid, data2[3]); //Sets players cash 
                   SetPVarInt(playerid, "Admin", data2[4]); 
                   SetPVarInt(playerid, "GameMaster", data2[5]);


Ovo si pogrijesio... i kakav crni GetValue :S
Naslov: Odg: [Pomoc]MySQL
Poruka od: FireMan poslato Jul 04, 2011, 19:46:31 POSLE PODNE
Citat: EM|Pacino poslato Jul 04, 2011, 19:44:32 POSLE PODNE

Ovo si pogrijesio... i kakav crni GetValue :S

Ma nesto sam guglao xD

Ali prije nisu bile <|> i radilo je ovo drugo kad nije bio adminlevel i gmlevel
Naslov: Odg: [Pomoc]MySQL
Poruka od: Zarathos poslato Jul 04, 2011, 19:48:05 POSLE PODNE
koja ti je verzija sscanf-a?
Naslov: Odg: [Pomoc]MySQL
Poruka od: FireMan poslato Jul 04, 2011, 19:50:57 POSLE PODNE
1.0,sad stavio 2.0 plugin i include,compilo,restarto i opet neradi
Naslov: Odg: [Pomoc]MySQL
Poruka od: Zarathos poslato Jul 04, 2011, 19:58:24 POSLE PODNE
lol nije do plugina, rekao sam ti do cega je... problem je u tvom kodu, tj. ne dajes kako treba definicije varijabli...
Naslov: Odg: [Pomoc]MySQL
Poruka od: FireMan poslato Jul 04, 2011, 20:04:13 POSLE PODNE
Sad mi je ovako i opet neradi

new line[750]; //I know it's big D=
               if(mysql_fetch_row(line)) //Fetches the line
               {
                   //new data[10][50]; //The data strings
                   new data2[30]; //The data variables
                   sscanf(line, "p<|>dddddd", data2[0], data2[1], data2[2], data2[3], data2[4], data2[5]);
                   SetPVarInt(playerid, "Kills", data2[0]); //Sets Pvar ints
                   SetPVarInt(playerid, "Logged", 1); //Sets Pvar ints
                   SetPVarInt(playerid, "Deaths", data2[1]); //Sets Pvar ints
                   SetPlayerScore(playerid, data2[2]); //Sets players score
                   GivePlayerMoney(playerid, data2[3]); //Sets players cash
                   SetPVarInt(playerid, "Admin", data2[4]);
                   SetPVarInt(playerid, "GameMaster", data2[5]);
                   SendClientMessage(playerid, 0x0000D9AA, "Prijavljen!");
                   mysql_free_result();
Naslov: Odg: [Pomoc]MySQL
Poruka od: Zarathos poslato Jul 04, 2011, 20:06:16 POSLE PODNE
cita li kako treba? ili ne sprema kako treba?
Naslov: Odg: [Pomoc]MySQL
Poruka od: FireMan poslato Jul 04, 2011, 20:07:06 POSLE PODNE
Ne cita kako treba a sprema kako treba,ali samo admin lvl a gm lvl nisam isprobo dal cita,a pass cita uredu ali admin lvl ne