Ban and Kick
#6

@nicholas1
- You're using playerid as a result you'll kick/ban the person who typed the command. You will need strtok for the id. However, strcmp and strtok are too damn slow and outdated. I'd recomment you to use ZCMD + sscanf as it's an amazing combination and it's really fast/easy.
pawn Код:
CMD:kick( playerid, params[ ] )
{
    if( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, -1, "You are not an Admin!" );
    new
        id,
        reason[ 64 ]
    ;
    if( sscanf( params, "rs[64]", id, reason ) ) return SendClientMessage( playerid, -1, "Usage: /kick <ID/Part Of Name>" );
    if( id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "That player is not connected!" );
    new
        name[ MAX_PLAYER_NAME ],
        string[ 128 ]
    ;
    GetPlayerName( id, name, MAX_PLAYER_NAME );
    format( string, sizeof( string ), "%s has been kicked by Administrator! (Reason: %s)", name, reason );
    SendClientMessageToAll( -1, string );
    Kick( id );
    return 1;
}

CMD:ban( playerid, params[ ] )
{
    if( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, -1, "You are not an Admin!" );
    new
        id,
        reason[ 64 ]
    ;
    if( sscanf( params, "rs[64]", id, reason ) ) return SendClientMessage( playerid, -1, "Usage: /ban <ID/Part Of Name>" );
    if( id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "That player is not connected!" );
    new
        name[ MAX_PLAYER_NAME ],
        string[ 128 ]
    ;
    GetPlayerName( id, name, MAX_PLAYER_NAME );
    format( string, sizeof( string ), "%s has been banned by Administrator! (Reason: %s)", name, reason );
    SendClientMessageToAll( -1, string );
    Ban( id );
    return 1;
}
Quote:
Originally Posted by GoldZoroGrab
Посмотреть сообщение
1- thats wrong, the player won't get the unban when time finish
2- he didn't ask for the time


Code:
Kick:
pawn Код:
command(kick, playerid, params[])
{
    new ID, reason[100];
    if(sscanf(params, "is", ID, reason)) SendClientMessage(playerid, BLANCO, "USAGE: /kick [id] [reason]");
    else if(IsPlayerConnected(ID) == 0) SendClientMessage(playerid, ROJO, "Player is not connected");
    else
    {
        GetPlayerName(ID, name2, 60);
    format(string, 256, "[ADMIN-KICK]Roze: %s[%d] Has Been Kicked From The Server - %s", name2, ID, reason);
    SendClientMessageToAll(AC, string);
        Kick(playerid);
        return 1;
    }
}
pawn Код:
command(ban, playerid, params[])
{
    new ID, reason[100];
    if(sscanf(params, "is", ID, reason)) SendClientMessage(playerid, BLANCO, "USAGE: /kick [id] [reason]");
    else if(IsPlayerConnected(ID) == 0) SendClientMessage(playerid, ROJO, "Player is not connected");
    else
    {
        GetPlayerName(ID, name2, 60);
    format(string, 256, "[ADMIN-KICK]Roze: %s[%d] Has Been Kicked From The Server - %s", name2, ID, reason);
    SendClientMessageToAll(AC, string);
        Kick(playerid);
        return 1;
    }
    return 1;
}
That's also wrong.
Sscanf specifiers: "is". It's "r" or "u" for ID/Part Of Name and "s[size]". Otherwise, it will give you error by sscanf in the server window. The messages are wrong and you kick player in both. And Player name's limit is 24, not 60..
Reply


Messages In This Thread
Ban and Kick - by nicholas1 - 09.12.2012, 22:26
Re: Ban and Kick - by HireMe - 09.12.2012, 22:52
Re: Ban and Kick - by nicholas1 - 10.12.2012, 00:11
Re: Ban and Kick - by Devilxz97 - 10.12.2012, 02:28
Re: Ban and Kick - by GoldZoroGrab - 10.12.2012, 10:26
Re: Ban and Kick - by Konstantinos - 10.12.2012, 10:36
Re: Ban and Kick - by nicholas1 - 11.12.2012, 00:57

Forum Jump:


Users browsing this thread: 1 Guest(s)