[Help - MySQL] Offline Ban not working
#5

Okay, so I made this

PHP код:
CMD:oban(playeridparams[])// Banning offline players
{
    new 
bannedAdminName[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME], str[128], reason[32], query[128];
    
GetPlayerRPName(playeridAdminNamesizeof(AdminName));
    
GetPlayerName(bannedPlayerNamesizeof(PlayerName));
    if(
PlayerInfo[playerid][Admin] > 3)
    {
        if(
sscanf(params"s[24] s[24]"PlayerNamereason)) return SendClientMessage(playeridCOLOR_DARKCORAL"[BS] {AFAFAF}USAGE: /o(ffline)ban [Player NAME] [Reason]");
        
mysql_format(g_Sqlquerysizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%e' LIMIT 1"PlayerName);
        
mysql_tquery(g_Sqlquery"OffBan""is"playeridPlayerName);
        
printf(query);
        
format(strsizeof(str), "[BS] {AA3333} %s has offline banned %s. Reason: %s"AdminNamePlayerNamereason);
        
SendClientMessageToAll(COLOR_DARKCORALstr);
    }
    else
    {
        
SendClientMessage(playeridCOLOR_DARKCORAL"[BS] {AFAFAF}You cannot use this command!");
    }
    return 
1;

PHP код:
forward OffBan(playeridBanned); 
PHP код:
public OffBan(playeridBanned)
{
    new 
rowsfieldsquery[128], isOBanned 0;
    
cache_get_row_count(rows);
    
cache_get_field_count(fields);
    if(
rows)
    {
        
cache_get_value_name_int(0"isBanned"isOBanned);
        if(
isOBanned == 1)
        {
            
SendClientMessage(playeridCOLOR_DARKCORAL"[BS] {AFAFAF}That player is already banned!");
            return 
1;
        }
        
mysql_format(g_Sqlquerysizeof(query), "UPDATE `accounts` SET `isBanned` = 1 WHERE `Name` = %e"Banned);
        
mysql_tquery(g_Sqlquery"""");
        
printf(query);
    }
    else if(!
rows)
    {
        
SendClientMessage(playeridCOLOR_DARKCORAL"[BS] {AFAFAF}That player doesn't exist!");
        return 
1;
    }
    return 
1;

If I change "UPDATE `accounts` SET `isBanned` = 1 WHERE `Name` = %e" to "UPDATE `accounts` SET `isBanned` = 1", all the accounts get banned, so I don't know why I have a SELECT in the cmd: oban

Here's the output:





Also, how can I make a check if the return is 0 from the callback so I could do something? Like: If(isReturned(0)) return 1;
Reply


Messages In This Thread
[SOLVED by X337] Offline Ban not working - by Sibuscus - 21.03.2017, 18:26
Re: [Help - MySQL] Offline Ban not working - by verlaj - 21.03.2017, 18:50
Re: [Help - MySQL] Offline Ban not working - by AndySedeyn - 21.03.2017, 18:53
Re: [Help - MySQL] Offline Ban not working - by Vince - 21.03.2017, 19:15
Re: [Help - MySQL] Offline Ban not working - by Sibuscus - 22.03.2017, 12:46
Re: [Help - MySQL] Offline Ban not working - by X337 - 22.03.2017, 13:04
Re: [Help - MySQL] Offline Ban not working - by Sibuscus - 22.03.2017, 13:16
Re: [Help - MySQL] Offline Ban not working - by X337 - 22.03.2017, 13:23
Re: [Help - MySQL] Offline Ban not working - by Sibuscus - 22.03.2017, 18:35

Forum Jump:


Users browsing this thread: 1 Guest(s)