• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

guard who shot player and take max hp - 1

tim26

Member
Joined
Aug 12, 2008
Messages
618
Reaction score
11
Location
Poland
hello i want npc who shot player when he say bad word something like queen eloise in carlin she shot for max hp -1 and player have only 1 hp i have that script
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local fire = createConditionObject(CONDITION_FIRE)
addDamageCondition(fire, 4, 6000, -20)
addDamageCondition(fire, 4, 6000, -10)

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()
	talk = math.random(1,40)
	if talk == 1 then
		selfSay("LONG LIVE THE QUEEN!")
	end
end

function creatureSayCallback(cid, type, msg)
	if(npcHandler.focus ~= cid) then
		return FALSE
	end
	if msgcontains(msg, 'job') then
		selfSay("My duty is to protect this town from wild monsters.")
	elseif msgcontains(msg, 'king') then
		selfSay("I would protect the king with my own like if necessary!")
	elseif msgcontains(msg, 'ass') or msgcontains(msg, 'craw') or msgcontains(msg, 'fuck') or msgcontains(msg, 'suck') or msgcontains(msg, 'dick') then
		selfSay("Take this!")
		doCreatureSay(cid, "Ouch!", TALKTYPE_ORANGE_1)
		doTargetCombatCondition(0, cid, fire, CONST_ME_NONE)
	elseif msgcontains(msg, 'heal') and getCreatureHealth(cid) < 65 then
		selfSay("You're hurt, let me heal you.")
		heal = 65 - getCreatureHealth(cid)
		doCreatureAddHealth(cid, heal)
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
	elseif msgcontains(msg, 'heal') and getCreatureHealth(cid) >= 65 then
		selfSay("You don't need to be healed.")
	end
		
	end
	return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
hello i want npc who shot player when he say bad word something like queen eloise in carlin she shot for max hp -1 and player have only 1 hp i have that script

Try this one (I just edited the yours):
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local fire = createConditionObject(CONDITION_FIRE)
addDamageCondition(fire, 4, 6000, -20)
addDamageCondition(fire, 4, 6000, -10)

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()
	talk = math.random(1,40)
	if talk == 1 then
		selfSay("LONG LIVE THE QUEEN!")
	end
end

function creatureSayCallback(cid, type, msg)
	if(npcHandler.focus ~= cid) then
		return FALSE
	end
	if msgcontains(msg, 'job') then
		selfSay("My duty is to protect this town from wild monsters.")
	elseif msgcontains(msg, 'king') then
		selfSay("I would protect the king with my own like if necessary!")
	elseif msgcontains(msg, 'ass') or msgcontains(msg, 'craw') or msgcontains(msg, 'fuck') or msgcontains(msg, 'suck') or msgcontains(msg, 'dick') and getCreatureHealth(cid) >= 2 then
		selfSay("Take this!")
		doCreatureSay(cid, "Ouch!", TALKTYPE_ORANGE_1)
		health = getCreatureHealth(cid)
		total = health -1
        doCreatureAddHealth(cid, -total)
        doSendMagicEffect(getCreaturePosition(cid), 6)		
	elseif msgcontains(msg, 'heal') and getCreatureHealth(cid) < 65 then
		selfSay("You're hurt, let me heal you.")
		heal = 65 - getCreatureHealth(cid)
		doCreatureAddHealth(cid, heal)
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
	elseif msgcontains(msg, 'heal') and getCreatureHealth(cid) >= 65 then
		selfSay("You don't need to be healed.")
	end
		
	end
	return TRUE
end

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

NOTE: I didn tested so im not sure if the script will work...
 
Last edited:
whos know why i have error in line 44 expected <eof> near end ;/ when i delete one end npc work but no answer on bad words;/
 
Back
Top