Unban-IP Command doenst work
#8

IP is not a number (@Yaa) but a text, he had used "s" specifier correctly. You don't even need sscanf in the first place for a single string. One string and re-formatting is also a good practice than many strings for different purposes and GetPlayerPoolSize (which was added in 0.3.7) for loops if you don't use foreach.

PHP код:
// if not defined by the include:
#if !defined isnull
    #define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
ocmd:unbanip(playeridparams[])
{
    if (!
IsAdmin(playerid2)) return noaccess
    
if (isnull(params)) return SendClientMessage(playerid, -1"/unbanip <IP>");
    if (!
IsValidIp(params)) return SendClientMessage(playerid, -1"Not a valid IP address.");
  
    new 
str[87];
    
format(strsizeof(str), "%s hat die IP %s erfolgreich entbannt!"PlayerName(playerid), params);
  
    for (new 
0GetPlayerPoolSize(); <= ji++)
    {
        if (!
PlayerOnline(i)) continue;
        if (!
IsAdmin(i2)) continue;
      
        
SendClientMessage(iGELBstr);
    }
  
    
format(strsizeof(str), "%s hat die IP-Adresse : %s erfolgreich entbannt!"PlayerName(playerid), params);
    
AddLog("log_unbanip.txt"str);
    
    
format(strsizeof(str), "unbanip %s"params);
    
SendRconCommand(str);
    
SendRconCommand("reloadbans");
    return 
1;
}
IsValidIp(const player_ip[])
{
    new 
p_ip[4];
    return !
sscanf(player_ip"p<.>a<i>[4]"p_ip) && (<= p_ip[0] <= 255) && (<= p_ip[1] <= 255) && (<= p_ip[2] <= 255) && (<= p_ip[3] <= 255);

EDIT: In the format, there was % instead of %s by the way - just noticed it after your comment.
Reply


Messages In This Thread
Unban-IP Command doenst work - by amaruwhite - 23.10.2016, 15:13
Re: Unban-IP Command doenst work - by Yaa - 23.10.2016, 15:17
Re: Unban-IP Command doenst work - by amaruwhite - 23.10.2016, 15:31
Re: Unban-IP Command doenst work - by Yaa - 23.10.2016, 15:40
Re: Unban-IP Command doenst work - by amaruwhite - 23.10.2016, 15:46
Re: Unban-IP Command doenst work - by amaruwhite - 23.10.2016, 15:48
Re: Unban-IP Command doenst work - by Yaa - 23.10.2016, 15:52
Re: Unban-IP Command doenst work - by Konstantinos - 23.10.2016, 16:01
Re: Unban-IP Command doenst work - by amaruwhite - 23.10.2016, 16:04
Re: Unban-IP Command doenst work - by amaruwhite - 23.10.2016, 16:06

Forum Jump:


Users browsing this thread: 2 Guest(s)