How to Send Admin Message ?
#1

Hello, so I got this command where I set the players VIP level and I am wondering how can I make it so for me, the admin, sends a message notifying me that "You gave VIP level 1, 2 or 3 to "ID" player.

Here is the command:

Код:
CMD:setvip(playerid, params[])
{
   if(IsPlayerAdmin(playerid))
   {
	  new string[125], level, player1;
	  if(sscanf(params,"dd",player1, level)) return SendClientMessage(playerid, RED,"[USAGE]: /setvip ( playerid ) ( level )");
	  if(!IsPlayerConnected(playerid) && player1 != INVALID_PLAYER_ID)
	  {
		 SendClientMessage(playerid, RED,"[ERROR]: Player is not connected");
	  }
	  if(level > MAX_VIPL)
	  {
		 SendClientMessage(playerid, RED,"[ERROR]: Incorrect level");
	  }
	  else
	  {
	     format(string, sizeof(string),""cblue"Administrator "cgreen"'%s' "cblue"has set your vip level to "cgreen"'%d'", PlayerName(playerid),level);
	     SendClientMessage(player1, PURPLE, string);
	     PlayerPlaySound(player1,1057,0.0,0.0,0.0);
	     PlayerInfo[player1][pVIP] = level;
	  }
   }
   else return SendClientMessage(playerid, RED,"[ERROR]: You need to be RCON admin to use this command");
   return 1;
}
Reply
#2

Код:
format(string,sizeof(string),"You gave VIP level %d to %d player.",level,player1);
SendClientMessage(playerid,0xFFFFFFFF,string);
Reply
#3

use format

pawn Код:
CMD:setvip(playerid, params[])
{
   new admsg[128];
   if(IsPlayerAdmin(playerid))
   {
      new string[125], level, player1;
      if(sscanf(params,"dd",player1, level)) return SendClientMessage(playerid, RED,"[USAGE]: /setvip ( playerid ) ( level )");
      if(!IsPlayerConnected(playerid) && player1 != INVALID_PLAYER_ID)
      {
         SendClientMessage(playerid, RED,"[ERROR]: Player is not connected");
      }
      if(level > MAX_VIPL)
      {
         SendClientMessage(playerid, RED,"[ERROR]: Incorrect level");
      }
      else
      {
         format(string, sizeof(string),""cblue"Administrator "cgreen"'%s' "cblue"has set your vip level to "cgreen"'%d'", PlayerName(playerid),level);
         SendClientMessage(player1, PURPLE, string);
         PlayerPlaySound(player1,1057,0.0,0.0,0.0);
         PlayerInfo[player1][pVIP] = level;
         //>Format "admsg"
         format(admsg,sizeof(admsg),"[Admin Message]: You Gave Vip Level %d To Playerid %d",level, player1);
         //>Send it to playerid (someone that used command)
         SendClientMessage(playerid,-1,admsg);
      }
   }
   else return SendClientMessage(playerid, RED,"[ERROR]: You need to be RCON admin to use this command");
   return 1;
}
EDIT: @Raweresh Sorry i didn't refresh page before i submite post to see someone replied or no !
Reply
#4

Thanks ! Both !
Reply
#5

One more question, how can I set it so it shows player name and not the ID only.
Reply
#6

Код:
format(string,sizeof(string),"You gave VIP level %d to %s player.",level,PlayerName(player1));
SendClientMessage(playerid,0xFFFFFFFF,string);
Reply
#7

Quote:
Originally Posted by Raweresh
Посмотреть сообщение
Код:
format(string,sizeof(string),"You gave VIP level %d to %s player.",level,PlayerName(player1));
SendClientMessage(playerid,0xFFFFFFFF,string);
Thanks dude !
Reply
#8

Quote:
Originally Posted by Raweresh
Посмотреть сообщение
Код:
format(string,sizeof(string),"You gave VIP level %d to %s player.",level,PlayerName(player1));
SendClientMessage(playerid,0xFFFFFFFF,string);
he have to define PlayerName because it isn't defined by default

put it somewhere in your script

pawn Код:
stock PlayerName(playerid)
{
    new
        pName[MAX_PLAYER_NAME];

    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    return pName;
}
Reply
#9

Quote:
Originally Posted by M4D
Посмотреть сообщение
he have to define PlayerName because it isn't defined by default

put it somewhere in your script

pawn Код:
stock PlayerName(playerid)
{
    new
        pName[MAX_PLAYER_NAME];

    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    return pName;
}
I had it defined already.
Reply


Forum Jump:


Users browsing this thread: