Jump to content
Jelly

Anti-spam script

Recommended Posts

if i want so that if a player says messages over X times a minute, for example, if he exceeds the limit it will mute him

 

how to script it?

Share this post


Link to post
Share on other sites

@Jelly

You need GameServer.exe with HandleChat function. In that function you can write script which will check how many times player send messages to chat.

 

For example:

variable.lua

LocalChat = {}

functions.lua

function HandleChat(role, message)
	
	local minute = os.date("%M")
	
	if (LocalChat[role] == nil) then
		LocalChat[role] = {}
	else

		if (LocalChat[role].minute == minute) then
			
			-- 25 messages are maximum
			if (LocalChat[role].number > 25) then
				-- Mute player
				SystemNotice(role, "Don't flood in local chat please!")
				return 0
			else
				LocalChat[role].number = LocalChat[role].number + 1
			end
			
		else
			LocalChat[role].minute = minute
			LocalChat[role].number = 1
		end
	end
	
	return 1
	
end

Note: haven't tested

  • Like 1

Share this post


Link to post
Share on other sites
19 hours ago, V3ct0r said:

@Jelly

You need GameServer.exe with HandleChat function. In that function you can write script which will check how many times player send messages to chat.

 

For example:

variable.lua


LocalChat = {}

functions.lua


function HandleChat(role, message)
	
	local minute = os.date("%M")
	
	if (LocalChat[role] == nil) then
		LocalChat[role] = {}
	else

		if (LocalChat[role].minute == minute) then
			
			-- 25 messages are maximum
			if (LocalChat[role].number > 25) then
				-- Mute player
				SystemNotice(role, "Don't flood in local chat please!")
				return 0
			else
				LocalChat[role].number = LocalChat[role].number + 1
			end
			
		else
			LocalChat[role].minute = minute
			LocalChat[role].number = 1
		end
	end
	
	return 1
	
end

Note: haven't tested

i tested. it works! thanks @V3ct0r!

 

can u give me a list of the variables that handlechat has?

 

(example: LocalChat)

Share this post


Link to post
Share on other sites

@Jelly

LocalChat is my variable (array) that I defined in file variables.lua to use it for counting player's messages.

 


Share this post


Link to post
Share on other sites
On 21/5/2016 at 5:17 PM, V3ct0r said:

What channel?

 

And for example if i want to make it for World-Trade or PM Chat? 9_9

Edited by Giampy

Share this post


Link to post
Share on other sites
5 часов назад, Giampy сказал:

 

And for example if i want to make it for World-Trade or PM Chat? 9_9

You can't. World, Trade, PM and guild chats are in the GroupServer.exe. So you have to patch GroupServer to make it call some LUA functions before message will be sent to selected chat channel.

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, Giampy said:

 

And for example if i want to make it for World-Trade or PM Chat? 9_9

 

Groupserver.cfg

 

"WorldInterval        =    60
TradeInterval        =    300"

 

 

  • Like 2

logo-big.png   logo.png

                                   Sunny Go! Online                                                                    pko.host                                                 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...