[Pomoc]Spawn nako Logina

Započeo FireMan
2. Jul 2011.
1,142
pregleda
6
postova
Dave
5
Underboss
2. Jul 2011.
Skripta koju koristim:MojMod od 0
Detaljan opis problema:Radio sam MySQL login/register po jednom TuT-u sa Sa-Mp Foruma ali kad se Login/Registriram ne spawna me,na 3 mjesta sam stavio SpawnPlayer(playerid);,evo vam OnPlayerConnect i OnDialogResponse
Dio skripte:public OnPlayerConnect(playerid)
{
    new Query, Pname, escpname; //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; //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;
            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; //The data strings
                  new data2; //The data variables
                  sscanf(line, "p|ssdddds", data, data, data2, data2, data2, data2, data); //Splits the line with sscanf
                  SetPVarInt(playerid, "Kills", data2); //Sets Pvar ints
                  SetPVarInt(playerid, "Logged", 1); //Sets Pvar ints
                  SetPVarInt(playerid, "Deaths", data2); //Sets Pvar ints
                  SetPlayerScore(playerid, data2); //Sets players score
                  GivePlayerMoney(playerid, data2); //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;
}

I...

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 14600)
    {
      if(response)
      {
            if(!strlen(inputtext)) //If the player doesn't enter a pass
            {
                ShowPlayerDialog(playerid, 14600, DIALOG_STYLE_INPUT , "Register", "This account is not registered, please register!", "OK", "Cancel");
                SendClientMessage(playerid, 0xF60000AA, "Please enter a password");
            }
            new PIP;
            new Query, Pname;
            GetPlayerName(playerid, Pname, 24); //Players name
            new escpname, escpass;
            mysql_real_escape_string(inputtext, escpass);
            mysql_real_escape_string(Pname, escpname); //escapes the string so you cant MySQL inject
            GetPlayerIp(playerid, PIP, 50); //Players IP
            format(Query, sizeof(Query), "INSERT INTO `playerinfo` (`user`, `password`, `kills`, `deaths`, `score`, `money`, IP) VALUES ('%s', '%s', 0, 0, 0, 0, '%s')", escpname, escpass, PIP); //Insert string
            mysql_query(Query); //Queries
            GameTextForPlayer(playerid, "~g~Registered", 2000, 3);
            SendClientMessage(playerid, 0x0000D9AA, "Registered and Logged into your account!");
            SetPVarInt(playerid, "Logged", 1);
            SpawnPlayer(playerid);
        }
    }
    if(dialogid == 15000)
    {
      if(response)
      {
          new Query, Pname;
          GetPlayerName(playerid, Pname, 24);
          new escpname;
          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; //I know it's big D=
              if(mysql_fetch_row(line)) //Fetches the line
              {
                  new data; //The data strings
                  new data2; //The data variables
                  sscanf(line, "p|ssdddds", data, data, data2, data2, data2, data2, data); //Splits the line with sscanf
                  SetPVarInt(playerid, "Kills", data2); //Sets Pvar ints
                  SetPVarInt(playerid, "Logged", 1); //Sets Pvar ints
                  SetPVarInt(playerid, "Deaths", data2); //Sets Pvar ints
                  SetPlayerScore(playerid, data2); //Sets players score
                  SetPVarInt(playerid, "MoneyGiven", data2); //Sets players cash
                  SendClientMessage(playerid, 0x0000D9AA, "Logged in!");
                  mysql_free_result();
                  SpawnPlayer(playerid);
              }
          }
      }
    }
    return 1;

Neke slike/video za lakse dobivanje pomoci(neobavezno): 
Luis
5
Godfather
2. Jul 2011.
jel kad stinse onio dole spawn da li ti se spawna ??
Dave
5
Underboss
2. Jul 2011.
Da,ali ja zelim da mi se spawna odma nakon logina
Luis
5
Godfather
2. Jul 2011.
Akos i radio po tut sa foru msampa jel imas

public OnPlayerRequestSpawn(playerid)
{
    if(GetPVarInt(playerid, "Logged") == 0)
    {
        new Query, Pname; //Variables
        GetPlayerName(playerid, Pname, 24); //Gets the player name
        new escpname;   
        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); //MySQL string
        mysql_query(Query); //Queries
        mysql_store_result(); //Stores
        if(!mysql_num_rows()) ShowPlayerDialog(playerid, 14600, DIALOG_STYLE_INPUT , "Register", "This account is not registered, please register!", "OK", "Cancel"); //If the user is not found it will show the register dialog
        else ShowPlayerDialog(playerid, 15000, DIALOG_STYLE_INPUT , "Login", "This account is registered, please login", "OK", "Cancel"); //If the user is not found it will show the login dialog
        return 0; //Player won't spawn
    }
    return 1;
}

??
Dave
5
Underboss
Luis
5
Godfather
2. Jul 2011.
Stavi u ovaj public isto sapwnplayer :
public OnPlayerRequestSpawn(playerid)
{
    if(GetPVarInt(playerid, "Logged") == 0)
    {
        new Query, Pname; //Variables
        GetPlayerName(playerid, Pname, 24); //Gets the player name
        new escpname;   
        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); //MySQL string
        mysql_query(Query); //Queries
        mysql_store_result(); //Stores
        if(!mysql_num_rows()) ShowPlayerDialog(playerid, 14600, DIALOG_STYLE_INPUT , "Register", "This account is not registered, please register!", "OK", "Cancel"); //If the user is not found it will show the register dialog
        else ShowPlayerDialog(playerid, 15000, DIALOG_STYLE_INPUT , "Login", "This account is registered, please login", "OK", "Cancel"); //If the user is not found it will show the login dialog
        return 0; //Player won't spawn
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(GetPVarInt(playerid, "Logged") == 1 && GetPVarInt(playerid, "MoneyGiven") > 0)
    {
        GivePlayerMoney(playerid, GetPVarInt(playerid, "MoneyGiven")); //Cant give cash on OnPlayerConnect
        SetPVarInt(playerid, "MoneyGiven", 0);
    }
    return 1;
}

Morate biti prijavljeni da biste odgovorili na ovu temu.

Prijava

© 2026 SmartShark. All rights reserved.

Powered by Momentum|v2026.3.001 Alpha