Unban Command [MYSQL] Help
#1

Hello guys.i've been configuring trying to make a unban command. but can someone help me? when i type /unban and unban someone it say's the player name doesn't exist on database. can anyone help me?

Code:
pawn Код:
CMD:unban(playerid, params[])
{
    new
        String[128],
        account[24],
        Query[128]
      ;
    if(pInfo[playerid][Adminlevel] < 4) return SendClientMessage(playerid, COLOR_RED_ERROR,"You are not Authorized to use this command");
    //
    if(!strlen(params)) return SendClientMessage(playerid,COLOR_RED_ERROR,"Usage: /unban (Player Name)");
    //
    if(strlen(account) > 24) return SendClientMessage(playerid, COLOR_RED_ERROR, "Name of the player can't exceed 24 characters.");
    {
    format(Query, sizeof(Query), "SELECT Username FROM users WHERE Banned = 1 AND Username = '%s'", PlayerName(playerid));
    mysql_query(Query);
    mysql_store_result();
    if(!mysql_num_rows())
    {
    mysql_free_result();
    format(String, sizeof(String), "This user doesn't exist.", account);
    return SendClientMessage(playerid, COLOR_RED_ERROR, String);
    }
    else if(mysql_num_rows() != 0)
    {

    format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `Username` = '%s' ", account);
    mysql_query(Query);
    mysql_store_result();
    mysql_fetch_row_format(Query, "|");
    sscanf(Query, "p<|>e<s[26]s[512]iiiiiiiiiiiiiiiiiiiis[17]i>", pInfo[100]);
    mysql_free_result();
    new ubs[128];
    format(ubs,128,"unbanip %s",pInfo[100][IpAdress]);
    SendRconCommand(ubs);
    SendRconCommand("Reloadbans");
    format(String, sizeof(String), "You have succesfuly unbanned %s!", account);
    SendClientMessage(playerid, COLOR_GREEN, String);
    }
    }
    //
    format(String, sizeof(String), "%s has been unbanned. (IP and Name)",params);
    SendClientMessage(playerid,COLOR_RED_ERROR,String);
    return 1;
}
Reply
#2

Well what you have there is checking if YOU are banned and not the username that you've typed ..and also
Код:
This user doesn't exist.
If you type a user that exist in DB but doesn't have Banned = 1 it's gonna say the user doesn't exist.. but he does.So you need to change that text
Also .. if you have sscanf ..why not use it ? In commands i mean.. if i'm not mistaken zcmd+sscanf are the fastest in terms of commands
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)