#1

I have a problem with loading last player connect date and last player connected IP. It is always null! But the values in PMA is not null :3 Tried to print, everything is fine.

OnPlayerConnect:

pawn Код:
format(szQuery, 77, "SELECT `Name` FROM `players` WHERE `Name` = '%s'", GetPlayerNameEx(playerid));
mysql_function_query(iHandle, szQuery, true, "OnPlayerConnectEx", "ds", playerid, szName[playerid]);
OnPlayerConnectEx:

pawn Код:
PUB::OnPlayerConnectEx(playerid, Name[])
{
    new iFields, iRows;
       
    cache_get_data(iRows, iFields);
    if (iRows)
    {
           // login check
    }
    else
    {
           // register
    }
    return true;
}

Login:

pawn Код:
format(szQuery, 77, "SELECT `Name` FROM `players` WHERE `Name` = '%s'", GetPlayerNameEx(playerid));
mysql_function_query(iHandle, szQuery, true, "OnPlayerLogin", "dsd", playerid, GetPlayerNameEx(playerid), 1);
OnPlayerLogin:

pawn Код:
PUB::OnPlayerLogin(playerid, Name[], ResultID)
{
    new szQuery[213], iFields, iRows;
       
    switch (ResultID)
    {
        case 1:
        {
            cache_get_data(iRows, iFields);
            format(szQuery, 61, "SELECT `IP` FROM `players` WHERE `IP` = '%s'", GetPlayerIpEx(playerid));
            mysql_function_query(iHandle, szQuery, true, "OnPlayerLogin", "dsd", playerid, GetPlayerNameEx(playerid), (iRows) ? (2) : (3));
        }
        case 2:
        {
            cache_get_data(iRows, iFields);
            if (iRows)
            {
                format(szQuery, 125, "SELECT `LastSeen`, `LastIP` FROM `players` WHERE `Name` = '%s'", GetPlayerNameEx(playerid));
                mysql_function_query(iHandle, szQuery, true, "OnPlayerLogin", "dsd", playerid, GetPlayerNameEx(playerid), 5);
            }
            else
            {
                // The IP doesnt match with registration IP,  let's open login dialog
            }
        }
        case 3:
        {
            cache_get_data(iRows, iFields);
            if (iRows >= MAX_ACCOUNTS_PER_IP)
            {
                // Player haves 3 accounts already, kick him.
                Kick(playerid);
            }
            else
            {
                // Player doesnt have more than three accounts, open registration dialog
            }
        }
        case 4:
        {
            cache_get_data(iRows, iFields);
            if (iRows)
            {
                format(szQuery, 125, "SELECT `LastSeen`, `LastIP` FROM `players` WHERE `Name` = '%s'", GetPlayerNameEx(playerid));
                mysql_function_query(iHandle, szQuery, true, "OnPlayerLogin", "dsd", playerid, GetPlayerNameEx(playerid), 5);
            }
            else
            {
                if (iBadPassword[playerid] == MAX_PASSWORD_WARNS - 1)
                {
                    // Player entered wrong password three times. Kick him
                    Kick(playerid);
                    return true;
                }
                // Player havent entered wrong password three times, lets open login dialog.
                iBadPassword[playerid] += 1;
            }
        }
        case 5:
        {
            cache_get_row(0, 0, pInfo[playerid][statsLastSeen]);
            cache_get_row(0, 1, pInfo[playerid][statsLastIP]);

            printf("Last Seen: %s\nLast IP: %s", date(pInfo[playerid][statsLastSeen]), pInfo[playerid][statslastIP]);

            strcpy(pInfo[playerid][statsLastIP], GetPlayerIpEx(playerid), 17);
            pInfo[playerid][statsLastSeen] = GetCurrentDateInUnix();
            iLoggedIn[playerid] = true;
        }
    }
    return true;
}
Functions date(), GetCurrentDateInUnix(), GetPlayerIpEx() works fine in other places..
Reply
#2

Anyone?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)