• 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!

Another VERY SIMPLE request.

richux

Tibera.org
Joined
Aug 18, 2008
Messages
3,666
Reaction score
26
Location
---------
Could someone script or post a script for npc that attacks/burns you with fire if you say bad word to him, for example "FUCK"?


Thank you very much!
 
something like
Lua:
function onSay(cid, words, param, channel)

local whatever = {
"fuck"
"noob"
"bitch"
"kurwa"
}
for i = 1, table.maxn(whatever) do
if words == i then
-- code here

thank you, but I need code too, the one I posted above will not work because its totally different from what I want. TFs cityguard kills player if hes skulled and attacks ppl :D I dont want anything like that. Please post a code?
 
Lua:
  function onSay(cid, words, param, channel)

local filter = {
	"fuck"
	"noob"
	"bitch"
	"kurwa"
}
for i = 1, 4 do
	if words == filter[i] then
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA)
		doCreatureAddHealth(cid, -50)
			end
		end
	return TRUE
end
not tested.
 
Why use "table.maxn"?.. and it will give error, because you are not using "," to separate the words.

I think this is better (not tested)

Lua:
function onSay(cid, words, param, channel)

local filter =
{
        "fuck",
        "noob",
        "bitch",
        "kurwa"
}
	if filter[words] then
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA)
		doCreatureAddHealth(cid, -50)
        end
	return TRUE
end
 
Maybe try this and edit to fire condition, found this in my otserv folder, credits to the creator

Lua:
local target = 0
local prevTarget = 0
local maxChaseDistance = 20
local origPos = 0
local lastAttack = 0
local followTimeout = 10

local function isSkulled(cid)
	if(getCreatureSkullType(cid) >= 3 and isPlayerPzLocked(cid) == TRUE) then
		return true
	end

	return false
end

local function goToOrigPos()
	target = 0
	lastAttack  = 0
	selfFollow(0)
	doTeleportThing(getNpcCid(), origPos)
end

local function updateTarget()
	if(isPlayer(target) == FALSE) then
		goToOrigPos()
	elseif(not isSkulled(target)) then
		selfSay("Now, behave in the future.")
		goToOrigPos()
	end

	if(target == 0) then
		local list = getSpectators(getNpcPos(), 9, 9, false)
		for i = 1, table.getn(list) do
			local _target = list[i]
			if(_target ~= 0) then
				if(isPlayer(_target) == TRUE and isSkulled(_target)) then
					if(getTilePzInfo(getCreaturePosition(_target)) == FALSE) then
						if(selfFollow(_target)) then
							target = _target
							if(target ~= prevTarget) then
								selfSay("We do not tolerate people like you here!")
							end

							prevTarget = target
							break
						end
					end
				end
			end
		end
	end
end

function onCreatureAppear(cid)
	if(cid == getNpcCid()) then
		origPos = getNpcPos()
	end
end

function onCreatureDisappear(cid)
	if(cid == target) then
		goToOrigPos()
	end
end

function onCreatureMove(creature, oldPos, newPos)
	--
end

function onThink()
	updateTarget()

	if(target == 0) then
		return
	end

	local playerPos = getCreaturePosition(target)
	local myPos = getNpcPos()

	if(myPos.z ~= playerPos.z) then
		goToOrigPos()
		return
	end

	if(math.abs(myPos.x - origPos.x) > maxChaseDistance or math.abs(myPos.y - origPos.y) > maxChaseDistance) then
		selfSay("I'll catch you next time.")
		goToOrigPos()
		return
	end

	if(lastAttack == 0) then
		lastAttack = os.clock()
	end

	if(os.clock() - lastAttack > followTimeout) then
		selfSay("You got me this time, but just wait.")
		goToOrigPos()
		return
	end

	if((math.abs(playerPos.x - myPos.x) <= 1) and (math.abs(playerPos.y - myPos.y) <= 1)) then
		doTargetCombatHealth(getNpcCid(), target, COMBAT_LIFEDRAIN, -10, -50, CONST_ME_BLOCKHIT)
		lastAttack = os.clock()
	end
end

Sincerely,
Furstwin.
 
Why use "table.maxn"?.. and it will give error, because you are not using "," to separate the words.

I think this is better (not tested)

Lua:
function onSay(cid, words, param, channel)

local filter =
{
        "fuck",
        "noob",
        "bitch",
        "kurwa"
}
	if filter[words] then
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA)
		doCreatureAddHealth(cid, -50)
        end
	return TRUE
end

oh;) i forget them xD :

Lua:
  function onSay(cid, words, param, channel)

local filter = {
        "fuck",
        "noob",
        "bitch",
        "kurwa"
}
for i = 1, 4 do
        if words == filter[i] then
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA)
                doCreatureAddHealth(cid, -50)
                        end
                end
        return TRUE
end
 
Ehh... I thought Im "KOOl" and will be able to figure NPC script too, but I couldn't. Tried some scripts from other npc's :D but they doesnt seem to work. No reaction. Could someone give me npx.xml file for this script :D ?


PS. rep for Zonet and darkhaos. And the one who will post xml script.

Thank you all!
 
PHP:
    <talkaction words="fuck" event="script" value="badwords.lua"/>
    <talkaction words="noob" event="script" value="badwords.lua"/>  
    <talkaction words="bitch" event="script" value="badwords.lua"/>
    <talkaction words="kurwa" event="script" value="badwords.lua"/>

@btw what mean kurwa?
 
PHP:
    <talkaction words="fuck" event="script" value="badwords.lua"/>
    <talkaction words="noob" event="script" value="badwords.lua"/>  
    <talkaction words="bitch" event="script" value="badwords.lua"/>
    <talkaction words="kurwa" event="script" value="badwords.lua"/>

@btw what mean kurwa?

no dude, this is not talkaction. I want a npc script(data/npc/NPC.xml :D

PS. kurwa=bitch
 
well...

PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="NO BAD WORDS!" script="data/npc/scripts/badwords.lua" walkinterval="0" floorchange="0">
	<health now="100" max="100"/>
	<look type="139" head="20" body="39" legs="45" feet="7" addons="0"/>
	<parameters>
		<parameter key="message_greet" value="Hiya |PLAYERNAME|! how may I help you?." />
	</parameters>

</npc>

my NPC version:
for more words, just add more elseifs...

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)            npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                    npcHandler:onThink()                    end

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    
    if msgcontains(msg, 'fuck') then
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA)
        doCreatureAddHealth(cid, -50)
        npcHandler:say('Respect!!!', cid)		
	elseif msgcontains(msg, 'bitch') then
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA)
        doCreatureAddHealth(cid, -50)	
        npcHandler:say('Respect!!!', cid)
    else          
        npcHandler:say('uuuuh? what?', cid)
    end
   return TRUE
end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
well...

PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="NO BAD WORDS!" script="data/npc/scripts/badwords.lua" walkinterval="0" floorchange="0">
	<health now="100" max="100"/>
	<look type="139" head="20" body="39" legs="45" feet="7" addons="0"/>
	<parameters>
		<parameter key="message_greet" value="Hiya |PLAYERNAME|! how may I help you?." />
	</parameters>

</npc>

my NPC version:
for more words, just add more elseifs...

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)            npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                    npcHandler:onThink()                    end

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    
    if msgcontains(msg, 'fuck') then
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA)
        doCreatureAddHealth(cid, -50)
        npcHandler:say('Respect!!!', cid)		
	elseif msgcontains(msg, 'bitch') then
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA)
        doCreatureAddHealth(cid, -50)	
        npcHandler:say('Respect!!!', cid)
    else          
        npcHandler:say('uuuuh? what?', cid)
    end
   return TRUE
end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

you know what.... it works!!! :thumbup:


Just one last thing:
I want so player burns more than one time after saying fuck. This is what I tried:

Lua:
if msgcontains(msg, 'fuck') then
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA)
        doCreatureAddHealth(cid, -50)
	doCreatureAddHealth(cid, -20)
	doCreatureAddHealth(cid, -10)

but npc did 80 hp damage in same time, how can I insert delay between 50, 20 and 10, so it would be like slow burning...?


Edit: Btw it burns me only if I say "fuck", but when I say Fuck, fuck you it doesnt. It reacts only on theese ones "fuck", how can I make so it would work with capital letters and all phrases that includes "fuck"? Is there other simpler way than adding much elseif...?
 
Last edited:
You can possibly use addEvent...

Lua:
function attack(cid, damage)
   doCreatureAddHealth(cid, damage)
   return TRUE
end

And then after 'doCreatureAddHealth(cid, -50)' put

Lua:
addEvent(attack, 5000, cid, -20)
addEvent(attack, 10000, cid, -10)

And to your edit - yes there is a way, just put...

Lua:
msg = string.lower(msg)

before the if functions.

Edit: I dno about the phrases part, it should work.
 
You can possibly use addEvent...

Lua:
function attack(cid, damage)
   doCreatureAddHealth(cid, damage)
   return TRUE
end

And then after 'doCreatureAddHealth(cid, -50)' put

Lua:
addEvent(attack, 5000, cid, -20)
addEvent(attack, 10000, cid, -10)

And to your edit - yes there is a way, just put...

Lua:
msg = string.lower(msg)

before the if functions.

Edit: I dno about the phrases part, it should work.

Thank you! It worked, now it takes the damage more than one time after decent time period, BUT...
1)It only takes away hp, but does not give battle.
2)How can I add so it would send magic effect on ever add event(time the hp is taken away), so it would look like player is burning?
3)All that could simply be done if script would BURN the player. I mean it would do the same thing as stepping in fire. So maybe u could tell me how to modifie script so it would just do the same movement as stepinfield?

Thank ya!
 
Back
Top