distance based speech? - 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: distance based speech? (
/showthread.php?tid=327956)
distance based speech? -
Vladamir - 23.03.2012
I have noticed that in a lot of RP game modes that when you are within a certain distance of another player they can "hear you" (displays their text)
I am very interested in what variables determine the distance and how one would go about setting up a filterscript or gamemode addition that would only allow my players to hear each other from a defined distance.
** Also I was unable to locate any documentation or even pieces of code inside the RP gamemodes that define distance from players for speech.
Any help would be MUCH appreciated and +REP!
Re: distance based speech? -
Reklez - 23.03.2012
You cannot rep but still i will help you.
use IsRangeOfPoint then loop it
Re: distance based speech? -
Vladamir - 23.03.2012
Quote:
Originally Posted by Reklez
use IsRangeOfPoint then loop it
|
Could you give me an example of a method in which I would utilize that to cater to speech?
Re: distance based speech? -
Reklez - 23.03.2012
pawn Код:
CMD:whisper(playerid, params[])
{
new string[128], Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(isnull(params)) return SendClientMessage(playerid, COLOR_GREY, "SYNTAX: /w(hisper) [message]");
if(pInfo[playerid][Mask] == 0) {
format(string, sizeof(string), "%s "blue"Whispers: "white"%s", GetName(playerid), params);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 6.0, x, y, z))
{
SendClientMessage(i, COLOR_WHITE, string);
}
}
} else if(pInfo[playerid][Mask] == 1) {
format(string, sizeof(string), "Stranger "blue"Whispers: "white"%s", params);
for(new i = 0; i < MAX_PLAYERS; i++) //looping
{
if(IsPlayerInRangeOfPoint(i, 6.0, x, y, z)) //is player near in the player talking at distance 6.0
{
SendClientMessage(i, COLOR_RED, string); //will sent to player that near in the player talking in float distance 6.0
}
}
}
return 1;
}
Re: distance based speech? -
Vladamir - 23.03.2012
Thank you very much! this is exactly what I was looking for.