Help about /kick command
#1

Hello all, again me, now i have a problem: when any admin kick any player, i want it will be shown in mainchat like: Admin [nick] has kicked [playername] from this server with reason: [reason] but i dont know what need to change here


// Kicks a player with a reason
COMMAND:kick(playerid, params[])
{
new PlayerToKick, Reason[128], ReasonMsg[128], Name[24];

// Send the command to all admins so they can see it
SendAdminText(playerid, "/kick", params);

// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 1
if (APlayerData[playerid][PlayerLevel] >= 1)
{
if (sscanf(params, "us[128]", PlayerToKick, Reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/kick <PlayerToKick> <Reason>\"");
else
if (IsPlayerConnected(PlayerToKick)) // If the player is a valid playerid (he's connected)
{
// Get the name of the player who warned the player
GetPlayerName(playerid, Name, sizeof(Name));
// Send the warned player a message who kicked him and why he's been kicked
format(ReasonMsg, 128, "You have been kicked by %s %s", AdminLevelName[APlayerData[playerid][PlayerLevel]], Name);
SendClientMessage(PlayerToKick, 0xFF0000FF, ReasonMsg);
format(ReasonMsg, 128, "Reason: %s", Reason);
SendClientMessage(PlayerToKick, 0xFF0000FF, ReasonMsg);
// Kick the player
Kick(PlayerToKick);
}
else
SendClientMessage(playerid, 0xFF0000FF, "That player isn't online");
}
else
return 0;
}
else
return 0;

// Let the server know that this was a valid command
return 1;
}


so help me please
Reply
#2

Post it before you kick him

pawn Код:
new message[128];
format(message,sizeof(message),"Admin %s has kicked %s from this server with reason:%s",Name,PlayerToKick,Reason);
SendClientMessageToAll(-1,message);
next time use [PAWN][ /PAWN] tags
Reply
#3

i dont understand what i need to replace with
pawn Код:
new message[128];
format(message,sizeof(message),"Admin %s has kicked %s from this server with reason:%s",Name,PlayerToKick,Reason);
SendClientMessageToAll(-1,message);
Reply
#4

pawn Код:
// Kicks a player with a reason
COMMAND:kick(playerid, params[])
{
    new PlayerToKick, Reason[128], ReasonMsg[128], Name[24], Name2[24];

    // Send the command to all admins so they can see it
    SendAdminText(playerid, "/kick", params);

    // Check if the player has logged in
    if (APlayerData[playerid][LoggedIn] == true)
    {
        // Check if the player's admin-level is at least 1
        if (APlayerData[playerid][PlayerLevel] >= 1)
        {
            if (sscanf(params, "us[128]", PlayerToKick, Reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/kick <PlayerToKick> <Reason>\"");
            else
            if (IsPlayerConnected(PlayerToKick)) // If the player is a valid playerid (he's connected)
            {
                // Get the name of the player who warned the player
                GetPlayerName(playerid, Name, sizeof(Name));
                GetPlayerName(PlayerToKick, Name2, sizeof(Name2));
                // Send the warned player a message who kicked him and why he's been kicked
                format(ReasonMsg, 128, "You have been kicked by %s %s", AdminLevelName[APlayerData[playerid][PlayerLevel]], Name);
                SendClientMessage(PlayerToKick, 0xFF0000FF, ReasonMsg);
                format(ReasonMsg, 128, "Reason: %s", Reason);
                SendClientMessage(PlayerToKick, 0xFF0000FF, ReasonMsg);
                format(ReasonMsg, 128, "Admin %s has kicked %s from this server with reason: %s", Name, Name2, Reason);
                SendClientMessageToAll(0xFF0000FF, ReasonMsg);
                // Kick the player
                Kick(PlayerToKick);
            }
            else
            SendClientMessage(playerid, 0xFF0000FF, "That player isn't online");
        }
        else
        return 0;
    }
    else
    return 0;

    // Let the server know that this was a valid command
    return 1;
}
Reply
#5

Not to replay to post before you kick player becose if you kick him there no way to get the name while player is kicked so you put it before you kick him


pawn Код:
new message[128];// you can post this on top on command were you define others
                format(message,sizeof(message),"Admin %s has kicked %s from this server with reason:%s",Name,PlayerToKick,Reason);
                SendClientMessageToAll(-1,message);
                // Kick the player
                Kick(PlayerToKick);
            }

If you post the command in pawn tags i could make it everything into 1 command to work but like that i cant understand anything
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)