SA-MP Forums Archive
Teamchat spam in IRC - 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: Teamchat spam in IRC (/showthread.php?tid=105781)



Teamchat spam in IRC - Striker_Moe - 31.10.2009

Hi there.

Iґm using this script for teamchat:

Код:
	if(strcmp(cmdtext, "/t", true))
	{
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if(MyVar[i] == MyVar[playerid])
				{
					new pname[26];
					GetPlayerName(playerid, pname, sizeof(pname));
					new str[256];
					format(str, 256, "[TEAM] %s: %s", pname, cmdtext[3]);
					SendClientMessage(i, 0x2641FEAA, str);
					IrcSay(str);
				}
			}
		}
		return 1;
	}
But unfortunately, when someone writes something on /t, the IRC channel is getting spammed with it. (IrcSay(str). Why?


Re: Teamchat spam in IRC - Westie - 31.10.2009

It's because you're calling ircSay whenever you send someone a team message.

Код:
if(strcmp(cmdtext, "/t", true))
{
	new
		sPlayerName[MAX_PLAYER_NAME],
		sOutput[128];
		
	GetPlayerName(playerid, sPlayerName, sizeof sPlayerName);
	format(sOutput, sizeof sOutput, "[TEAM] %s: %s", sPlayerName, sOutput);
	
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(MyVar[i] == MyVar[playerid])
			{
				SendClientMessage(i, 0x2641FEAA, sOutput);
			}
		}
	}

	IrcSay(sOutput);
	return 1;
}
Also, learn to name variables appropriately


Re: Teamchat spam in IRC - Striker_Moe - 31.10.2009

Good job, now the text doesnt display any more.