SA-MP Forums Archive
Problem with Gang Chat - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with Gang Chat (/showthread.php?tid=66327)



Problem with Gang Chat - dawidek11 - 21.02.2009

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.


Re: Problem with Gang Chat - _diana_ - 30.08.2009

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?


Re: Problem with Gang Chat - HuRRiCaNe - 30.08.2009

remove your first return 0



Re: Problem with Gang Chat - _diana_ - 30.08.2009

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?


Re: Problem with Gang Chat - Zeex - 30.08.2009

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.



Re: Problem with Gang Chat - Imran.Abbas - 30.08.2009

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;
	}



Re: Problem with Gang Chat - _diana_ - 31.08.2009

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


Re: Problem with Gang Chat - dice7 - 31.08.2009

Show your whole OnPlayerText


Re: Problem with Gang Chat - _diana_ - 31.08.2009

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;
}