23.03.2014, 03:45
I am creating a RP script and I am new to scripting so I need to know how to create a chat with range, like for talking Icly.
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(w,1,cmdtext)
return 0;
}
dcmd_w(playerid,params[])
{
new Pname[28];
GetPlayerName(playerid,Pname,sizeof(Pname));
new string[128];
if(!strlen(params))
{
SendClientMessage(playerid,COLOR_ERROR,"USAGE: /w (msg)");
return 1;
}
format(string, sizeof(string), "[WHISPER] %s(%d): %s",Pname(playerid),playerid,params);
printf("%s", string);
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i) && GetDistanceBetweenPlayers(playerid,i) < 10)
{
format(string, sizeof(string), "[WHISPER] %s(%d): %s",Pname(playerid),playerid,params);
SendClientMessage(i,COLOR_YELLOW,string);
}
}
return 1;
}
CMD:s(playerid,params[]) { if(isnull(params)) return SendClientMessage(playerid, -1, "USAGE: /s [text] to talk to nearest person"); new Name[MAX_PLAYER_NAME]; GetPlayerName(playerid, Name, sizeof(Name)); new string[128], Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); format(string, sizeof(string), "[%s] says: %s", Name, params[0]); new str[128]; format(str, sizeof(str),"[SAY] %s: %s", Name, params[0]); printf("%s", string); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i,50.0, x, y, z) ) SendClientMessage(i, COLOR_RED, string); } return 1; }