[POMOC] Register i login

Započeo MarQueZ, Januar 03, 2012, 14:23:40 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

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[24];
    GetPlayerName(playerid, Pname, 24);
new escpname[24];
    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[56];
        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[750];
            SetPVarInt(playerid, "Logged", 1);
            SendClientMessage(playerid, 0x009600AA, "Automatsko logiranje");
            if(mysql_fetch_row(line))
            {
                   new data[3][50];
                   new data2[4];
                   sscanf(line, "p|ssdddds", data[0], data[1], data2[0], data2[1], data2[2], data2[3], data[2]);
                   SetPVarInt(playerid, "Kills", data2[0]);
                   SetPVarInt(playerid, "Logged", 1);
                   SetPVarInt(playerid, "Deaths", data2[1]);
                   SetPlayerScore(playerid, data2[2]);
                   GivePlayerMoney(playerid, data2[3]);
                   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[50];
new Pname[24];
            GetPlayerName(playerid, Pname, 24); //Players name
            new escpname[24];
new escpass[100];
            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[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, "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[750];
               if(mysql_fetch_row(line))
               {
                   new data[3][50];
                   new data2[4];
                   sscanf(line, "p|ssdddds", data[0], data[1], data2[0], data2[1], data2[2], data2[3], data[2]);
                   SetPVarInt(playerid, "Kills", data2[0]);
                   SetPVarInt(playerid, "Logged", 1);
                   SetPVarInt(playerid, "Deaths", data2[1]);
                   SetPlayerScore(playerid, data2[2]);
                   SetPVarInt(playerid, "MoneyGiven", data2[3]);
                   SendClientMessage(playerid, 0x0000D9AA, "Logged in!");
                   mysql_free_result();
               }
           }
       }
    }


public OnPlayerRequestSpawn(playerid)
{
    if(GetPVarInt(playerid, "Logged") == 0)
    {
new 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'" , 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): /
Mike Marquez | House of Rave is Trippy Place ! |


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[129],
playerAge,
playerGender,
playerOrigin[13],
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[24]}s[129]iis[13]iiiiiiiiiiiiiiiiiiiii",
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[129],
playerAge,
playerGender,
playerOrigin[13],
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[24]}s[129]iis[13]iiiiiiiiiiiiiiiiiiiii",
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;
}
Mike Marquez | House of Rave is Trippy Place ! |