Ban Command
#4

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Actually "name" (misleading variable name) would need to be integer and you'd have to use "r" or "u" specifier in sscanf. GetName function accepts an integer, not a string so that'd give error 035.

Is that the whole code in the command? If not, post the whole command.
All are natives except GetName which is still not reported even if you have -d3 flag.

And remove the cache from memory otherwise you're going to have memory leaks.
How do I remove the cache?

Also I changed everything to "u" specifier however now whenever I type the command it doesn't crash. But nothing is displayed no error message or success message.

PHP код:
 CMD:oban(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < 3) return 0;
    {
        new 
IDquery[250], reason[128], string[128];
        if(
sscanf(params"us[24]"IDreason)) return SendClientMessage(playeridCOLOR_WHITE"Usage: /offlineban [Player Name] [Reason]");
        
mysql_format(ServerMySQLquerysizeof(query), "UPDATE `Users` SET pBanned = %d, pBannedBy = '%s', pReason = '%s' WHERE Name='%s'"1GetName(playerid), reasonGetName(ID));
        
mysql_tquery(ServerMySQLquery"""");
        if (!
cache_affected_rows(ServerMySQL)) return SendClientMessage(playeridCOLOR_RED"Error: That player doesn't exist"); 
        
format(string,sizeof(string), "*You have successfully banned player %s."GetName(ID));
        
SendClientMessage(playeridCOLOR_ADMINstring);
        
format(amsgsizeof(amsg), "[Admin Log]: %s has offline banned player %s [Reason: %s]"GetName(playerid), GetName(ID), reason);
        
ABroadCast(COLOR_ADMIN,amsg1);
        if(
IsPlayerConnected(ID))
        {
            
SetTimerEx("UnsetBan"5000"i"ID);
        }
    }
    return 
1;
}
CMD:unban(playerid,params[])
{
    if(
PlayerInfo[playerid][pAdmin] <= 3) return 0;
    new 
IDquery[300], cmdstring[44], string[128];
    if(
sscanf(params"u"ID)) return SendClientMessage(playeridCOLOR_WHITE,"Usage: /unban [Player Name]");
    
mysql_format(ServerMySQLquerysizeof(query), "UPDATE `Users` SET pBanned = %d, pBannedBy = '%s', pReason = '%s' WHERE Name='%s'"1GetName(playerid), ""GetName(ID));
    
mysql_tquery(ServerMySQLquery"""");
    if(!
cache_affected_rows(ServerMySQL)) return SendClientMessage(playeridCOLOR_RED"Error: That player doesn't exist"); 
    
format(cmdstringsizeof(cmdstring), "unbanip %s"PlayerInfo[ID][pIP]);
    
SendRconCommand(cmdstring);
    
SendRconCommand("reloadbans");
    
format(string,sizeof(string), "*You have successfully unbanned %s."GetName(ID));
    
SendClientMessage(playeridCOLOR_ADMINstring);
    
format(amsgsizeof(amsg), "[Admin Log]: %s has unbanned player %s"GetName(playerid), GetName(ID));
    
ABroadCast(COLOR_ADMIN,amsg1);
    
//UnBlockIpAddress( ip_address );
    
return 1;
}
CMD:banreason(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] <= 3) return 0;
    new 
IDquery[128], string[128], reason[128];
    if(
sscanf(params"u"ID)) return SendClientMessage(playeridCOLOR_WHITE"Usage: /banreason [Player Name]");
    
format(querysizeof(query), "SELECT `pReason` FROM `Users` WHERE `Name` = '%s'"GetName(ID));
    
mysql_query(ServerMySQLquery);
    if(
cache_num_rows())
    {
        
cache_get_field_content(0"pReason"reason);
        if(!
strcmp(reason""false1))
        {
            
format(string,sizeof(string), "[BAN REASON]: %s was banned for: %s",GetName(ID), reason);
            
SendClientMessage(playeridCOLOR_YELLOWstring);
            
format(amsg,sizeof(amsg), "[Admin Log]: %s is requesting ban information on %s"GetName(playerid), GetName(ID));
        }
        else
        {
            
SendClientMessage(playeridCOLOR_RED"Error: That player isn't banned.");
        }
    }
    return 
1;

Reply


Messages In This Thread
Ban Command - by Tass007 - 24.09.2016, 08:06
Re: Ban Command - by X337 - 24.09.2016, 08:54
Re: Ban Command - by Konstantinos - 24.09.2016, 09:01
Re: Ban Command - by Tass007 - 24.09.2016, 09:23
Re: Ban Command - by X337 - 24.09.2016, 09:28
Re: Ban Command - by Tass007 - 24.09.2016, 09:34
Re: Ban Command - by X337 - 24.09.2016, 09:35
Re: Ban Command - by Tass007 - 24.09.2016, 09:40
Re: Ban Command - by X337 - 24.09.2016, 10:12
Re: Ban Command - by Tass007 - 24.09.2016, 11:00

Forum Jump:


Users browsing this thread: 3 Guest(s)