Little problem with kick
#1

Well im trying to get a SendCLientMessageToAll but I dont know sure how to configure it good with kick.

What im trying to do is:
/kick 2 Bye
(a message to all
"Playerid2 his name" has been kicked for: "reason" by administrator:"adminname"

We use ZCMD so please post a reply in ZCMD

Our current code:
pawn Код:
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;
}
Reply
#2

Код:
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);
                    GetPlayerName(PlayerToKick,Name, sizeof(Name));
                    new playeridname[MAX_PLAYER_NAME];
                    GetPlayerName(playerid,playeridname,sizeof( playeridname ) );

                    format(ReasonMsg, 128, "%s has been kicked for : %s by administrator : %s",Name,Reason,playeridname);
                    SendClientMessageToAll(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
#3

Quote:
Originally Posted by juraska
Посмотреть сообщение
Код:
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);
                    GetPlayerName(PlayerToKick,Name, sizeof(Name));
                    new playeridname[MAX_PLAYER_NAME];
                    GetPlayerName(playerid,playeridname,sizeof( playeridname ) );

                    format(ReasonMsg, 128, "%s has been kicked for : %s by administrator : %s",Name,Reason,playeridname);
                    SendClientMessageToAll(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;
}
Great thanks.

Now, I edited a little of it, but it shows some warnings now:
Код:
C:\Users\kevin.H1964542\Desktop\SAMP Kevin\pawno\include\PPC_PlayerCommands.inc(1921) : warning 217: loose indentation
C:\Users\kevin.H1964542\Desktop\SAMP Kevin\pawno\include\PPC_PlayerCommands.inc(1924) : warning 217: loose indentation
C:\Users\kevin.H1964542\Desktop\SAMP Kevin\gamemodes\PPC_Trucking.pwn(232) : warning 204: symbol is assigned a value that is never used: "Msg"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
Our current code now is:
pawn Код:
COMMAND:kick(playerid, params[])
{
    new PlayerToKick, Reason[128], ReasonMsg[128], Name[24], Kieken[150];

    // 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);
                    GetPlayerName(PlayerToKick,Name, sizeof(Name));
                    new playeridname[MAX_PLAYER_NAME];
                    GetPlayerName(playerid,playeridname,sizeof( playeridname ) );

                    format(Kieken, 150, "%s has been kicked for : %s by administrator : %s",Name,Reason,playeridname);
            SendClientMessageToAll(0xFFFFFFFF, Kieken);

                    // 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;
}
Line 1921/1924
pawn Код:
SendClientMessageToAll(0xFFFFFFFF, Kieken);

                    // Kick the player
                    Kick(PlayerToKick);
                }
Reply
#4

PHP код:
COMMAND:kick(playeridparams[])
{
    new 
PlayerToKickReason[128], ReasonMsg[128], Name[24], Kieken[150];
    
// 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]"PlayerToKickReason)) SendClientMessage(playerid0xFF0000AA"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(playeridNamesizeof(Name));
                    
// Send the warned player a message who kicked him and why he's been kicked
                    
format(ReasonMsg128"You have been kicked by %s %s"AdminLevelName[APlayerData[playerid][PlayerLevel]], Name);
                    
SendClientMessage(PlayerToKick0xFF0000FFReasonMsg);
                    
format(ReasonMsg128"Reason: %s"Reason);
                    
SendClientMessage(PlayerToKick0xFF0000FFReasonMsg);
                    
GetPlayerName(PlayerToKick,Namesizeof(Name));
                    new 
playeridname[MAX_PLAYER_NAME];
                    
GetPlayerName(playerid,playeridname,sizeofplayeridname ) );
                    
format(Kieken150"%s has been kicked for : %s by administrator : %s",Name,Reason,playeridname);
                    
SendClientMessageToAll(0xFFFFFFFFKieken);
                    
// Kick the player
                    
Kick(PlayerToKick);
                }
                else
                    
SendClientMessage(playerid0xFF0000FF"That player isn't online");
        }
        else
            return 
0;
    }
    else
        return 
0;
    
// Let the server know that this was a valid command
    
return 1;

Indent properly.
Reply
#5

Thanks, worked.
Reply
#6

C:\Users\kevin.H1964542\Desktop\SAMP Kevin\gamemodes\PPC_Trucking.pwn(232) : warning 204: symbol is assigned a value that is never used: "Msg"

Delete variable"new Msg" because this veriable unused
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)