MYSQL PROBLEM
#1

hello everybody i have some problem with login/register script.
can you saw a mistake?
Код:
if(dialogid == GUI_REGISTER)
      {
      if(response) //Jei paspaudė mygtuką "Sutinku"
      {
      new str[256];
      GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
      GetPlayerIp(playerid, PlayerIP, sizeof(PlayerIP));

      if(PlayerInfo[playerid][pLogged] == 1)
      {
       switch (PlayerInfo[playerid][pKalba])
        {
            case 0:
            {
                format(str, sizeof(str), "ERROR: You are already logged in (username: \"%s\")", PlayerName);
            SendClientMessage(playerid, COLOR_ERROR, str);
            }
            case 1:
            {
                format(str, sizeof(str), "Klaida: Jūs jau esate prisijungęs (saskaita: \"%s\")", PlayerName);
            SendClientMessage(playerid, COLOR_ERROR, str);
            }
           }
      return true;
         }

    if(PlayerInfo[playerid][pREG]==1 && PlayerInfo[playerid][pLogged]==0)
   {
    switch (PlayerInfo[playerid][pKalba])
        {
            case 0:
            {
                format(str, sizeof(str), "ERROR: Password \"%s\" is invalid (can't contain \"<\" or \">\")", inputtext);
            SendClientMessage(playerid, COLOR_ERROR, str);
            }
            case 1:
            {
                format(str, sizeof(str), "KLAIDA: Kodas \"%s\" paraљytas su klaida (naudoti draudћiam \"<\" arba \">\")", inputtext);
            SendClientMessage(playerid, COLOR_ERROR, str);
            }
        }
   return true;
   }
   samp_mysql_real_escape_string( inputtext,PlayerName );
   format(query, sizeof(query), "INSERT INTO `server_users` (reg_id, player_name, password, admin_level, IP, player_kills, player_deaths, money, ExpToNextLevel) VALUES(0, '%s', '%s', 0, '%s', 0, 0, 20000, 400)", PlayerName, inputtext, PlayerIP);
   samp_mysql_query(query);
   format(query, sizeof(query), "SELECT `reg_id` FROM `server_users` WHERE `player_name` = '%s'", PlayerName);
   samp_mysql_query(query);
   samp_mysql_store_result();

   if(samp_mysql_num_rows() == 0)
   {
      format(str, sizeof(str), "ERROR: SA-MP MySQL Database failure - can't write into `%s`", MYSQL_DB);
      SendClientMessage(playerid, COLOR_ERROR, str);
      return true;
   }

    switch (PlayerInfo[playerid][pKalba])
        {
            case 0:
            {
                format(str, sizeof(str), "Username \"%s\" (password \"%s\") registered.", PlayerName, inputtext);
            SendClientMessage(playerid, COLOR_INFO, str);
            }
            case 1:
            {
                format(str, sizeof(str), "Saskaita \"%s\" (kodas: \"%s\") uћregistruota.", PlayerName,inputtext);
            SendClientMessage(playerid, COLOR_INFO, str);
            }
        }
          PlayerInfo[playerid][pREG]=1;
          
         PlayerInfo[playerid][Level]=1;
         PlayerInfo[playerid][Level]=1;
         PlayerInfo[playerid][pREG]=1;
   }
   if (PlayerInfo[playerid][pREG] == 1)
   {
   new ss[256];
   switch (PlayerInfo[playerid][pKalba])
        {
            case 0:
            {
                format(ss, sizeof(ss), "%s exists. Log in using /login <password>", PlayerName);
            ShowPlayerDialog(playerid,GUI_LOGIN,DIALOG_STYLE_INPUT,"Login",ss,"Login","Cancel");
            }
            case 1:
            {
                format(ss, sizeof(ss), "Saskaita \"%s\" sukurta. Prisijunk naudodamas /jungtis <kodas>.", PlayerName);
            ShowPlayerDialog(playerid,GUI_LOGIN,DIALOG_STYLE_INPUT,"Saskaita",ss,"Prisijungti","Iљeit");
            }
          }
            }
            return 1;
   }
//Login
  if(dialogid == GUI_LOGIN)
      {
      if(response) //Jei paspaudė mygtuką "Sutinku"
      {
  GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    new str[256];
   if(PlayerInfo[playerid][pLogged] == 1)
   {
    switch (PlayerInfo[playerid][pKalba])
        {
            case 0:
            {
                format(str, sizeof(str), "ERROR: You are already logged in (username: \"%s\")", PlayerName);
            SendClientMessage(playerid, COLOR_ERROR, str);
            }
            case 1:
            {
                format(str, sizeof(str), "Klaida: Jūs jau esate prisijungęs (saskaita: \"%s\")", PlayerName);
            SendClientMessage(playerid, COLOR_ERROR, str);
            }
        }
   return true;
   }

   if(PlayerInfo[playerid][pREG]==0 && PlayerInfo[playerid][pLogged]==0)
   {
    switch (PlayerInfo[playerid][pKalba])
        {
            case 0:
            {
                format(str, sizeof(str), "ERROR: Account \"%s\" isn't registered. Please use /register to register!", PlayerName);
            SendClientMessage(playerid, COLOR_ERROR, str);
            }
            case 1:
            {
                format(str, sizeof(str), "KLAIDA: Saskaita \"%s\" neregistruota. Naudokis /registruotis <kodas> kad uћsiregistruotum!", PlayerName);
            SendClientMessage(playerid, COLOR_ERROR, str);
            }
        }
   return true;
   }
   format(query, sizeof(query), "SELECT * FROM `server_users` WHERE `player_name` = '%s'", PlayerName);
   samp_mysql_query(query);
   samp_mysql_store_result();
   samp_mysql_fetch_row(qline);
   samp_mysql_get_field("password", inputtext);
   samp_mysql_free_result();

    switch (PlayerInfo[playerid][pKalba])
        {
            case 0:
            {
                format(str, sizeof(str), "ERROR: \"%s\" is an invalid password for account \"%s\"!", inputtext, PlayerName);
            SendClientMessage(playerid, COLOR_ERROR, str);
            }
            case 1:
            {
                format(str, sizeof(str), "KLAIDA: \"%s\" yra netinkantis kodas saskaitai \"%s\"!", inputtext, PlayerName);
            SendClientMessage(playerid, COLOR_ERROR, str);
            }
        }
   return true;
   }
    PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
    AtkurtiZaidejoInformacija(playerid);
    GetPlayerIp(playerid, PlayerIP, sizeof(PlayerIP));

   format(query, sizeof(query), "UPDATE `server_users` SET `IP` = '%s' WHERE `player_name` = '%s'", PlayerIP, PlayerName);
   samp_mysql_query(query);

   if(PlayerInfo[playerid][pGAdmin]==1){PlayerInfo[playerid][pGangAdm]=PlayerInfo[playerid][pGang];}
   if(PlayerInfo[playerid][pGAdmin]==2){PlayerInfo[playerid][pGangAdm]=PlayerInfo[playerid][pGang];}
      return 1;
   }
Reply
#2

what happens when you register/login?
Reply
#3

Don't let my spawn
Reply
#4

BUMP : )
Reply
#5

I don't know, because in the mysql i'm a newbie
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)