Unban-IP Command doenst work
#1

Hey,

i tried to get some help from a german-samp forum which helped me a little bit but didnt fix my not working command.

Quote:

ocmd:unbanip(playerid,params[])
{
new SpielerIP[32], str[64];
new adminstr[128];
if(!IsAdmin(playerid,2))return noaccess
if(sscanf(params,"s[32]",SpielerIP)) return SendClientMessage(playerid,-1,"/unbanip <IP>");
{
format(str,sizeof(str),"unbanip %s",SpielerIP);
format(adminstr,sizeof(adminstr),"%s hat die IP % erfolgreich entbannt!",PlayerName(playerid));
for(new i=0; i<GetMaxPlayers(); i++)
{
if(!PlayerOnline(i))continue;
if(!IsAdmin(i,2))continue;
SendClientMessage(i,GELB,adminstr);
}
new logstr[128];
format(logstr,sizeof(logstr),"%s hat die IP-Adresse : %s erfolgreich entbannt!",PlayerName(playerid),SpielerIP);
AddLog("log_unbanip.txt",logstr);
SendRconCommand(str);
SendRconCommand("reloadbans");
}
return 1;
}

Always when i type /unban (My IP), there is always coming up the ClientMessage for how to use the command.

Like this :

"/unban (IP)"...

Can someone help me?
Reply
#2

Quote:

ocmd:unbanip(playerid,params[])
{
new SpielerIP[32], str[64];
new adminstr[128];
if(!IsAdmin(playerid,2))return noaccess
if(sscanf(params,"n",SpielerIP)) return SendClientMessage(playerid,-1,"/unbanip <IP>");
{
format(str,sizeof(str),"unbanip %s",SpielerIP);
format(adminstr,sizeof(adminstr),"%s hat die IP % erfolgreich entbannt!",PlayerName(playerid));
for(new i=0; i<GetMaxPlayers(); i++)
{
if(!PlayerOnline(i))continue;
if(!IsAdmin(i,2))continue;
SendClientMessage(i,GELB,adminstr);
}
new logstr[128];
format(logstr,sizeof(logstr),"%s hat die IP-Adresse : %s erfolgreich entbannt!",PlayerName(playerid),SpielerIP);
AddLog("log_unbanip.txt",logstr);
SendRconCommand(str);
SendRconCommand("reloadbans");
}
return 1;
}

:/

and check this : https://sampforum.blast.hk/showthread.php?tid=570927
Reply
#3

Hey,

it says now that i unbanned a IP but the adminsting ( ClientMessage ) doesnt say the IP that i typed in, it says :

"aw_ hat die IP entbannt" it means

aw_ unbanned the IP " <-- Blank Field / nothing after IP

In formating adminstring i added now SpielerIP after the ClientMessage to fill the %s, but it still doesnt say the IP that i unbanned.
Reply
#4

Quote:

ocmd:unbanip(playerid,params[])
{
new SpielerIP[32], str[64];
new adminstr[128];
if(!IsAdmin(playerid,2))return noaccess
if(sscanf(params,"n",SpielerIP)) return SendClientMessage(playerid,-1,"/unbanip <IP>");
{
format(str,sizeof(str),"unbanip %s",SpielerIP);
format(adminstr,sizeof(adminstr),"%s hat die IP % erfolgreich entbannt!",PlayerName(playerid));
for(new i=0; i<GetMaxPlayers(); i++)
{
if(!PlayerOnline(i))continue;
if(!IsAdmin(i,2))continue;
SendClientMessage(i,GELB,adminstr);
}
new logstr[128];
format(logstr,sizeof(logstr),"%s hat die IP-Adresse : %d erfolgreich entbannt!",PlayerName(playerid),SpielerIP);
AddLog("log_unbanip.txt",logstr);
SendRconCommand(str);
SendRconCommand("reloadbans");
}
return 1;
}

check it now

+REP if i helped you
Reply
#5

It always says now "aw_ unbanned the IP 0". gg xD

And btw my IP doesnt get banned
Reply
#6

current code :

Код:
ocmd:unbanip(playerid,params[])
{
    new SpielerIP[18], str[64];
    new adminstr[128];
    if(!IsAdmin(playerid,2))return noaccess
    if(sscanf(params,"n",SpielerIP)) return SendClientMessage(playerid,-1,"/unbanip <IP>");
    {
        format(str,sizeof(str),"unbanip %s",SpielerIP);
        format(adminstr,sizeof(adminstr),"%s hat die IP %d erfolgreich entbannt!",PlayerName(playerid),SpielerIP);
        for(new i=0; i<GetMaxPlayers(); i++)
        {
            if(!PlayerOnline(i))continue;
            if(!IsAdmin(i,2))continue;
            SendClientMessage(i,GELB,adminstr);
        }
        new logstr[128];
        format(logstr,sizeof(logstr),"%s hat die IP-Adresse : %d erfolgreich entbannt!",PlayerName(playerid),SpielerIP);
        AddLog("log_unbanip.txt",logstr);
        SendRconCommand(str);
        SendRconCommand("reloadbans");
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by amaruwhite
Посмотреть сообщение
current code :

ocmd:unbanip(playerid,params[])
{
new SpielerIP[18], str[64];
new adminstr[128];
if(!IsAdmin(playerid,2))return noaccess
if(sscanf(params,"n",SpielerIP)) return SendClientMessage(playerid,-1,"/unbanip <IP>");
{
format(str,sizeof(str),"unbanip %s",SpielerIP);
format(adminstr,sizeof(adminstr),"%s hat die IP %i erfolgreich entbannt!",PlayerName(playerid),SpielerIP);
for(new i=0; i<GetMaxPlayers(); i++)
{
if(!PlayerOnline(i))continue;
if(!IsAdmin(i,2))continue;
SendClientMessage(i,GELB,adminstr);
}
new logstr[128];
format(logstr,sizeof(logstr),"%s hat die IP-Adresse : %i erfolgreich entbannt!",PlayerName(playerid),SpielerIP);
AddLog("log_unbanip.txt",logstr);
SendRconCommand(str);
SendRconCommand("reloadbans");
}
return 1;
}
check it now x)
Reply
#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
#9

Still saying "aw_ unbanned IP 0"
Reply
#10

Sorry didnt see Konstantinos Reply, lemme try this.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)