CheckPlayerSuspended(playerid);
#1

pawn Код:
CheckPlayerSuspended(playerid)
{
    new str[128], ans;
    format(str,sizeof(str),"SELECT * FROM kick_ban_jail_log WHERE type = 1");
    mysql_query(str);
    mysql_store_result();
    new row[256]; // The length of 1 'row' total.
    new field[9][128]; // [4] = Amount of fields, [24] = Max length of the bigest field.
    mysql_fetch_row(row, "|");
    explode(row, field, "|");
    mysql_free_result();
    if(strcmp(field[0],pName(playerid),false)) return 1;
    new day,month,year;
    getdate(year,month,day);
    if(year <= strval(field[8]))
    {
        if(month <= strval(field[7]))
        {
            if(day < strval(field[6]))
            {
                ans = 1;
            }
            else ans = 0;
        }
    }
    printf("%d",ans);
    return ans;
}
I did this. It's placed on OnPlayerConnect to check if player's banned.

My problem is: It always returns 0 even though the player is banned.
Help please.
Reply
#2

pawn Код:
CheckPlayerSuspended(playerid)
{
    new str[128], ans;
    format(str,sizeof(str),"SELECT * FROM kick_ban_jail_log WHERE type = 1 AND username = '%s'",pName(playerid));
    mysql_query(str);
    mysql_store_result();
    new row[256]; // The length of 1 'row' total.
    new field[9][128]; // [4] = Amount of fields, [24] = Max length of the bigest field.
    mysql_fetch_row(row, "|");
    explode(row, field, "|");
    mysql_free_result();
    new day,month,year;
    getdate(year,month,day);
    /*if(year <= strval(field[8]) && month <= strval(field[7]) && day < strval(field[6]))
    {
        ans = 1;
    }*/

    if(year <= strval(field[8]))
    {
        if(month < strval(field[7])) ans = 1;
        else if(month == strval(field[7]) && day < strval(field[6])) ans = 1;
        else ans = 0;
    }
    else ans = 0;
    printf("%d",ans);
    return ans;
}
SOLVED!
Reply
#3

New problem:
pawn Код:
CheckPlayerSuspended(playerid)
{
    new str[128], ans;
    format(str,sizeof(str),"SELECT * FROM kick_ban_jail_log WHERE type = 1 AND username = '%s'",pName(playerid));
    mysql_query(str);
    mysql_store_result();
    new row[256]; // The length of 1 'row' total.
    new field[9][128]; // [4] = Amount of fields, [24] = Max length of the bigest field.
    mysql_fetch_row(row, "|");
    explode(row, field, "|");
    new day,month,year;
    getdate(year,month,day);
    if(year <= strval(field[8]))
    {
        if(month < strval(field[7])) ans = 1;
        else if(month == strval(field[7]) && day < strval(field[6])) ans = 1;
        else ans = 0;
    }
    else ans = 0;
    mysql_free_result();
    return ans;
}
This only works if the banlog has 1 row. how would I loop through all rows and set the value?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)