• 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 [Updated] Block IPs 0.3.6

Summ

(\/)(;,,;)(\/) Y not?
Staff member
Global Moderator
Joined
Oct 15, 2008
Messages
4,152
Solutions
12
Reaction score
1,107
Location
Germany :O
Hi
Since the old didn't work well I updated it for you.
All credits to @Gesior.pl

Fixes:
-Script won't execute twice now
-Fixed .lua file to work correct with 0.3.6
-Added spam protection to .lua (since it counts as talkaction it has no muted check)

Open talkaction.cpp of yur sources and search for:
Code:
if(!talkAction || (talkAction->getChannel() != -1 && talkAction->getChannel() != channelId))
return false;
and replace it with:
Code:
    if(!talkAction)
    {
        for(TalkActionsMap::iterator it = talksMap.begin(); it != talksMap.end(); ++it)
        {
            if(it->first == "illegalWords")
            {
                talkAction = it->second;
                break;
            }
        }
        if(talkAction && talkAction->isScripted())
            return talkAction->executeSay(creature, words, "", channelId);
        return false;
    }
    else if(talkAction->getChannel() != -1 && talkAction->getChannel() != channelId)
        return false;
Compile your server now.

Go to talkactions/talkactions.xml and add:
Code:
<talkaction words="illegalWords" event="script" value="blocklinks.lua"/>
NOTE: Do not change words="illegalWords" or it will not work..

Create "blocklinks.lua" in talkactions/scripts and paste that in this file:
Code:
function getFixedText(cid, text, replace)
    local wrongWords = {"otservlist.org", "ots-list.pl", "google.br", "83.17.165.189", "hopto.org", "no-ip.org", ".com"}
    local lowerText = string.lower(text)
    local noSpaceText = string.gsub(string.gsub(string.gsub(lowerText, "%s", ""), "%p", ""),"-", "")
    for w = 1, #wrongWords do
            wordLen = string.len(wrongWords[w])
            for p = 1, string.len(text) do
                    if(string.sub(lowerText, p, p+wordLen-1) == wrongWords[w]) then
                            text = string.sub(text, 1, p-1) .. string.rep(replace, wordLen) .. string.sub(text, p+wordLen)
                    end
            end
    end

    if(string.lower(text) == lowerText) then
            for c = 1, #wrongWords do
                    if(string.find(noSpaceText, string.gsub(string.gsub(wrongWords[c], "%p", ""),"-", "")) ~= nil) then
                            return "I want to post forbidden links.."
                    end
            end
    end
    return text
end

--[[Channels which are not added to block:
1 - Party Channel
2 - Channel for Staff members
3 - Rule Violation Channel
4 - Channel for Counselors/Tutors
65536 - Private Chat Channel  <-- Private Chat cannot be blocked with this script
]]--
local blocked_channels = {5,8,9} --Game-Chat, Real Chat, Help Channel
local trade_channels = {6,7}  --All trade channels <- These are also blocked
local replace = "°"  --Symbols which are shown instead of forbidden links -> °
local delay = {16246,5} -- {empty_storage, lenght of muted}

function onSay(cid, words, param, channel)
    local fixedWords = getFixedText(cid, words, replace)

    if words ~= fixedWords and getPlayerAccess(cid) == 0 then
        if getPlayerStorageValue(cid,delay[1]) > os.time() then
            return doPlayerSendCancel(cid,"You are still muted for ".. getPlayerStorageValue(cid,delay[1])-os.time() .." seconds.")
        end
        setPlayerStorageValue(cid,delay[1],os.time()+delay[2])
        if channel == CHANNEL_DEFAULT then
            doCreatureSay(cid, fixedWords, TALKTYPE_SAY)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Link: "..words.." is forbidden.")
            return true
        elseif isInArray(trade_channels, channel) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Link: "..words.." is forbidden on the trade channel.")
            return true
        elseif isInArray(blocked_channels, channel) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Link: "..words.." is forbidden.")
            doPlayerSendChannelMessage(cid, getCreatureName(cid), fixedWords, TALKTYPE_CHANNEL_Y, channel)
            return true
        end
    end
    return false
end

Description:
blocked_channels -> Array with the channel_id of blocked channels
Note: You cannot block private messages this way.
trade_channels = {6,7} --List of trade channels, which are also blocked
replace -> The script replaces the links with the symbol entered here
delay = {16246,5} -> Mute feature. First number is an empty storage id and second the time how long you can't say another forbidden link.
---> The player is not really muted. He can talk normal, but he is "muted" for illegal links for that period of time.


Always remember that Gesior.pl was the one who did this script I just updated it.

Have fun

~Summ
 
Last edited:
Well, there is a little problem with this, when someone add ".pl" to the wrongWords table, and someone in game say fe. "pls" then it block that :p. Same for the ".com" - if player say "come" it'll be blocked.
 
Last edited:
Well, there is a little problem with this, when someone add ".pl" to the wrongWords table, and someone in game say fe. "pls" then it block that :p. Same for the ".com" - if player say "come" it'll be blocked.

has that been fixed yet ?
 
if it search for .com and .pl it should work, if it would search just for come it can cause problems

but honestly, I would do it in chat.cpp instead of emulating usage of talkaction every time someone says something
and in chat.cpp you can play with prv messages and fe disable links from people that are not on receivers viplist(just ignore that message probably?)
yeah, I'm complaining a bit
 
Last edited:
Back
Top