Banip help
#1

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?
Reply
#2

Someone any idea?
Reply
#3

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

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

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.
Reply
#5

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

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

Код:
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.
Reply
#8

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
Reply
#9

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.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)