Radio problem, proxdetector
#1

Hi some guy helped me a longtime ago with fixing so the sender only receives the message once and people around him will see it, but now it sends to ALL on the whole server.
Код:
  	if(strcmp(cmd, "/radio", true) == 0 || strcmp(cmd, "/r", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			new wstring[128];
			new faction = PlayerInfo[playerid][pFaction];
			new rank = PlayerInfo[playerid][pRank];
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[128];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_WHITE, "[Usage] (/r)adio");
				return 1;
			}
			if(Muted[playerid])
			{
				SendClientMessage(playerid, COLOR_GREY, "[Error] You can not use the radio, You are muted");
				return 1;
			}
			if(PlayerInfo[playerid][pFaction] == 5)
			{
				 		if(rank == 1)
						{
						  format(wstring, sizeof(wstring), "[Radio] %s %s: %s, over",DynamicFactions[faction][fRank1],GetPlayerNameEx(playerid),result);
						  FactionChatLog(wstring);
						}
				 		else if(rank == 2)
						{
						  format(wstring, sizeof(wstring), "[Radio] %s %s: %s, over",DynamicFactions[faction][fRank2],GetPlayerNameEx(playerid),result);
						  FactionChatLog(wstring);
						}
				 		else if(rank == 3)
						{
						  format(wstring, sizeof(wstring), "[Radio] %s %s: %s, over",DynamicFactions[faction][fRank3],GetPlayerNameEx(playerid),result);
						  FactionChatLog(wstring);
						}
				 		else if(rank == 4)
						{
						  format(wstring, sizeof(wstring), "[Radio] %s %s: %s, over",DynamicFactions[faction][fRank4],GetPlayerNameEx(playerid),result);
						  FactionChatLog(wstring);
						}
				 		else if(rank == 5)
						{
						  format(wstring, sizeof(wstring), "[Radio] %s %s: %s, over",DynamicFactions[faction][fRank5],GetPlayerNameEx(playerid),result);
						  FactionChatLog(wstring);
						}
				 		else if(rank == 6)
						{
						  format(wstring, sizeof(wstring), "[Radio] %s %s: %s, over",DynamicFactions[faction][fRank6],GetPlayerNameEx(playerid),result);
						  FactionChatLog(wstring);
						}
				 		else if(rank == 7)
						{
						  format(wstring, sizeof(wstring), "[Radio] %s %s: %s, over",DynamicFactions[faction][fRank7],GetPlayerNameEx(playerid),result);
						  FactionChatLog(wstring);
						}
				 		else if(rank == 8)
						{
						  format(wstring, sizeof(wstring), "[Radio] %s %s: %s, over",DynamicFactions[faction][fRank8],GetPlayerNameEx(playerid),result);
						  FactionChatLog(wstring);
						}
				 		else if(rank == 9)
						{
						  format(wstring, sizeof(wstring), "[Radio] %s %s: %s, over",DynamicFactions[faction][fRank9],GetPlayerNameEx(playerid),result);
						  FactionChatLog(wstring);
						}
				 		else if(rank == 10)
						{
						  format(wstring, sizeof(wstring), "[Radio] %s %s: %s, over",DynamicFactions[faction][fRank10],GetPlayerNameEx(playerid),result);
						  FactionChatLog(wstring);
						}
						SendFactionMessage(5, COLOR_LSPD, wstring);
						printf("%s", wstring);
						for(new i; i<MAX_PLAYERS; i++)
						{
						  if(IsPlayerConnected(i))
						  {
						    if(i != playerid)
						    {
						      ProxDetector(20.0, i, wstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
						    }
						  }
						}
						return 1;
			}
Its the
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(i != playerid)
{
ProxDetector(20.0, i, wstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_ FADE4,COLOR_FADE5);
Thats the problem, could anybody help me?
Reply
#2

ProxDetector sends a message to players depending on their position (local chat)

I suggest you use something way better, and a better method
pawn Код:
stock SendLocalChat(playerid,color,msg[],Float:radius)
{
  new Float:x,Float:y,Float:z;
  GetPlayerPos(playerid,x,y,z);
  for(new ply;ply<MAX_PLAYERS;ply++)
  {
    if(IsPlayerInRangeOfPoint(ply,radius,x,y,z))SendClientMessage(ply,color,msg);
  }
  return 1;
}
Reply
#3

Quote:
Originally Posted by Joe Staff
ProxDetector sends a message to players depending on their position (local chat)

I suggest you use something way better, and a better method
pawn Код:
stock SendLocalChat(playerid,color,msg[],Float:radius)
{
  new Float:x,Float:y,Float:z;
  GetPlayerPos(playerid,x,y,z);
  for(new ply;ply<MAX_PLAYERS;ply++)
  {
    if(IsPlayerInRangeOfPoint(ply,radius,x,y,z))SendClientMessage(ply,color,msg);
  }
  return 1;
}
Would that send the text to players around the guy who talks in the radio?
And would it display the text for the player twice or once? The problem is i only want it to appear once for the guy who wrote it because i use a "SendFactionChat" string, and then a proxdetector which sends my messages twice.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)