22.06.2014, 11:56
pawn Код:
CMD:whisper(playerid,params[])
{
new name[MAX_PLAYER_NAME],string[128],msg[128]; //Taking string arrays to store name, message and to format text.
if (sscanf(params, "s[128]", message)) //using sscanf to store the whispered text.
{
SendClientMessage(playerid, -1, "USAGE: /(w)hisper [message]"); //if the text is not stored in message.
return 1;
}
else
{
new Float:x,Float:y,Float:z; //variables to get player's position
GetPlayerPos(playerid, x, y, z); //getting the position
GetPlayerName(playerid, name, sizeof(name)); //getting the player's name
format(string,sizeof(string), "%s whispers: %s",name, message); //formating the text
for(new i=0;i<MAX_PLAYERS;i++) //looping
{
if(IsPlayerConnected(i)) //checking if players are connected.
{
if(IsPlayerInRangeOfPoint(i, 10.0, x, y, z); //checking the range so that we can display the whispered message
{
SendClientMessage(i,-1,string); //displaying the message to the players who are nearby to the sender.
}
}
}
}
return 1;
}
pawn Код:
CMD:w(playerid, params[])
{
return cmd_whisper; //adding this, so that you can also whisper by using /w
}