How to make a Dynamic Chat system?
#1

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!
Reply
#2

I suggest you take a look at OnPlayerText and IsPlayerInRangeOfPoint.
Reply
#3

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)