This command didn't kick me
#1

Okay, I've logged in to RCON, and typed /kick 0 testreason ( 0 is the player ID ).

pawn Код:
COMMAND:kick( playerid, params[ ] )
{
    if ( IsPlayerAdmin( playerid ) )
    {
        new
            toplayerid,
            reason;

        if ( sscanf( params, "us[128]", toplayerid, reason ) )
        {
            SendClientMessage( playerid, 0xFFFFFF, "Syntax Error: /Kick < Playerid > < Reason >" );
            return 1;
        }

        if ( toplayerid == INVALID_PLAYER_ID )
        {
            SendClientMessage( playerid, 0xFFFFFF, "Input Error: Player is not connected or it is yourself." );
            return 1;
        }
       
        new
            kickString[ 128 ],
            adminName[ 24 ],
            kickedName[ 24 ];

        GetPlayerName( playerid, adminName, 24 );
        GetPlayerName( toplayerid, kickedName, 24 );

        format( kickString, 128, "{EE5555}Admin Command {FFFFFF}: Player %s was kicked by Administrator %s with the reason : %s.",
        kickedName, adminName, reason );

        SendClientMessageToAll( 0xFFFFFF, kickString );

        Kick( toplayerid );
    }
    return 1;
}
EDIT: Also, vehicle will create more.
The X Y position is same, but the Z is higher.
Reply
#2

You just need to declare your variable "reason" as an array:

pawn Код:
COMMAND:kick( playerid, params[ ] )
{
    if ( IsPlayerAdmin( playerid ) )
    {
        new
            toplayerid,
            reason[ 128 ]; // <------------- CHANGED THIS BIT HERE <----------------

        if ( sscanf( params, "us[128]", toplayerid, reason ) )
        {
            SendClientMessage( playerid, 0xFFFFFF, "Syntax Error: /Kick < Playerid > < Reason >" );
            return 1;
        }

        if ( toplayerid == INVALID_PLAYER_ID )
        {
            SendClientMessage( playerid, 0xFFFFFF, "Input Error: Player is not connected or it is yourself." );
            return 1;
        }
       
        new
            kickString[ 128 ],
            adminName[ 24 ],
            kickedName[ 24 ];

        GetPlayerName( playerid, adminName, 24 );
        GetPlayerName( toplayerid, kickedName, 24 );

        format( kickString, 128, "{EE5555}Admin Command {FFFFFF}: Player %s was kicked by Administrator %s with the reason : %s.",
        kickedName, adminName, reason );

        SendClientMessageToAll( 0xFFFFFF, kickString );

        Kick( toplayerid );
    }
    return 1;
}
Reply
#3

Thanks Benjo!
Trying it right now.

EDIT:
The command you showed works Benjo, thanks for fixing it.
And also thanks for the information.
Reply
#4

No problem Things like this are always easier to catch with an extra set of eyes! Nice looking code btw, very neat and tidy
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)