14.01.2014, 16:14
So, I was thinking what I needed to script and in the back of my mind I remembered I needed a whisper command. I would like to know if the system I thought of would work and if it does, is there anyway I can improve it.
pawn Код:
CMD:whisper(playerid, params[])
{
new tid, message[128], recieved[128];
if(PlayerInfo[playerid][pAdmin] < 1)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(tid, x, y, x);
if(sscanf(params, "ds", tid, message)) return SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /(w)hisper [playerid] [message]");
if(IsPlayerInRangeOfPoint(playerid, 7, x, y, z)) return SendClientMessage(playerid, COLOR_WHITE, "You are not near that person!");
else
{
format(message, sizeof(message), "You whispered to %s [%i]: %s", GetPlayerNameEx(tid), tid, message);
SCM(playerid, COLOR_YELLOW, message);
format(recieved, sizeof(recieved), "Whisper from %s [%i]: %s", GetPlayerNameEx(playerid), playerid, message);
SCM(tid, COLOR_YELLOW, recieved);
}
}
else
{
if(sscanf(params, "ds", tid, message)) return SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /(w)hisper [playerid] [message]");
format(message, sizeof(message), "You whispered to %s [%i]: %s", GetPlayerNameEx(tid), tid, message);
SCM(playerid, COLOR_YELLOW, message);
format(recieved, sizeof(recieved), "Whisper from %s [%i]: %s", GetPlayerNameEx(playerid), playerid, message);
SCM(tid, COLOR_YELLOW, recieved);
}
return 1;
}