#1

Another question
How to get the name of the player who used the command ??
Reply
#2

Код:
//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;
}
pName stores name of player with id of playerid
Greetings
Reply
#3

I made a command
PHP код:
CMD:kick(playeridparams[])
{

new 
id;
if(
sscanf(params,"u"id)) return SendClientMessage(playeridCOLOR_WHITE"Usage: /kick [id]");
if(!
IsPlayerConnected(id)) return SendClientMessage(playeridCOLOR_RED"This is player is not connected");
new 
name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME];
GetPlayerName(playeridnamesizeof(name));
format(stringsizeof(string), "%s has been kicked by //name here"name);
SendClientMessageToAll(COLOR_REDstring);
SetTimerEx("KickDelay"2000false"i"playerid);
return 
1;

I want to add the player name who kicked the other player instead of "name here" how to make it ??
Reply
#4

Quote:

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;
}

You really didn't noticed so obvious thing?
Reply
#5

Quote:
Originally Posted by nezo2001
Посмотреть сообщение
I made a command
PHP код:
CMD:kick(playeridparams[])
{

new 
id;
if(
sscanf(params,"u"id)) return SendClientMessage(playeridCOLOR_WHITE"Usage: /kick [id]");
if(!
IsPlayerConnected(id)) return SendClientMessage(playeridCOLOR_RED"This is player is not connected");
new 
name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME];
GetPlayerName(playeridnamesizeof(name));
format(stringsizeof(string), "%s has been kicked by //name here"name);
SendClientMessageToAll(COLOR_REDstring);
SetTimerEx("KickDelay"2000false"i"playerid);
return 
1;

I want to add the player name who kicked the other player instead of "name here" how to make it ??
nice one
this will surely kick the player who typed the command... backfired hard xD

but that aside, do it like this:
pawn Код:
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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)