Problem with Gang Chat
#1

Hi, I've problem with Gang Chat, when I'm in gang and I want to use gang chat so I type "!" before my message, but when I do this nothing happens, my message is displayed in chat and anyone can see what I wrote...

Here is the code :

Quote:

public OnPlayerText(playerid, text[])
{

new te[256];
format(te, sizeof(te),"(id:%d): %s", playerid, text);
SendPlayerMessageToAll(playerid, te);
return 0;

if(text[0] == '!') {
if(playerGang[playerid] > 0) {
new gangChat[256];
new senderName[MAX_PLAYER_NAME];
new string[256];

// for(new i = 1; i < strlen(text)+1; i++)
// gangChat[i]=text[i];

strmid(gangChat,text,1,strlen(text));

GetPlayerName(playerid, senderName, sizeof(senderName));
format(string, sizeof(string),"Gang Chat: %s: %s", senderName, gangChat);

for(new i = 0; i < gangInfo[playerGang[playerid]][1]; i++) {
SendClientMessage(gangMembers[playerGang[playerid]][i], ROZOWY, string);
}
}

return 0;
}
return 1;
}

If I delete this :

new te[256];
format(te, sizeof(te),"(id:%d): %s", playerid, text);
SendPlayerMessageToAll(playerid, te);
return 0;

then everything works fine, but I'm using this to show ID after nick.

Can someone help me with this ?
Thanks.
Reply
#2

hi, i have the same problem, my code is this one

Код:
public OnPlayerText(playerid, text[])
{
	if(text[0] == '!') {
		if(playerGang[playerid] > 0) {
		  new gangChat[256];
		  new senderName[MAX_PLAYER_NAME];
		  new string[256];

//		  for(new i = 1; i < strlen(text)+1; i++)
//				gangChat[i]=text[i];

			strmid(gangChat,text,1,strlen(text));

			GetPlayerName(playerid, senderName, sizeof(senderName));
			format(string, sizeof(string),"%s: %s", senderName, gangChat);

			for(new i = 1; i < gangInfo[playerGang[playerid]][1]; i++) {
				SendClientMessage(gangMembers[playerGang[playerid]][i], COLOR_LIGHTBLUE, string);
			}
		}

		return 0;
	}
	return 1;
}
havent found anything to fix it, but maybe have you fixed yours?, or does anyone here want to lend a hand?
Reply
#3

remove your first return 0
Reply
#4

nop tried, doesnt work apparently, just displays as normal chat, if you like i can pass u the gm so you can have a look to see whether its correct?
Reply
#5

pawn Код:
new te[256];
  format(te, sizeof(te),"(id:%d): %s", playerid, text);
  SendPlayerMessageToAll(playerid, te);
return 0;
That code you have send message to all players anyway, doesn't matter whether they are gang members or not.

Try this:
pawn Код:
public OnPlayerText(playerid, text[])
{  
  new message[128];
 
  if (text[0] == &#39;!' && playerGang[playerid] > 0)
  {
     new playername[MAX_PLAYER_NAME];
     GetPlayerName(playerid, playername, MAX_PLAYER_NAME);

     strdel(text, 0, 1);
     format(message, sizeof(message),"Gang Chat: %s: %s", playername, text);
     
     for(new i = 0; i < gangInfo[playerGang[playerid]][1]; i++)
     {
        SendClientMessage(gangMembers[playerGang[playerid]], ROZOWY, message);
     }
  }
  else
  {
     format(message, sizeof(message)," (id:%d): %s", playerid, text);
     SendPlayerMessageToAll(playerid, message);
  }
  return 0;
}
Also you need read this topic.
Reply
#6

maybe this
Код:
	if(text[0] == '!')
	{
		if(playerGang[playerid] > 0)
		{
		  new gangChat[256];
		  new string[256];
			strmid(gangChat,text,1,strlen(text));
			format(string, sizeof(string),"(Clan-chat)%s: %s", Player(playerid), gangChat);
			for(new i = 0; i < gangInfo[playerGang[playerid]][1]; i++)
			{
				SendClientMessage(gangMembers[playerGang[playerid]][i], COLOR_LIGHTBLUE, string);
			}
		}

		return 0;
	}
Reply
#7

i used both and still shows up as normal chat ?ї, i get no errors or warnings :S
Reply
#8

Show your whole OnPlayerText
Reply
#9

public OnPlayerText(playerid, text[])
{
if(text[0] == '!') {
if(playerGang[playerid] > 0) {
new gangChat[256];
new senderName[MAX_PLAYER_NAME];
new string[256];

// for(new i = 1; i < strlen(text)+1; i++)
// gangChat[i]=text[i];

strmid(gangChat,text,1,strlen(text));

GetPlayerName(playerid, senderName, sizeof(senderName));
format(string, sizeof(string),"%s: %s", senderName, gangChat);

for(new i = 0; i < gangInfo[playerGang[playerid]][1]; i++) {
SendClientMessage(gangMembers[playerGang[playerid]][i], COLOR_LIGHTBLUE, string);
}
}

return 0;
}
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)