• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Advanced Anti-Insult Script

Delirium

OTLand veteran
Staff member
Global Moderator
Joined
May 28, 2007
Messages
3,365
Solutions
1
Reaction score
290
Location
Athens, Greece
Hello. I've been bored so I decided to make a script that gives a punishment to people that use offensive words.

How it works?

If a player says an offensive word (e.g "fuck") he will be given a warning at first. Then he'll be jailed, then warned again and then banished. Simple eh?

How do I implement that?

Add this script in the talkactions folder:

anti-insult.lua -
Lua:
-- Advanced Anti-Insult script by KuGaSh1rA --
local JailTime = 1000 * 60 * 60
local OffenseStorage = 20000
local JailPosition = {x = 1000, y = 1000, z = 7}
local UnjailPosition = {x = 1000, y = 1000, z = 7}
local BanTime = 24 * 60 * 60
local BanDelayAfterFYI = 1000 * 10
local DamageOnOffense = -500

function onSay(cid, words, param)
	if getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE then
		if getPlayerStorageValue(cid, OffenseStorage) == -1 then
			doPlayerSendTextMessage(cid, 19, "Insulting another player is not allowed. In the next offense you will be jailed.")
			setPlayerStorageValue(cid, OffenseStorage, 1)
		elseif getPlayerStorageValue(cid, OffenseStorage) == 1 then
			doPlayerSendTextMessage(cid, 19, "Insulting another player is not allowed. You have been jailed.")
			setPlayerStorageValue(cid, OffenseStorage, 2)
			doTeleportThing(cid, JailPosition)
			addEvent(Unjail, JailTime, cid)
		elseif getPlayerStorageValue(cid,OffenseStorage) == 2 then
			doPlayerSendTextMessage(cid, 19, "Insulting another player is not allowed. This is your last warning.")
			setPlayerStorageValue(cid, OffenseStorage, 3)
		elseif getPlayerStorageValue(cid, OffenseStorage) == 3 then
			setPlayerStorageValue(cid, OffenseStorage, -1)
			if doPlayerPopupFYI(cid, "You have been banished for offending another player.") then
				addEvent(BanPlayer, BanDelayAfterFYI, cid)
			end
		end
	else
		doCreatureAddHealth(cid, DamageOnOffense)
		doPlayerSendTextMessage(cid, 19, "Insulting while being in combat makes you hurt.")
	end
end

function Unjail(cid)
	doTeleportThing(cid, UnjailPosition)
	doPlayerSendTextMessage(cid, 19, "You are free to go. If you insult again you'll have only a final warning and then a banishment.")
end

function BanPlayer(cid)
	local playerName = getCreatureName(cid)
	local pAcc = getAccountIdByName(playerName)
	doAddBanishment(pAcc, BanTime, 4, 2, "Automatic Banishment for Offensive Statement")
	doRemoveCreature(cid)
end

And then in talkactions.xml add this:

HTML:
<talkaction words="bitch" event="script" value="anti-insult.lua"/>
<talkaction words="fag" event="script" value="anti-insult.lua"/>
<talkaction words="bastard" event="script" value="anti-insult.lua"/>


Do not forget to change these:
Lua:
local JailPosition = {x = 1000, y = 1000, z = 7}
local UnjailPosition = {x = 1000, y = 1000, z = 7}
local JailTime = 1000 * 60 * 60
local BanTime = 24 * 60 * 60
local BanDelayAfterFYI = 1000 * 10
local DamageOnOffense = -500



If you wish to add more offensive words then do the following:

Add this in talkactions.xml:
HTML:
<talkaction words="offensivewordshere" event="script" value="anti-insult.lua"/>

and then change "offensivewordshere" to the offensive word (or words) you want (e.g "fuck off").


If you have any question, feel free to post.
 
Last edited:
Improved:
Lua:
-- Advanced Anti-Insult script by Kugashira // improved by Keraxel --
local data = {
	jailTime = 1000 * 60 * 60,
	storage = 20000,
	jailPosition = {x = 1000, y = 1000, z = 7},
	banTime = 24 * 60 * 60,
	banDelayAfterFYI = 1000 * 10,
	messageColor = 19,
	messages = {
		"Insulting another player is not allowed. In the next offense you will be jailed.",
		"Insulting another player is not allowed. You have been jailed.",
		"Insulting another player is not allowed. This is your last warning.",
		"You have been banished for offending another player."
	}
}

function onSay(cid, words, param)
	local warning = getPlayerStorageValue(cid, data.storage)
	warning = ((warning >= 0) and warning) or 0

	if warning == 1 then
		addEvent(Unjail, data.jailTime, {cid = cid, position = getCreaturePosition(cid)})
		doTeleportThing(cid, data.jailPosition)
	elseif warning = 3 then
		setPlayerStorageValue(cid, data.storage, -1)
		addEvent(BanPlayer, BanDelayAfterFYI, cid)
		return doPlayerPopupFYI(cid, data.messages[#data.messages])
	end
	doPlayerSendTextMessage(cid, data.messageColor, data.messages[warning + 1])
	return doPlayerSendTextMessage(cid, data.messageColor, data.messages[warning + 1])
end

function Unjail(p)
	doTeleportThing(p.cid, p.position)
	return doPlayerSendTextMessage(p.cid, data.messageColor, "You are free to go. If you insult again you'll have only a final warning and then a banishment.")
end

function BanPlayer(cid)
	doAddBanishment(getAccountIdByName(getCreatureName(cid)), BanTime, 4, 2, "Automatic Banishment for Offensive Statement")
	return doRemoveCreature(cid)
end

Probably swears can be wrote like this:
PHP:
<talkaction words="bitch;fag;bastard" event="script" value="anti-insult.lua"/>
 
To give a RPG feelings, you should replace "fuck" with "$^&%" ^_^.
Would be easy to make I assume?

I bet people would like that.
 
To give a RPG feelings, you should replace "fuck" with "$^&%" ^_^.
Would be easy to make I assume?

I bet people would like that.

I totally agree with you :)

But still this is a really cool script i think i'm going to use it :p
 
Improved:
Lua:
-- Advanced Anti-Insult script by Kugashira // improved by Keraxel --
local data = {
	jailTime = 1000 * 60 * 60,
	storage = 20000,
	jailPosition = {x = 1000, y = 1000, z = 7},
	banTime = 24 * 60 * 60,
	banDelayAfterFYI = 1000 * 10,
	messageColor = 19,
	messages = {
		"Insulting another player is not allowed. In the next offense you will be jailed.",
		"Insulting another player is not allowed. You have been jailed.",
		"Insulting another player is not allowed. This is your last warning.",
		"You have been banished for offending another player."
	}
}

function onSay(cid, words, param)
	local warning = getPlayerStorageValue(cid, data.storage)
	warning = ((warning >= 0) and warning) or 0

	if warning == 1 then
		addEvent(Unjail, data.jailTime, {cid = cid, position = getCreaturePosition(cid)})
		doTeleportThing(cid, data.jailPosition)
	elseif warning = 3 then
		setPlayerStorageValue(cid, data.storage, -1)
		addEvent(BanPlayer, BanDelayAfterFYI, cid)
		return doPlayerPopupFYI(cid, data.messages[#data.messages])
	end
	doPlayerSendTextMessage(cid, data.messageColor, data.messages[warning + 1])
	return doPlayerSendTextMessage(cid, data.messageColor, data.messages[warning + 1])
end

function Unjail(p)
	doTeleportThing(p.cid, p.position)
	return doPlayerSendTextMessage(p.cid, data.messageColor, "You are free to go. If you insult again you'll have only a final warning and then a banishment.")
end

function BanPlayer(cid)
	doAddBanishment(getAccountIdByName(getCreatureName(cid)), BanTime, 4, 2, "Automatic Banishment for Offensive Statement")
	return doRemoveCreature(cid)
end

Probably swears can be wrote like this:
PHP:
<talkaction words="bitch;fag;bastard" event="script" value="anti-insult.lua"/>

I don't think it works the same now:O Also I saw some bugss:)
 
Last edited:
That's look really goooooodd thanks :d i gona use it :D! and i will give you reputation+++ :D
 
@KuGaSh1rA

-- Great job man... i like this... hehe... i have a question, how to me block ROOKers players don't be teleported to mais land??? Because if player ROOK use, this him be teleported to main on prison.... and my mainland will be invade by noobs no vocation.... help me plx???
 
-- I have a problem with this, when a player stay on prison, him don't kiked from prison.... the caracter stay online but dont are kiked out of prison....

-- Someone can help me to solve???
 
Damageonoffense, instead having it as an constant value, like 500. Makes it worse for sorcerers but not so bad for knights. Wouldn't it be better if it made you loose 50% hp?

Also if a long sentence, "hello i fucking hate this system" <--- since it contains fuck, will the talkaction notice it and launch the punishment?
 
working for TFS 0.2.X?
 
Also if a long sentence, "hello i fucking hate this system" <--- since it contains fuck, will the talkaction notice it and launch the punishment?

Cant test it right now but Im wondering the same ^

Would be great if so, but well done anyways :thumbup:

Damageonoffense, instead having it as an constant value, like 500. Makes it worse for sorcerers but not so bad for knights. Wouldn't it be better if it made you loose 50% hp?

Good idea, but to make it even more mean you could make it removing 50% of both hp and mana, by adding this function to your server:

Lua:
function doPlayerRemoveAllCurrentPercent(cid, percent)
	local mana = getCreatureMana(cid)
	local health = getCreatureHealth(cid)
		doPlayerRemoveMana(cid, (mana / 100) * percent)
		doPlayerRemoveHealth(cid, (health / 100) * percent)
	return TRUE
end

And then set the local to it:

Lua:
local DamageOnOffense = doPlayerRemoveAllCurrentPercent(cid, 50)

Or if you'd rather it to always remove players's max stats regardless the current, add this one:

Lua:
function doPlayerRemoveAllMaxPercent(cid, percent)
	local mana = getCreatureMaxMana(cid)
	local health = getCreatureMaxHealth(cid)
		doPlayerRemoveMana(cid, (mana / 100) * percent)
		doPlayerRemoveHealth(cid, (health / 100) * percent)
	return TRUE
end

And do the same as before. Or similar stuff like make it by vocation etc :)

Cheers.
 
Last edited:
Back
Top