Local Chat
#1

Hey!

I'm using LimitGlobalChatRadius(125) on my server, so automatically when you write it only sends to the people around you.
Now I want to send the Message "Nobody around you recieved the message." if noone received the message. Now i have the weird bug, that the message also comes if 1 Person heard you, but as soon as 2 people hear it, it is all ok and the Message does not appear.

Anyone can help me please? Here is the code I'm using:

pawn Код:
LimitGlobalChatRadius(125);
    for(new i = 0; i < GetMaxPlayers(); i++)
    {
        if(GetDistanceBetweenPlayers(playerid, i) > 125)
        {
           SendClientMessage(playerid,COLOUR_WHITE , "( ! ) (INFO) Nobody around you recieved the message.");
        }
    }
Reply
#2

Omg, noone? Please help me >.<
Reply
#3

Use MAX_PLAYERS and replace the number of MAX_PLAYERS inside a_samp.inc with your max amount of players...
Shouldn't fix the problem, but it's better that way...
Reply
#4

Here, I'll show you my /l (local chat) command and I hope it helps you out.

Код:
		if(strcmp(cmd,"/l",true)==0 || strcmp(cmd,"/b",true)==0)
		{
		  new tmp[256];
		  new playername[24];
		  new string[150];
		  tmp=strtokmsg(cmdtext,idx);
		  if(!strlen(tmp))
		  {
		    SendClientMessage(playerid,White,"USAGE : /l [text]");
		    return 1;
		  }
		  for(new i = 0; i < MAX_PLAYERS; i++)
		  {
				GetPlayerName(playerid,playername,sizeof(playername));
				format(string,sizeof(string),"Local Chat~ %s : %s",playername,tmp);
				if(GetDistanceBetweenPlayers(playerid,i)<125)
				{
				  SendClientMessage(i,White,string);
				}
		  }
		  return 1;
		}
Reply
#5

Thanks for the replies. Well, not quite the thing I was searching for though... But I will try to replace 'GetMaxPlayers' with 'MAX_PLAYERS'... although I think it won't make such a big difference?

Maybe someone else knows the best solution for it...
Reply
#6

Hai!

I really don't know if this will work, but, you can try it :P
Replace this:
pawn Код:
for(new i = 0; i < GetMaxPlayers(); i++)
With this:
pawn Код:
for(new i = 0; i <= GetMaxPlayers(); i++)
I don't know if it will work, just guessing =)
Merry X-Mas and good luck!
Reply
#7

Quote:
Originally Posted by [SAP
Ycto ]
pawn Код:
for(new i = 0; i <= GetMaxPlayers(); i++)
Merry X-Mas and good luck!
I will give it a try... Merry christmas to you too
Reply
#8

Quote:
Originally Posted by [SAP
Ycto ]
Hai!

I really don't know if this will work, but, you can try it :P
Replace this:
pawn Код:
for(new i = 0; i < GetMaxPlayers(); i++)
With this:
pawn Код:
for(new i = 0; i <= GetMaxPlayers(); i++)
I don't know if it will work, just guessing =)
Merry X-Mas and good luck!
pawn Код:
for(new i = 0; i <= GetMaxPlayers(); i++)
obviously it doesn't work.
and also it's irrelevant with the problem.

even if you use this :
pawn Код:
for(new i = 0, j = GetMaxPlayers(); i < j; i++)
it's slower than:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
but if you limit max players lower than 200 in this case you should use the first method.
(i think so cause it will call useless IPC function)

you could try this.
but you should confirm before using this that GetDistanceBetweenPlayers is checking IPC(IsPlayerConnected).
pawn Код:
LimitGlobalChatRadius(125);
new i;
for(new i = 0, j = GetMaxPlayers(); i < j; i++)
{
    if( GetDistanceBetweenPlayers(playerid, i) <= 125 ) break;
}
if( i == MAX_PLAYERS ) SendClientMessage(playerid,COLOUR_WHITE , "( ! ) (INFO) Nobody around you recieved the message.");
if it works enjoy it
Reply
#9

Yes, the IPC is checked by GetDistanceBetweenPlayers.

If I compile your idea, it gives me "warning 219: local variable "i" shadows a variable at a preceding level"
Reply
#10

Quote:
Originally Posted by Soeren
Yes, the IPC is checked by GetDistanceBetweenPlayers.

If I compile your idea, it gives me "warning 219: local variable "i" shadows a variable at a preceding level"
That means you have to delete the variable "i" in that line.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)