need help in some cmmds!
#4

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
}
EDIT: Added explanation. Thank you Clad
Reply


Messages In This Thread
need help in some cmmds! - by VishalSama - 22.06.2014, 08:52
Re: need help in some cmmds! - by RenovanZ - 22.06.2014, 09:29
Re: need help in some cmmds! - by ScripteRNaBEEL - 22.06.2014, 11:42
Re: need help in some cmmds! - by Rittik - 22.06.2014, 11:56
Re: need help in some cmmds! - by Clad - 22.06.2014, 12:00

Forum Jump:


Users browsing this thread: 1 Guest(s)