OnPlayerConnect
#1

I need some help with my MySQL script. When I connect it lets me login straight away when sometimes my password doesn't match and also the account doesn't exist:

OnPlayerConnect:
pawn Код:
public OnPlayerConnect(playerid)
{
    playerinfo[playerid][Try]=0;
    SetPlayerPos(playerid,-2147.8987,-2462.0483,30.8516);
    SetPlayerCameraPos(playerid,-2051.2012,-2197.7373,75.6403);
    SetPlayerCameraLookAt(playerid,-2145.9492,-2366.4294,37.9938);
    GetPlayerIp(playerid,playerinfo[playerid][IP],16);
    GetPlayerName(playerid,playerinfo[playerid][playername2],MAX_PLAYER_NAME);
    format(queryEX,128,"SELECT `id` FROM `users` AND `del`=0 ORDER BY `id` ASC;",playerinfo[playerid][id]);
    mysql_query(queryEX);
    mysql_store_result();
    if(!mysql_num_rows())
    {
        mysql_free_result();
        SendClientMessage(playerid,COLOR_LIGHTRED,"Create a character at: http://cp.....com");
        Kick(playerid);
    }
    else
    {
        mysql_free_result();
        format(queryEX,128,"SELECT `ban` FROM `users` WHERE `id`='%d';",playerinfo[playerid][id]);
        mysql_query(queryEX);
        mysql_store_result();
        mysql_fetch_row(resultEX);
        mysql_free_result();
        if(strval(resultEX))
        {
            Ban(playerid);
        }
        else
        {
            format(queryEX,128,"UPDATE `users` SET `online`='1' WHERE `id`='%d'",playerinfo[playerid][id]);
            mysql_query(queryEX);
            format(queryEX,128,"SELECT `ip` FROM `users` WHERE `id`='%d' LIMIT 1;",playerinfo[playerid][id]);
            mysql_query(queryEX);
            mysql_store_result();
            mysql_fetch_row(resultEX);
            mysql_free_result();
            if(!strcmp(playerinfo[playerid][IP],resultEX,true))
            {
                format(queryEX,512,"INSERT INTO `ulog_ip` (`name`,`ip`) VALUES ('%s','%s');",playerinfo[playerid][playername],playerinfo[playerid][IP]);
                mysql_query(queryEX);
            }
            playerinfo[playerid][sel_char]=-1;
            SetPlayerColor(playerid,COLOR_INV);
            format(String, sizeof(String), "Welcome back %s! Please enter your password to login.",playerinfo[playerid][playername]);
            ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Login", String, "Login","Cancel");
        }
    }
    return 1;
}
This is my OnDialogResponse.
pawn Код:
case LOGIN:
        {
            if((inputtext[0]==0)&&response)
            {
                format(String, sizeof(String), "Welcome back %s! Please enter your password to login.",playerinfo[playerid][playername]);
                ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Login", String, "Login", "Cancel");
            }
            else if(!response)
            {
                SendClientMessage(playerid,COLOR_RED,"Connection canceled!");
                Kick(playerid);
                return 1;
            }
            else
            {
                new String2[256];
                format(stringEX,128,"SELECT `pass` FROM `users` WHERE `id`='%d' LIMIT 1;",playerinfo[playerid][id]);
                mysql_query(stringEX);
                mysql_store_result();
                mysql_fetch_row(String2);
                mysql_free_result();
                new pass[50];
                format(pass,50,"%s",strlen(inputtext));
                if(!strcmp(String2, inputtext, false) && strlen(inputtext))
                {
                    format(stringEX,128,"Welcome back %s!",playerinfo[playerid][playername]);
                    SendClientMessage(playerid,COLOR_LIGHTYELLOW,stringEX);
                    playerinfo[playerid][login]=true;
                    playerinfo[playerid][updatereduce]=30;
                    getdate(yearEX,monthEX,dayEX);
                    gettime(hourEX,minEX,secEX);
                    format(queryEX, 256, "UPDATE `users` SET `timestamp`='%d/%d/%d - %d:%d:%d' WHERE `id`='%d' LIMIT 1;",yearEX,monthEX,dayEX,hourEX,minEX,secEX,playerinfo[playerid][id]);
                    mysql_query(queryEX);
                    freeze(playerid,0);
                }
                else
                {
                    playerinfo[playerid][Try]++;
                    format(stringEX,128,"Wrong password (%d/3)!",playerinfo[playerid][Try]);
                    ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Login", stringEX, "Login", "Cancel");
                    if(playerinfo[playerid][Try]==3)
                    {
                        SendClientMessage(playerid,COLOR_RED,"You have tried three times. You have been kicked from the server.");
                        Kick(playerid);
                    }
                }
            }
        }
Reply
#2

Make sure you don't use blank strings in strcmp
Reply
#3

I haven't got any strcmp commands my script only dcmd.
Reply
#4

...
Maybe you could just ask in the topic you got this
Reply
#5

I got this from a friend, its a bugged script which hasn't been relised in SA:MP forums
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)