[Pomoc]MySQL

Započeo FireMan, Jul 02, 2011, 15:14:36 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

Skripta koju koristim:MojMod od 0
Detaljan opis problema:Zasto sluzi ova linija,jel to linija s kojom se radi Query ili gdje je ta linija da mogu dodat `adminlevel`
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!");
           SpawnPlayer(playerid);
           if(mysql_fetch_row(line)) //Fetches the line
           {
                  new data[3][50]; //The data strings
                  new data2[4]; //The data variables
/*------>*/   sscanf(line, "p|ssdddds", data[0], data[1], data2[0], data2[1], data2[2], data2[3], data[2]); //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
                  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[3][50]; //The data strings
                  new data2[4]; //The data variables
                  sscanf(line, "p|ssdddds", data[0], data[1], data2[0], data2[1], data2[2], data2[3], data[2]); //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
                  SendClientMessage(playerid, 0x0000D9AA, "Logged in!");
                  mysql_free_result();
                  SpawnPlayer(playerid);
              }
          }
      }
   }

Neke slike/video za lakse dobivanje pomoci(neobavezno):
Poslednja Izmena: Jul 02, 2011, 17:18:13 POSLE PODNE od FireMan