06.11.2014, 18:04
In order to create a local chat, you need to find out the distance between the player speaking and the player you want to see the text, and then confirm how far you want it to be seen. Since the only variables you have is the player that is typing, I would do a for loop to detect the players that are close to you.
That's a way that you can accomplish this. All you have to do is adjust the distance to your liking. You can also add more else if statements and make it so if the player gets further the color can begin to fade. if you just want one solid color for anyone that is in a certain range then negate the else if statement. I hope this helps answer your question.
Код:
public OnPlayerText(playerid, text[])
{
new str[128], name[20];
if(text[0] == '@')
{
GetPlayerName(playerid, name, sizeof(name));
format(str, sizeof(str), "(({%06x}%s: %s))",GetPlayerColor(playerid) >>> 8, name, text[1]);// added {%06x} -GetPlayerColor(playerid) >>> 8
SendClientMessageToAll(-1, str);
return 0;
} else { // if doesn't start with @
new Float:x,Float:y,Float:z,Float:fDistance;
GetPlayerPos(playerid,x,y,z);
new FormatBuffer[255];
new NameBuffer[255];
GetPlayerName(playerid,NameBuffer,sizeof(NameBuffer));
format(FormatBuffer,sizeof(FormatBuffer),"%s : %s",NameBuffer,text);
for(new i = 0; i < MAX_PLAYERS; i++) {
if(!IsPlayerConnected(i)) continue;
fDistance = GetPlayerDistanceFromPoint(i, x, y, z);
if(fDistance == 2) {
SendClientMessage(i,0xFFFFFFFF, FormatBuffer);
}
else if(fDistance == 3) {
}
}
}
return 1;
}

