Command to put on/off local chat
#1

Hello folks,

I was tried to create a command so players can decide to use local chat or not, but I failed hard time.

The command code look like this:

Код:
if (strcmp("/local", cmdtext, true) == 0)
	{
		if(localchat[playerid] == 0)
		{
		    localchat[playerid] = 1;
		}else{
		    localchat[playerid] = 0;
		}
		return 1;
	}
But it's not working, can somebody help me fix this or is this not possible?

Thanks!
Reply
#2

It's possible, combine it with OnPlayerText to check if somebody talks locally for players who turned it off.
Reply
#3

pawn Код:
public OnPlayerText(playerid, text[])
{
   for(new i; i<MAX_PLAYERS; i++)
   if(localchat[i] == 1) return SendClientMessage(i, playerid, text);
   return 0;
}
pawn Код:
public OnPlayerConnect(playerid);
{
   localchat[playerid] = 1;
   return 1;
}
I think this will work (with your command)
Changed Something
Reply
#4

Quote:
Originally Posted by CAR
Посмотреть сообщение
pawn Код:
public OnPlayerText(playerid, text[])
{
   for(new i; i<MAX_PLAYERS; i++)
   if(localchat[i] == 1) return 1;
   return 0;
}
I think this will work (with your command)
That'll show it to anyone in the area, guaranteed that there is someone who has it enabled. The idea is good though, +1.

pawn Код:
public OnPlayerText(playerid, text[])
{
  for(new i; i<MAX_PLAYERS; i++)
  {
     if(localchat[i] == 1) SendPlayerMessageToPlayer(i,playerid,text);
  }
  return 0;
}
Will only send it to players with it enabled.
Reply
#5

Yeah I changed it to that already :P
Reply
#6

'return' kills the callback, making it, in this case, only send it to the first ID who has his localchat enabled, and not to the others.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)