SA-MP Forums Archive
UnbanIP without rcon scipt help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: UnbanIP without rcon scipt help (/showthread.php?tid=423941)



UnbanIP without rcon scipt help - Vytixz - 20.03.2013

dsadasdasdasdasd


Re: UnbanIP without rcon scipt help - LarzI - 20.03.2013

You're wasting a lot of memory by the way.

Try this:

pawn Код:
CMD:unbanip(playerid, params[])
{
    new
        IP[ 22 ]
    ;
    if(sscanf(params, "s[22]", IP))
        return SendClientMessage(playerid, -1, "Usage: /unbanip [IP]");

    strins( IP, "unban ", 0 );
    SendRconCommand( IP );
    SendRconCommand( "reloadbans" );
   
    return true;
}
Not that I actually changed much.


Re: UnbanIP without rcon scipt help - Scenario - 20.03.2013

LarzI, you have to account for the null terminator. An IP address can be 16 cells, so then you add "unban" which is 21, the space between unban and the IP, then an additional cell for the null terminator.

So, the cell size should be 23.


Re: UnbanIP without rcon scipt help - LarzI - 20.03.2013

255.255.255.255 = 15, not 16. The 16 cells is including the null terminator. unban + space = 6 letters, 16 + 6 = 22.

http://www.lettercount.com/ - input "unban 255.255.255.2550" for proof.


Re: UnbanIP without rcon scipt help - newbienoob - 20.03.2013

Quote:
Originally Posted by LarzI
Посмотреть сообщение
255.255.255.255 = 15, not 16. The 16 cells is including the null terminator. unban + space = 6 letters, 16 + 16 = 22.
LarzI, I just wanna know...

Who's your math teacher?


Re: UnbanIP without rcon scipt help - LarzI - 20.03.2013

Oh spare me, you know as well as everyone else that it was a typ0. 16 + 6 = 22, obviously.


Re: UnbanIP without rcon scipt help - Threshold - 20.03.2013

I thought the rcon command was 'unbanip'... not 'unban'...
Therefore 24 cells?


Re: UnbanIP without rcon scipt help - LarzI - 20.03.2013

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
I thought the rcon command was 'unbanip'... not 'unban'...
Therefore 24 cells?
Haha, true that. My calculations were correct nevertheless!


Re: UnbanIP without rcon scipt help - XStormiest - 20.03.2013

255.255.255.255 = 15 so that means an ip can be max 15 characters or less, so if you make max ip + the space + /unbanip = 7 letters + space = 8 letters, so string must be 15 + 8 = 23


Re: UnbanIP without rcon scipt help - LarzI - 20.03.2013

And all strings are zero-terminated, which means they all end with an additional character: '\0' (Null) thus making it 24.