18.05.2010, 22:48
Is it too demanding for a server to INSERT every line of chat into a MySQL database for logging purposes?
Yes / No? Ideas?
Yes / No? Ideas?
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? |
#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; }
Originally Posted by cAMo
I'm not too familiar with GetTickCount, but I did look it up.
Would GetTickCount be better than doing something like: OnPlayerText { if(String_Count < 5) { String_Count ++; return 1; } else { return 0; } } Then have a 1 second timer: String_Count --; Note: Obviously this doesn't work, but which method would you recommend? Timer or Tick? |
Originally Posted by cAMo
Do you do the same with OnPlayerCommandText?
|
Originally Posted by Bayler
If you Store Chat Text to an SQL table, its going to pack VERY fast ...
In a few days, that SQL database is going to be SOOO massive that your going to have issues, especially if your using Cron Tabs to do Auto SQL backups. I Strongly Suggest that you use File Based Logging for Chat Recording ... you can just as easily parse a file to a website as you can stream SQL to a website. |