27.12.2014, 20:06
Another question
How to get the name of the player who used the command ??
How to get the name of the player who used the command ??
//using zcmd COMMAND:me(playerid, params[]) { new pName[MAX_PLAYER_NAME+1], Out[100]; GetPlayerName(playerid, pName, MAX_PLAYER_NAME+1); format(Out, sizeof( Out ), "Hello, this is %s speaking!", pName); SendClientMessageForAll(-1, Out); return true; }
CMD:kick(playerid, params[])
{
new id;
if(sscanf(params,"u", id)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /kick [id]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "This is player is not connected");
new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s has been kicked by //name here", name);
SendClientMessageToAll(COLOR_RED, string);
SetTimerEx("KickDelay", 2000, false, "i", playerid);
return 1;
}
CMD:kick(playerid, params[]) { new id; if(sscanf(params,"u", id)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /kick [id]"); if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "This is player is not connected"); new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME], victim[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); // this gets name of playerid - someone who USED command GetPlayerName(id, victim, sizeof(victim)); // this gets name of player BEING kicked format(string, sizeof(string), "%s has been kicked by %s", victim, name); SendClientMessageToAll(COLOR_RED, string); SetTimerEx("KickDelay", 2000, false, "i", id); return 1; } |
I made a command
PHP код:
|
CMD:kick(playerid, params[])
{
new id;
if(sscanf(params,"u", id)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /kick [id]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "This is player is not connected");
new pn[2][MAX_PLAYER_NAME], string[66];
GetPlayerName(playerid, pn[0], sizeof pn[]);
GetPlayerName(id, pn[1], sizeof pn[]);
format(string, sizeof(string), "%s has been kicked by %s", pn[1],pn[0]);
SendClientMessageToAll(COLOR_RED, string);
SetTimerEx("KickDelay", 2000, false, "i", id);
return 1;
}