Ban command working how unban??
#1

pawn Код:
CMD:ban(playerid,params[])
{
    if (PlayerInfo[playerid][pAdmin] >= 5)
    {
         new tmp[256], tmp2[256], Index;
         tmp = strtok(params,Index), tmp2 = strtok(params,Index);
         if(isnull(params)) return SendClientMessage(playerid, -1, "{F81414}USAGE: /ban [playerid] [waarom?]");
         new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
         player1 = strval(tmp);
         if(!IsPlayerConnected(player1)) return SendClientMessage(playerid,-1,"{F81414}Player is niet online!");
         GetPlayerName(player1, playername, sizeof(playername));
         GetPlayerName(playerid, adminname, sizeof(adminname));
         format(string,sizeof(string),"Admin %s Heeft %s Gebant| Waarom?? ( %s )",adminname,playername,params[2]);
         SendClientMessageToAll(-1,string);
         Ban(player1);
         }
         else
         {
         SendClientMessage(playerid,-1,"{F81414}Je kan deze commando niet voeren!");
    }
    return 1;
}
This is my ban command searched unban commands but dont found please help.
Reply
#2

Why do you use strtok with ZCMD, when you can use sscanf and be very fast?
pawn Код:
// unban command
new
    string[ 128 ] // Use 128, not 256.
;
// unbanned_ip would be either by sscanf or strtok. (param)
format( string, sizeof( string ), "unbanip %s", unbanned_ip );
SendRconCommand( string );
SendRconCommand( "reloadbans" );
Reply
#3

use sscanf , much better then strtok.
Reply
#4

IDK seed an tutorial and i dont now how sscanf work
Reply
#5

Quote:
Originally Posted by Dwane
Посмотреть сообщение
Use 128, not 256.
Well, honestly, 128 is way too large too.

unbanip + space = 8 chars

IP can be maximum 255.255.255.255 - 15 chars

15 + 8 + 1 (null) = 24

Thus making 24 cells the appropriate amount.

pawn Код:
new
    string[ 24 ];
Reply
#6

Quote:
Originally Posted by Mustafa6155
Посмотреть сообщение
IDK seed an tutorial and i dont now how sscanf work
I just replied to a thread that user doesn't know how to use sscanf.
Example
More info on ******'s thread about sscanf.

Quote:
Originally Posted by LarzI
Посмотреть сообщение
Well, honestly, 128 is way too large too.

unbanip + space = 8 chars

IP can be maximum 255.255.255.255 - 15 chars

15 + 8 + 1 (null) = 24

Thus making 24 cells the appropriate amount.

pawn Код:
new
    string[ 24 ];
Well, you count for that message, but string can be used for more messages into the /unban command.
Reply
#7

Код:
 Re: Ban command working how unban??
Why do you use strtok with ZCMD, when you can use sscanf and be very fast?
pawn Code:
// unban command
new
    string[ 128 ] // Use 128, not 256.
;
// unbanned_ip would be either by sscanf or strtok. (param)
format( string, sizeof( string ), "unbanip %s", unbanned_ip );
SendRconCommand( string );
SendRconCommand( "reloadbans" );
What i need to define and // unban command
I didnt have it...??
Reply
#8

I didn't get it. Just use the command and unban the ip of the player or it can be more complicated and reads the name from a file and returns the ip.
Reply
#9

Quote:
Originally Posted by Dwane
Посмотреть сообщение
Well, you count for that message, but string can be used for more messages into the /unban command.
Ah yes, if he uses the same string variable for both messages and the RCON command, then you're right.
Reply
#10

Man that modern thinks like sscanf freaking me out i need a teacher ;(
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)