Making a /kick command -
gamerhead - 22.05.2011
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...
Respuesta: Making a /kick command -
admantis - 22.05.2011
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;
}
Re: Making a /kick command - ColdIce - 22.05.2011
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");
}
Respuesta: Re: Making a /kick command -
admantis - 22.05.2011
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!
Re: Making a /kick command - ColdIce - 22.05.2011
Noo oops! Didnt read it all
Its from LuxAdmin
Re: Making a /kick command -
jameskmonger - 22.05.2011
I am disappointed at how you attempt to be good at English and then fail.
Respuesta: Re: Making a /kick command -
admantis - 22.05.2011
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.
Re: Making a /kick command -
fissekarl - 22.05.2011
admantis I got a question about your code, why do you use unformat? I never saw anything like that before, would you mind explaning

?
Respuesta: Re: Making a /kick command -
admantis - 22.05.2011
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.
Re: Respuesta: Making a /kick command -
Madsen - 22.05.2011
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!