SA-MP Forums Archive
Banip 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: Banip help (/showthread.php?tid=604315)



Banip help - justjamie - 03.04.2016

Hello,
i'm making a command (banip), but it doesn't work.
Everytime i ban someone using the command it shows:
Код:
127.0.0.1 [03/04/16 | 10:36:52] justjamie - (null)
When i ban a ip using the rcon, i get this:
Код:
127.0.0.1 [03/04/16 | 10:39:50] NONE - IP BAN
The ip shows banned, but i still can join ingame.

This is my banip command:
pawn Код:
COMMAND:banip(playerid, params[])
{
    new eReason [ 64 ], iReason[ 128 ], tmp[ 64 ], string[ 128 ];
    if(sscanf(params, "ss", eReason, iReason)) return SCP(playerid, "[IP Range][Reason]");

    format(tmp, sizeof(tmp), "banip %s", eReason);
    SendRconCommand(tmp);
    SendRconCommand("reloadbans");

    format(string, MAX_STRING, "4[ IPBAN ] IP address %s has been banned. Reason: %s", eReason, iReason);
    iEcho(string);
    return 1;
}
What's wrong here and why doesn't it work?


Re: Banip help - justjamie - 03.04.2016

Someone any idea?


Re: Banip help - AndySedeyn - 03.04.2016

You need to add the string's size next to the specifiers in sscanf.

PHP код:
if(sscanf(params"s[64]s[128]"eReasoniReason)) 



Re: Banip help - justjamie - 03.04.2016

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
You need to add the string's size next to the specifiers in sscanf.

PHP код:
if(sscanf(params"s[64]s[128]"eReasoniReason)) 
Doesn't work.


Re: Banip help - iKevin - 03.04.2016

Quote:
Originally Posted by justjamie
Посмотреть сообщение
Doesn't work.
Do you have sscanf plugin and include?


Re: Banip help - justjamie - 03.04.2016

Quote:
Originally Posted by KevinExec
Посмотреть сообщение
Do you have sscanf plugin and include?
Yup,
otherwise it wouldnt show the NULL as a ban, right?


Re: Banip help - Tingesport - 03.04.2016

Код:
COMMAND:banip(playerid, params[])
{
	new eReason [ 64 ], iReason[ 128 ], tmp[ 64 ], string[ 128 ];
	if(sscanf(params, "s[64]s[128]", eReason, iReason)) return SCP(playerid, "[IP Range][Reason]");

	format(tmp, sizeof(tmp), "banip %s", eReason);
	SendRconCommand(tmp);
	SendRconCommand("reloadbans");

	format(string, MAX_STRING, "4[ IPBAN ] IP address %s has been banned. Reason: %s", eReason, iReason);
	iEcho(string);
	return 1;
}
You need to specify string size within sscanf parameters even though it's specified.


Re: Banip help - justjamie - 03.04.2016

Quote:
Originally Posted by Tingesport
Посмотреть сообщение
Код:
COMMAND:banip(playerid, params[])
{
	new eReason [ 64 ], iReason[ 128 ], tmp[ 64 ], string[ 128 ];
	if(sscanf(params, "s[64]s[128]", eReason, iReason)) return SCP(playerid, "[IP Range][Reason]");

	format(tmp, sizeof(tmp), "banip %s", eReason);
	SendRconCommand(tmp);
	SendRconCommand("reloadbans");

	format(string, MAX_STRING, "4[ IPBAN ] IP address %s has been banned. Reason: %s", eReason, iReason);
	iEcho(string);
	return 1;
}
You need to specify string size within sscanf parameters even though it's specified.
now it shows this



Re: Banip help - Karan007 - 03.04.2016

PHP код:
COMMAND:banip(playeridparams[])
{
    new 
eReason 64 ], iReason128 ], tmp64 ], string128 ];
    if(
sscanf(params"ss"eReasoniReason)) return SendClientMessage(playerid, -1,"[IP Range][Reason]");

    
format(tmpsizeof(tmp), "banip %s"eReason);
    
SendRconCommand(tmp);
    
SendRconCommand("reloadbans");

    
format(stringsizeof(string), "4[ IPBAN ] IP address %s has been banned. Reason: %s"eReasoniReason);
    
iEcho(string);
    return 
1;

Not sure if it'll work but try it WITHOUT changing anything in my code.


Re: Banip help - justjamie - 03.04.2016

Quote:
Originally Posted by Karan007
Посмотреть сообщение
PHP код:
COMMAND:banip(playeridparams[])
{
    new 
eReason 64 ], iReason128 ], tmp64 ], string128 ];
    if(
sscanf(params"ss"eReasoniReason)) return SendClientMessage(playerid, -1,"[IP Range][Reason]");
    
format(tmpsizeof(tmp), "banip %s"eReason);
    
SendRconCommand(tmp);
    
SendRconCommand("reloadbans");
    
format(stringsizeof(string), "4[ IPBAN ] IP address %s has been banned. Reason: %s"eReasoniReason);
    
iEcho(string);
    return 
1;

Not sure if it'll work but try it WITHOUT changing anything in my code.
It works now, but i can still connect with that IP.