[POMOC] Register i login

Započeo MarQueZ
3. Jan. 2012.
1,641
pregleda
3
postova
Rey_McShakur
4
Shot Caller
3. Jan. 2012.
Skripta koju koristim: Afrika gaming
Detaljan opis problema: Ja sam pokusao napraviti da se igrac moze registrirati preko servera, ali nikako da mi uspije, pa ako mi netko moze pomoci oko toga.
Dio skripte:
	new Pname;
    GetPlayerName(playerid, Pname, 24);
new escpname;
    mysql_real_escape_string(Pname, escpname);
    format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `user` = '%s'", escpname);
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
        new PIP;
        GetPlayerIp(playerid, PIP, 56);
        format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `user` = '%s' AND `IP` = '%s'", escpname, PIP);
        mysql_query(Query);
        mysql_store_result();
        if(mysql_num_rows() != 0)
        {
            new line;
            SetPVarInt(playerid, "Logged", 1);
            SendClientMessage(playerid, 0x009600AA, "Automatsko logiranje");
            if(mysql_fetch_row(line))
            {
                  new data;
                  new data2;
                  sscanf(line, "p|ssdddds", data, data, data2, data2, data2, data2, data);
                  SetPVarInt(playerid, "Kills", data2);
                  SetPVarInt(playerid, "Logged", 1);
                  SetPVarInt(playerid, "Deaths", data2);
                  SetPlayerScore(playerid, data2);
                  GivePlayerMoney(playerid, data2);
                  mysql_free_result();
              }
        }
        if(!mysql_num_rows())
        {
            SendClientMessage(playerid, 0x009600AA, "Ovaj acc je registriran, ulogiraj se");
            ShowPlayerDialog(playerid, 14601, DIALOG_STYLE_PASSWORD , "Login", "Acc je registriran logiraj se!, Ulogiraj se", "OK", "Cancel");
        }
    }
    else
    {
        ShowPlayerDialog(playerid, 14600, DIALOG_STYLE_PASSWORD , "Register", "Ovaj acc nije registriran, Registriraj se!", "OK", "Cancel");
        SendClientMessage(playerid, 0x009600AA, "Ovaj acc nije registriran, Registriraj se!");
    }
    mysql_free_result(); //Frees the result :)

if(dialogid == 14600)
    {
      if(response)
      {
            if(!strlen(inputtext))
            {
                ShowPlayerDialog(playerid, 14600, DIALOG_STYLE_PASSWORD , "Register", "Ovaj acc nije registriran, Registriraj se!", "OK", "Cancel");
                SendClientMessage(playerid, 0x009600AA, "Ovaj acc nije registriran, Registriraj se!");
            }
            new PIP;
new Pname;
            GetPlayerName(playerid, Pname, 24); //Players name
            new escpname;
new 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~Registriranje", 2000, 3);
            SendClientMessage(playerid, 0x0000D9AA, "Registriran i logiran u acc!");
            SetPVarInt(playerid, "Logged", 1);
        }
    }
if(dialogid == 14601)
    {
      if(response)
      {
  new 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, "Netocna lozinka!");
              SetPVarInt(playerid, "WrongPass", GetPVarInt(playerid, "WrongPass") + 1);
              ShowPlayerDialog(playerid, 14601, DIALOG_STYLE_INPUT , "Login", "Acc je registriran logiraj se!, Ulogiraj se", "OK", "Cancel");
              if(GetPVarInt(playerid, "WrongPass") == 3)
              {
                  SendClientMessage(playerid, 0xF60000AA, "Pogrijesno si napisao lozinku 3 pita kick!!");
                  Kick(playerid);
              }
          }
          else
          {
              new line;
              if(mysql_fetch_row(line))
              {
                  new data;
                  new data2;
                  sscanf(line, "p|ssdddds", data, data, data2, data2, data2, data2, data);
                  SetPVarInt(playerid, "Kills", data2);
                  SetPVarInt(playerid, "Logged", 1);
                  SetPVarInt(playerid, "Deaths", data2);
                  SetPlayerScore(playerid, data2);
                  SetPVarInt(playerid, "MoneyGiven", data2);
                  SendClientMessage(playerid, 0x0000D9AA, "Logged in!");
                  mysql_free_result();
              }
          }
      }
    }

public OnPlayerRequestSpawn(playerid)
{
    if(GetPVarInt(playerid, "Logged") == 0)
    {
new Pname;
        GetPlayerName(playerid, Pname, 24);
        new escpname;
        mysql_real_escape_string(Pname, escpname);
        format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `user` = '%s'" , escpname);
        mysql_query(Query); //Queries
        mysql_store_result(); //Stores
        if(!mysql_num_rows()) ShowPlayerDialog(playerid, 14600, DIALOG_STYLE_PASSWORD , "Register", "Ovaj acc nije registriran, Registriraj se!", "OK", "Cancel");
        else ShowPlayerDialog(playerid, 14601, DIALOG_STYLE_PASSWORD , "Login", "Acc je registriran logiraj se!, Ulogiraj se", "OK", "Cancel");
        return 0; //Player won't spawn
    }
    return 1;
}


Neke slike/video za lakse dobivanje pomoci(neobavezno): /
Dr.Ninex
4
Shot Caller
3. Jan. 2012.
skni xampp i radi po ovom tutu
http://balkan-samp.com/forum/index.php?topic=24981.0
Rey_McShakur
4
Shot Caller
3. Jan. 2012.
ma ne kuzis kaj ti hocu rec . radio sam po tom tut-u i sve sam napravio nego se ne mogu registrirat s novim racunom. moram se prvo registrirat na Afrika forumu da mogu igrat na serveru.

Ovako sam ja napravio:
public OnQueryFinish(query[], resultid, extraid, connectionHandle)
{
switch(resultid)
{
case THREAD_CHECK_FOR_ACCOUNT:
{
new
playerPassword,
playerAge,
playerGender,
playerOrigin,
playerLevel,
playerRespect,
playerNRespect,
playerSkin,
playerGSkin,
playerCash,
playerBankCash,
playerJob,
playerGroup,
playerGroupRank,
playerHouse,
playerRentHouse,
playerBizz,
playerCOBizz,
playerCar,
playerBike,
playerBicycle,
playerAdmin,
playerLeader,
playerMember,
playerGamedude;

mysql_store_result();
if(mysql_fetch_row(query)) // Ima korisnicki racun
{
sscanf(query, "p<|>{s}siisiiiiiiiiiiiiiiiiiiiii",
playerPassword,
playerAge,
playerGender,
playerOrigin,
playerLevel,
playerRespect,
playerNRespect,
playerSkin,
playerGSkin,
playerCash,
playerBankCash,
playerJob,
playerGroup,
playerGroupRank,
playerHouse,
playerRentHouse,
playerBizz,
playerCOBizz,
playerCar,
playerBike,
playerBicycle,
playerAdmin,
playerLeader,
playerMember,
playerGamedude
);

SetPVarString(extraid, "Password", playerPassword);
SetPVarString(extraid, "Origin", playerOrigin);

SetPVarInt(extraid, "Age", playerAge);
SetPVarInt(extraid, "Gender", playerGender);
SetPVarInt(extraid, "Level", playerLevel);
SetPVarInt(extraid, "Respect", playerRespect);
SetPVarInt(extraid, "NRespect", playerNRespect);
SetPVarInt(extraid, "Skin", playerSkin);
SetPVarInt(extraid, "GSkin", playerGSkin);
SetPVarInt(extraid, "Cash", playerCash);
SetPVarInt(extraid, "BankCash", playerBankCash);
SetPVarInt(extraid, "Job", playerJob);
SetPVarInt(extraid, "Group", playerGroup);
SetPVarInt(extraid, "GroupRank", playerGroupRank);
SetPVarInt(extraid, "House", playerHouse);
SetPVarInt(extraid, "RentHouse", playerRentHouse);
SetPVarInt(extraid, "Biiz", playerBizz);
SetPVarInt(extraid, "COBizz", playerCOBizz);
SetPVarInt(extraid, "Car", playerCar);
SetPVarInt(extraid, "Bike", playerBike);
SetPVarInt(extraid, "Bicycle", playerBicycle);
    SetPVarInt(extraid, "Admin",playerAdmin);
    SetPVarInt(extraid, "Leader",playerLeader);
    SetPVarInt(extraid, "Member",playerMember);
    SetPVarInt(extraid, "Gamedude",playerGamedude);

format(Query, sizeof(Query), ""C_RED"DOB"C_YELLOW"RODO"C_GREEN"SAO"C_WHITE", {0cc0ff}%s!\n\n"C_RED"Ti imas registrirani korisnicki racun.\n"C_YELLOW"Logiraj se tako da upises svoju lozinku.\n"C_GREEN"Sretno u daljnjoj igri!", GetName(extraid));
ShowPlayerDialog(extraid, 1, DIALOG_STYLE_INPUT, ""C_RED"Role"C_YELLOW"Side "C_WHITE"| "C_GREEN"Logiranje", Query, "Logiraj se", "Izlaz");

mysql_free_result();
}
else // Nema korisnicki racun
{
format(Query, sizeof(Query), ""C_RED"DOB"C_YELLOW"RODO"C_GREEN"SAO"C_WHITE", {0cc0ff}%s!\n\nDa se registriras moras otici na nasu stranicu UCP-a.\nURL naseg UCP-a: http://afrika-gaming.com/ucp", GetName(extraid));
ShowPlayerDialog(extraid, 0, DIALOG_STYLE_MSGBOX, ""C_RED"Role"C_YELLOW"Side "C_WHITE"| "C_GREEN"Registracija", Query, "U redu", "");
}
}
}
return 1;
}


A bilo je ovako:
public OnQueryFinish(query[], resultid, extraid, connectionHandle)
{
switch(resultid)
{
case THREAD_CHECK_FOR_ACCOUNT:
{
new
playerPassword,
playerAge,
playerGender,
playerOrigin,
playerLevel,
playerRespect,
playerNRespect,
playerSkin,
playerGSkin,
playerCash,
playerBankCash,
playerJob,
playerGroup,
playerGroupRank,
playerHouse,
playerRentHouse,
playerBizz,
playerCOBizz,
playerCar,
playerBike,
playerBicycle,
playerAdmin,
playerLeader,
playerMember,
playerGamedude;

mysql_store_result();
if(mysql_fetch_row(query)) // Ima korisnicki racun
{
sscanf(query, "p<|>{s}siisiiiiiiiiiiiiiiiiiiiii",
playerPassword,
playerAge,
playerGender,
playerOrigin,
playerLevel,
playerRespect,
playerNRespect,
playerSkin,
playerGSkin,
playerCash,
playerBankCash,
playerJob,
playerGroup,
playerGroupRank,
playerHouse,
playerRentHouse,
playerBizz,
playerCOBizz,
playerCar,
playerBike,
playerBicycle,
playerAdmin,
playerLeader,
playerMember,
playerGamedude
);

SetPVarString(extraid, "Password", playerPassword);
SetPVarString(extraid, "Origin", playerOrigin);

SetPVarInt(extraid, "Age", playerAge);
SetPVarInt(extraid, "Gender", playerGender);
SetPVarInt(extraid, "Level", playerLevel);
SetPVarInt(extraid, "Respect", playerRespect);
SetPVarInt(extraid, "NRespect", playerNRespect);
SetPVarInt(extraid, "Skin", playerSkin);
SetPVarInt(extraid, "GSkin", playerGSkin);
SetPVarInt(extraid, "Cash", playerCash);
SetPVarInt(extraid, "BankCash", playerBankCash);
SetPVarInt(extraid, "Job", playerJob);
SetPVarInt(extraid, "Group", playerGroup);
SetPVarInt(extraid, "GroupRank", playerGroupRank);
SetPVarInt(extraid, "House", playerHouse);
SetPVarInt(extraid, "RentHouse", playerRentHouse);
SetPVarInt(extraid, "Biiz", playerBizz);
SetPVarInt(extraid, "COBizz", playerCOBizz);
SetPVarInt(extraid, "Car", playerCar);
SetPVarInt(extraid, "Bike", playerBike);
SetPVarInt(extraid, "Bicycle", playerBicycle);
    SetPVarInt(extraid, "Admin",playerAdmin);
    SetPVarInt(extraid, "Leader",playerLeader);
    SetPVarInt(extraid, "Member",playerMember);
    SetPVarInt(extraid, "Gamedude",playerGamedude);

format(Query, sizeof(Query), ""C_RED"DOB"C_YELLOW"RODO"C_GREEN"SAO"C_WHITE", {0cc0ff}%s!\n\n"C_RED"Ti imas registrirani korisnicki racun.\n"C_YELLOW"Logiraj se tako da upises svoju lozinku.\n"C_GREEN"Sretno u daljnjoj igri!", GetName(extraid));
ShowPlayerDialog(extraid, 1, DIALOG_STYLE_INPUT, ""C_RED"A"C_YELLOW"G "C_WHITE"| "C_GREEN"Logiranje", Query, "Logiraj se", "Izlaz");

mysql_free_result();
}
else // Nema korisnicki racun
{
format(Query, sizeof(Query), ""C_RED"DOB"C_YELLOW"RODO"C_GREEN"SAO"C_WHITE", {0cc0ff}%s!\n\nDa se registriras moras otici na nasu stranicu UCP-a.\nURL naseg UCP-a: http://afrika-gaming.com/ucp", GetName(extraid));
ShowPlayerDialog(extraid, 0, DIALOG_STYLE_MSGBOX, ""C_RED"A"C_YELLOW"G "C_WHITE"| "C_GREEN"Registracija", Query, "U redu", "");
}
}
}
return 1;
}

Morate biti prijavljeni da biste odgovorili na ovu temu.

Prijava

© 2026 SmartShark. All rights reserved.

Powered by Momentum|v2026.3.001 Alpha