MySQL field check OnPlayerConnect
#1

Hello SA-MP!

I am trying to make a ban command with MySQL. I made a field in MySQL called 'BANNED'. If it is Null, then the player isn't banned, if it is set to '1' then the player is banned. So, how would I go about checking if the field is not null or contains '1'?

This is my attempt at it:

pawn Код:
// In OnPlayerConnect...
    format(query2, sizeof(query2), "SELECT `BANNED` from `playerdata` WHERE user = '%s' LIMIT 1", GetName(playerid)); // MySQL query
    mysql_query(query); // Send the query
    mysql_store_result(); // Store the result found with the query
    new BANNED = mysql_fetch_int(); // Create the variable, make the query result the variable (this is where im not sure with the use of mysql_fetch_int();)
    if(BANNED == 1) // Check if the variable is 1
    {
        ShowPlayerDialog(playerid, 05, DIALOG_STYLE_MSGBOX, "{FF0303}[X]{FFFFFF} Banned", "This account is disabled. Check our website ("website") for more information.", "Okay", "");
        Kick(playerid);
    }
    mysql_free_result(); // Free the result
// Rest of code...
Trying to teach myself MySQL, so bear with me please

P.S. No errors or warnings upon compiling.

Thanks in advance.
Reply


Messages In This Thread
MySQL field check OnPlayerConnect - by DBan - 01.07.2012, 07:07

Forum Jump:


Users browsing this thread: 1 Guest(s)