Making a /kick command
#1

Hello guys, i want to know how to make a kick command like this:

if (strcmp("/kick", cmdtext, true, 10) == 0)
new victim;
{
Kick (victim);
SendClientMessageToAll(playerid, COLOR_RED, "Text ^^");
}

return 1;

And then like /kick VICTIM
will kick (victim); i just want it in this, no DCMD or zcmd just in normal.
I realy dont know how to make it.
Please help, i searched ****** and all but only found dcmd...
Reply
#2

pawn Код:
CMD:kick(playerid, params[])
{
    new
        i_Player,
        sz_PlayerName[24],
        sz_SenderName[24],
        sz_Reason[64],
        sz_String[128]
    ;
   
    if (unformat(params, "us[64]", i_Player, sz_Reason))
        return SendClientMessage(playerid, -1, "{C0C0C0}USAGE: /kick <playerid> <reason>");
       
    if (i_Player == 0xFFFF)
        return SendClientMessage(playerid, -1, "{FF0000}This player is not connected.");
       
    GetPlayerName(i_Player, sz_PlayerName, 24);
    GetPlayerName(playerid, sz_SenderName, 24);
   
    format(sz_String, 128, "%s(%d) was kicked by %s(%d) [Reason: %s]", sz_PlayerName, i_Player, playerid, sz_SenderName, szReason);
    SendClientMessageToAll(-1, sz_String);
   
    Kick(i_Player);
    return true;
}
Reply
#3

pawn Код:
dcmd_kick(playerid,params[])
{
    if(AccInfo[playerid][LoggedIn] == 1)

    {
        if(AccInfo[playerid][Level] >= 3)
        {
            new Index;
            new tmp[256];  tmp  = strtok(params,Index);
            new tmp2[256]; tmp2 = strtok(params,Index);
            if(!strlen(params)) return
            SendClientMessage(playerid, LIGHTBLUE2, "Usage: /kick [PlayerID] [Reason]") &&
            SendClientMessage(playerid, orange, "Function: Will Kick the specified player");
            new player1;
            new string[128];
            new playername[MAX_PLAYER_NAME];
            new adminname [MAX_PLAYER_NAME];
            player1 = strval(tmp);

            if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (AccInfo[player1][Level] != ServerInfo[MaxAdminLevel]))
             {
                GetPlayerName(player1, playername, sizeof(playername));
                GetPlayerName(playerid, adminname, sizeof(adminname));
                SendCommandToAdmins(playerid,"Kick");
                if(!strlen(tmp2))
                {
                format(string,sizeof(string),"|- %s has been kicked by Administrator %s | Reason: Not Specified -|",playername,adminname);
                SendClientMessageToAll(grey,string);
                SaveIn("KickLog",string);
                print(string);
                return Kick(player1);
                }
                else
                {
                format(string,sizeof(string),"|- %s has been kicked by Administrator %s | Reason: %s -|",playername,adminname,params[2]);
                SendClientMessageToAll(grey,string);
                SaveIn("KickLog",string); print(string);
                return Kick(player1);
                }
            }
            else return ErrorMessages(playerid, 3);
        }
        else return ErrorMessages(playerid, 1);
    }
    else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
Reply
#4

Quote:
Originally Posted by ColdIce
Посмотреть сообщение
pawn Код:
dcmd_kick(playerid,params[])
{
    if(AccInfo[playerid][LoggedIn] == 1)

    {
        if(AccInfo[playerid][Level] >= 3)
        {
            new Index;
            new tmp[256];  tmp  = strtok(params,Index);
            new tmp2[256]; tmp2 = strtok(params,Index);
            if(!strlen(params)) return
            SendClientMessage(playerid, LIGHTBLUE2, "Usage: /kick [PlayerID] [Reason]") &&
            SendClientMessage(playerid, orange, "Function: Will Kick the specified player");
            new player1;
            new string[128];
            new playername[MAX_PLAYER_NAME];
            new adminname [MAX_PLAYER_NAME];
            player1 = strval(tmp);

            if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (AccInfo[player1][Level] != ServerInfo[MaxAdminLevel]))
             {
                GetPlayerName(player1, playername, sizeof(playername));
                GetPlayerName(playerid, adminname, sizeof(adminname));
                SendCommandToAdmins(playerid,"Kick");
                if(!strlen(tmp2))
                {
                format(string,sizeof(string),"|- %s has been kicked by Administrator %s | Reason: Not Specified -|",playername,adminname);
                SendClientMessageToAll(grey,string);
                SaveIn("KickLog",string);
                print(string);
                return Kick(player1);
                }
                else
                {
                format(string,sizeof(string),"|- %s has been kicked by Administrator %s | Reason: %s -|",playername,adminname,params[2]);
                SendClientMessageToAll(grey,string);
                SaveIn("KickLog",string); print(string);
                return Kick(player1);
                }
            }
            else return ErrorMessages(playerid, 3);
        }
        else return ErrorMessages(playerid, 1);
    }
    else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
I am dissapointed at how you just copy this from GodFather and put it here, it will most likely return a bunch of errors! Plus a low ammount of users use this low and antiquated system, better to use the modern!
Reply
#5

Noo oops! Didnt read it all

Its from LuxAdmin
Reply
#6

I am disappointed at how you attempt to be good at English and then fail.
Reply
#7

Quote:
Originally Posted by jameskmonger
Посмотреть сообщение
I am disappointed at how you attempt to be good at English and then fail.
I am not attempting to be good at English and I admit I am not -that- good in English but infact that command provided by ColdIce was not convectional.
Reply
#8

admantis I got a question about your code, why do you use unformat? I never saw anything like that before, would you mind explaning ?
Reply
#9

Quote:
Originally Posted by fissekarl
Посмотреть сообщение
admantis I got a question about your code, why do you use unformat? I never saw anything like that before, would you mind explaning ?
It's the same thing as sscanf just another name to avoid confusions with sscanf from C.
Reply
#10

Quote:
Originally Posted by admantis
Посмотреть сообщение
pawn Код:
CMD:kick(playerid, params[])
{
    new
        i_Player,
        sz_PlayerName[24],
        sz_SenderName[24],
        sz_Reason[64],
        sz_String[128]
    ;
   
    if (unformat(params, "us[64]", i_Player, sz_Reason))
        return SendClientMessage(playerid, -1, "{C0C0C0}USAGE: /kick <playerid> <reason>");
       
    if (i_Player == 0xFFFF)
        return SendClientMessage(playerid, -1, "{FF0000}This player is not connected.");
       
    GetPlayerName(i_Player, sz_PlayerName, 24);
    GetPlayerName(playerid, sz_SenderName, 24);
   
    format(sz_String, 128, "%s(%d) was kicked by %s(%d) [Reason: %s]", sz_PlayerName, i_Player, playerid, sz_SenderName, szReason);
    SendClientMessageToAll(-1, sz_String);
   
    Kick(i_Player);
    return true;
}
so i am just going to copy this xD ty!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)