Log Chat with MYSQL == Too Demanding?
#2

Quote:
Originally Posted by cAMo
Is it too demanding for a server to INSERT every line of chat into a MySQL database for logging purposes?

Yes / No? Ideas?
No. Inserts are not that bad, i know of 4 servers that use MySQL to log chat / other player events, and they handle it with ease. If you do add the chat logging though, i'd add a flood protection script.


EDIT:

Here's a little flood protection i whipped up, its pretty simple.

Код:
#include <a_samp>

#define MAX_WARNINGS 5 //warnings before a kick
#define CHAT_LIMIT 5 //seconds before they can send another message


enum E_FLOOD
{
	Tick,
	Warnings
}

new AntiSpam[MAX_PLAYERS][E_FLOOD], String[128];

public OnFilterScriptInit()
{
	print("\n**************************************");
	print("--------------------------------------");
	print("|   Kyoshiro's AntiSpam Loaded!!  |");
	print("--------------------------------------");
	print("**************************************\n");
}

public OnPlayerText(playerid, text[])
{
	if(GetTickCount() - AntiSpam[playerid][Tick] <= CHAT_LIMIT * 1000)
	{
		new seconds = CHAT_LIMIT-(GetTickCount() - AntiSpam[playerid][Tick])/1000;

		format(String, sizeof(String), "Please wait %d %s to talk! Warning %d of %d!!",seconds,(seconds==1)?("second"):("seconds"),AntiSpam[playerid][Warnings]+1, MAX_WARNINGS);
		SendClientMessage(playerid,0xFF0000FF,String);

		AntiSpam[playerid][Warnings]++;

		if(AntiSpam[playerid][Warnings] >= MAX_WARNINGS)
		{
			SendClientMessage(playerid, 0xFF0000FF, "You were kicked for flooding the chat!!");
			Kick(playerid);
		}
		return 0;
	}
	AntiSpam[playerid][Tick] = GetTickCount(), AntiSpam[playerid][Warnings] = 0;
	return 1;
}
Reply


Messages In This Thread
Log Chat with MYSQL == Too Demanding? - by cAMo - 18.05.2010, 22:48
Re: Log Chat with MYSQL == Too Demanding? - by Kyosaur - 19.05.2010, 00:16
Re: Log Chat with MYSQL == Too Demanding? - by cAMo - 19.05.2010, 00:29
Re: Log Chat with MYSQL == Too Demanding? - by Kyosaur - 19.05.2010, 00:32
Re: Log Chat with MYSQL == Too Demanding? - by cAMo - 19.05.2010, 01:17
Re: Log Chat with MYSQL == Too Demanding? - by Kyosaur - 19.05.2010, 01:42
Re: Log Chat with MYSQL == Too Demanding? - by Bayler - 19.05.2010, 02:37
Re: Log Chat with MYSQL == Too Demanding? - by Kyosaur - 19.05.2010, 02:55
Re: Log Chat with MYSQL == Too Demanding? - by Bayler - 19.05.2010, 03:25
Re: Log Chat with MYSQL == Too Demanding? - by Sergei - 19.05.2010, 04:19

Forum Jump:


Users browsing this thread: 1 Guest(s)