• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TalkAction Advanced Anti-swearing

Mazen

Developer
Joined
Aug 20, 2007
Messages
612
Reaction score
38
Location
Sweden
Greetings everyone. If the open-tibia team would ever implement a type of talkaction that work for all words at the same time, this script would be very useful and yes, I got the idea from Runescape. :p

Right now nether open-tibia or any OT distribution support this. Anyway, here is the script:

In data/talkactions/scripts/illegalwords.lua:
Lua:
local BlockedChannels = {
	{channel = CHANNEL_DEFAULT}, 
	{channel = CHANNEL_HELP, type = TALKTYPE_CHANNEL_Y}, 
	{channel = CHANNEL_GUILD, type = TALKTYPE_CHANNEL_Y}
}

local InvalidWords = {
        "whore",
        "slut",
        "fuck",
        "mother~fucker"
}

function onSay(cid, words, param, channel)
local TheWords = words .. param
	for i, select in ipairs(BlockedChannels) do
		if select.channel == channel then
			talkType = select.type
			break
		elseif select.channel ~= channel and i == #BlockedChannels then
			return false
		end
	end

        for i = 1, #InvalidWords do
                TheWords = TheWords:gsub("(%a*".. nocase(InvalidWords[i]) .."%a*)", doFixString(InvalidWords[i]))
        end

	if channel == CHANNEL_DEFAULT then
        	doCreatureSay(cid, TheWords, TALKTYPE_SAY)
	else
		doPlayerSendChannelMessage(cid, getCreatureName(cid), TheWords, talkType, channel)
	end
        return true
end

function doFixString(w) 
        return ("*"):rep(w:len())
end 

function nocase(s)
        -- From: [url]http://www.lua.org/pil/20.4.html[/url]
        return s:gsub("%a", function(c) return ("[%s%s]"):format(c:lower(), c:upper()) end)
end

The sentence:
Code:
Hey you fucktard, get your fucking ass here, bitch!

Will turn into:
Code:
Hey you ********, get your ******* ass here, *****!

News:
Gesior made a way to make this work. :D

Credits To Gesior for this code.

Here is the C++ code:
C++ code (TFS 0.3.5 !) execute talkaction 'Allwords' always when anything say something (not spell/talkaction). LUA script must check is it player, channel ...
In source in talkaction.cpp find:
PHP:
	if(!talkAction || (talkAction->getChannel() != -1 && talkAction->getChannel() != channelId))
		return false;
and replace with:
PHP:
	if(!talkAction)
	{
    	for(TalkActionsMap::iterator it = talksMap.begin(); it != talksMap.end(); ++it)
    	{
    		if(it->first == "Allwords")
    		{
    			talkAction = it->second;
    			break;
    		}
    	}
    	if(talkAction && talkAction->isScripted() && talkAction->executeSay(creature, words, "", channelId))
    	    return true;
        return false;
    }
    else if(talkAction->getChannel() != -1 && talkAction->getChannel() != channelId)
		return false;
(compile :) )
in talkactions.xml add:
Code:
<talkaction words="Allwords" event="script" value="illegalwords.lua"/>
 
Last edited:
Yea, would be nice i was thinking about anty-advertise system, but can't catch all messages via LUA :x
 
Yea, would be nice i was thinking about anty-advertise system, but can't catch all messages via LUA :x

You can make a script that checks such messages with the words ".com" and "no-ip", then log the sentence and you decide if you wish to add it or not. But idk, there are a lot of nice ideas.
 
Yea, but i have to add the all avalible ip's like 123.456.789.00? It will take a lot of time xD
 
But it's really possible to do, i think it's easy you have to spent some time with source :p
 
But can i use tag like A-Z0-9 in talkactions.xml? ^^
 
not working on 0.2.5

and what do I have to add to talkactions.xml?
 
not working on 0.2.5

and what do I have to add to talkactions.xml?

It doesn't work on any OT, it's just an idea. If OT would support a talkaction that works for every word, this script would work, but right now it doesn't work because OT doesn't support this.
 
Last edited:
Lua:
local invalidWords = {
	'whore',
	'fuck',
	'dick',
}

function onSay(cid, words, param, channel)
	words = (words .. ' ' .. param)
	for k, v in ipairs(invalidWords) do
		words = words:gsub("%a*" .. v .. "%a*", function(v) return ('*'):rep(v:len()) end)
	end
	doCreatureSay(cid, words, TALKTYPE_SAY)
	return true
end

Should work better too :)


** Mod warning ** These are just examples, no need to infract me hehe :D
whore motherfucker just fuck yourself fucking dickhead lol go die haha
goes
***** ************ just **** yourself ******* ******** lol go die haha
 
Last edited:
Back
Top