Wrong password issue
#1

If il put wrong password, i get message of wrong password, but if i logg in with right password after the first fail, it says that "Im succefully logged in" but im staying in "TogglePlayerSpectating"
But if i do it first time correctly it works fine. How can i fix it? here is the login stock:

pawn Код:
stock MySQL_Login(playerid)
{
    new query[300], pname[24], savingstring[20];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT PlayerLevel, PlayerAdmin, Score, Vip, Sex, Age, Origin, Money, Bank, PhoneBook, PhoneNr, LottoNr, House, Biz, Car, Bike, HouseKey, BizKey, CarKey, BikeKey, Posx, Posy, Posz, Posa FROM Player WHERE user = '%s'", pname);
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_row_format(query,"|"))
    {
        mysql_fetch_field_row(savingstring, "PlayerLevel"); PlayerInfo[playerid][pLevel] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "PlayerAdmin"); PlayerInfo[playerid][pAdmin] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Score"); SetPlayerScore(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "Vip"); PlayerInfo[playerid][pVip] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Sex"); PlayerInfo[playerid][pSex] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Age"); PlayerInfo[playerid][pAge] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Origin"); PlayerInfo[playerid][pOrigin] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Money"); MoneyGiven[playerid] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Bank"); PlayerInfo[playerid][pBank] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "PhoneBook"); PlayerInfo[playerid][pPhoneBook] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "PhoneNr"); PlayerInfo[playerid][pPhoneNr] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "LottoNr"); PlayerInfo[playerid][pLottoNr] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "House"); PlayerInfo[playerid][pHouse] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Biz"); PlayerInfo[playerid][pBiz] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Car"); PlayerInfo[playerid][pCar] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Bike"); PlayerInfo[playerid][pBike] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "HouseKey"); PlayerInfo[playerid][pHouseKey] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "BizKey"); PlayerInfo[playerid][pBizKey] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "CarKey"); PlayerInfo[playerid][pCarKey] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "BikeKey"); PlayerInfo[playerid][pBikeKey] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Posx"); PlayerInfo[playerid][pPosX] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Posy"); PlayerInfo[playerid][pPosY] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Posz"); PlayerInfo[playerid][pPosZ] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Posa"); PlayerInfo[playerid][pPosA] = strval(savingstring);
    }
    mysql_free_result();
    Logged[playerid] = 1;
    JustLogged[playerid] = 1;
    PlayerInfo[playerid][pLogins]++;
    SendMessage(playerid, "~g~Info: ~w~You have been logged-in!");
    return 1;
}
pawn Код:
if(dialogid == DIALOG_LOGIN)
    {
        if(!response)
        {
            SendClientMessage(playerid, COLOR_WHITE, "Sa valisid 'Katkesta', taaskдivita mдng, et uuesti proovida !");
            TogglePlayerSpectating(playerid, 1);
            Kick(playerid);
        }
        if(response)
        {
            new query[200], pname[24], escapepass[100];
            GetPlayerName(playerid, pname, 24);
            mysql_real_escape_string(inputtext, escapepass);
            format(query, sizeof(query), "SELECT `Name` FROM Player WHERE Name = '%s' AND Password = SHA1('%s')", pname, escapepass);
            mysql_query(query);
            mysql_store_result();
            new numrows = mysql_num_rows();
            if(numrows == 1) MySQL_Login(playerid);
            if(!numrows)
            {
                SendMessage(playerid, "~r~Error: ~w~Vale parool!");
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""Blue"Please log-in", ""White"Welcome back to "Red""SERVER_NAME""White"!\n"White"In order to start playing, you have to log-in!\n\n"White"Please insert "Red"your"White" password below:", "Login", "Cancel");
            }
            mysql_free_result();
        }
        return 1;
    }
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    if(!Logged[playerid])
    {
        if(!JustLogged[playerid])
        {
            TogglePlayerSpectating(playerid, 1);
        }
        if(JustLogged[playerid] == 1)
        {
            SetSpawnInfo( playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 26, 36, 28, 150, 0, 0 );
            SpawnPlayer(playerid);
        }
    }
    return 1;
}
Reply
#2

This shows us nothing, post the code where it checks whether you're inserting a correct password or not.
Reply
#3

Quote:
Originally Posted by Toreno
Посмотреть сообщение
This shows us nothing, post the code where it checks whether you're inserting a correct password or not.
ok, i added other stuff too, what may cause the problem.
Reply
#4

Most likely "OnDialogResponse", where you check the password...
Reply
#5

how can problem lay there? if i get message "You have succefully logged in" i just cant spawn after that, if i have set wrong password before correct one. So, is the problem somewhere in "OnPlayerSpawn" or something?
Reply
#6

bump - Its based of "Making a MySQL system!"
so there must be the same problem then, only that i have tried to remove Spawn button, so maybe that changed something?
Reply
#7

pawn Код:
if(numrows == 1) MySQL_Login(playerid);
if(!numrows)
{
     SendMessage(playerid, "~r~Error: ~w~Vale parool!");
     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""Blue"Please log-in", ""White"Welcome back to "Red""SERVER_NAME""White"!\n"White"In order to start playing, you have to log-in!\n\n"White"Please insert "Red"your"White" password below:", "Login", "Cancel");
}
Use elseif instead of another if-clause, like that you can avoid the second if. Aswell it seems like you would like that you have TogglePlayerSpectating enabled when he's logging in and off when he successfully logged in. So put in the second if-clause TogglePlayerSpectating(playerid, 0) and in the function MySQL_Login TogglePlayerSpectating(playerid, 1), aswell check your function MySQL_Login if you're changing anything about TogglePlayerSpectating there.
Reply
#8

Ok i got it fixed now
Actualy i only needed "TogglePlayerSpectating(playerid, 0)" under "Stock MySQL_Login"
I tought i already used it this way, but maybe i used it on MySQL_Register. Anyways, thnx for reply and there goes some Rep+.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)