Idea from http://otland.net/f81/advanced-anti-swearing-50400/
When player say:
C++ code (TFS 0.3.5 !) execute talkaction 'illegalWords' always when anything say something (not spell/talkaction). LUA script must check is it player, channel ...
In source in talkaction.cpp find:
and replace with:
(compile )
in talkactions.xml add:
in illegalwords.lua paste:
(it block links on trade/rook-trade, because player doesn't get 2 min exhaust when post links with this script)
If talkaction return false (illegalWords false = good msg) player say normal message/send to channel.
EDIT:
ADDED NEW LINK/IP DETECTION FUNCTION
Its version to block links, better dont try to add here insults like 'fuck' because it can work wrong and block other words (ignore [one or more] 'space', ',', '.', '-', ' , " in text)
you can block user otses like:
if spammer 'is pro' and try something like (space and - ):
When player say:
it show:otservlist.org/index.php&show=543456
---------------------13:06 Gessi [102]: (illegal IP)/index.php&show=543456
C++ code (TFS 0.3.5 !) execute talkaction 'illegalWords' 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;
PHP:
if(!talkAction)
{
for(TalkActionsMap::iterator it = talksMap.begin(); it != talksMap.end(); ++it)
{
if(it->first == "illegalWords")
{
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;
in talkactions.xml add:
PHP:
<talkaction words="illegalWords" event="script" value="illegalwords.lua"/>
Lua:
function getFixedText(cid, text)
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("*", 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 think I'm better then link blocker, but I'm not :( (message from link blocker)."
end
end
end
return text
end
function onSay(cid, words, param, channel)
local fixedWords = getFixedText(cid, words)
if words ~= fixedWords and getPlayerAccess(cid) == 0 then
if channel == 0 then -- default
doCreatureSay(cid, fixedWords, TALKTYPE_SAY)
return true
elseif channel == 5 or channel == 7 then -- trade
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't send links to Trade channel.")
return true
elseif channel == 9 then -- help
doPlayerSendChannelMessage(cid, getCreatureName(cid), fixedWords, TALKTYPE_CHANNEL_Y, channel)
return true
end
end
return false
end
If talkaction return false (illegalWords false = good msg) player say normal message/send to channel.
EDIT:
ADDED NEW LINK/IP DETECTION FUNCTION
Its version to block links, better dont try to add here insults like 'fuck' because it can work wrong and block other words (ignore [one or more] 'space', ',', '.', '-', ' , " in text)
you can block user otses like:
or short link/dns services like:xxxx.hopto.org
or 90% links:no-ip.net
hopto.org
tinyurl.net
for normal user that try to post link it show:.org
.net
.com
.pl
.br
if someone try to post link to his ots:Say: View movie http://www.youtube.com/watch?v=CsGYh8AacgY
23:48 Erg: View movie http://www.youtube****/watch?v=CsGYh8AacgY
players will have problem to get info what is address of serverNEW BEST RPG OTS! ACC. MAKER http://mybestots.hopto.org/index.php
23:49 Erg: NEW BEST RPG OTS! ACC. MAKER http://mybestots.*********/index.php
if spammer 'is pro' and try something like (space and - ):
JUST EDIT CONFIG (add spammed link/ip) IN LUA FILE AND ON GOD IN GAME SAY '/reload talkactions'NEW BEST RPG OTS! ACC. MAKER http://mybestots - hopto - org/index.php
23:50 Erg: I think I'm better then link blocker, but I'm not (message from link blocker).
Last edited: