SA-MP Forums Archive
How to make a Dynamic Chat system? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to make a Dynamic Chat system? (/showthread.php?tid=520663)



How to make a Dynamic Chat system? - Jigsaw123 - 19.06.2014

Hi..

Im wondering how to make a dynamic chat system? ( Ima newb. scripter ). Basically, when you speak, I don't want the whole server to hear, and only people around you. If you could help me, It'll be great.

Thanks!


Re: How to make a Dynamic Chat system? - Manyula - 19.06.2014

I suggest you take a look at OnPlayerText and IsPlayerInRangeOfPoint.


Re: How to make a Dynamic Chat system? - Jigsaw123 - 19.06.2014

I understand onPlayerText, but i don't understand how to make only people close to him/her hear it.. ?


Re: How to make a Dynamic Chat system? - Manyula - 19.06.2014

In the moment the player sends a client message, you basically get your position and loop through the positions of all players around you - this will provide you with the fundamentals, namely the current positions of all the players on the server exactly in the moment you sent the client message. Using IsPlayerInRangeOfPoint, you can check whether any position of any player on the server is within the range of hearing.

EDIT:
Код:
public OnPlayerText(playerid, text[])
{
	for(new i; i<MAX_PLAYERS; i++)
	{
		new Float:X, Float:Y, Float:Z;
		GetPlayerPos(i, X, Y, Z);
		if(!IsPlayerInRangeOfPoint(playerid, 100.0, X, Y, Z)) return 0;
		else return 1;
	}
	return 1;
}
Untested. You may want to include a check for whether a player is connected.

EDIT 2: https://sampwiki.blast.hk/wiki/LimitGlobalChatRadius