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

Lua NPC function dont work.

tompan

Member
Joined
Dec 13, 2008
Messages
646
Reaction score
24
Location
Sweden
Title says it..

Code:
			if getPlayerBlessing(cid, 1) == FALSE then

it always return to else...
whats the correct function to use in the npc lua? :S


here is the whole npc
Thank you!!
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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(npcHandler.focus ~= cid) then
		return false
	end

	if msgcontains(msg, 'heal') then
		if hasCondition(cid, CONDITION_FIRE) == TRUE then
			npcHandler:say('You are burning. I will help you.')
			doRemoveCondition(cid, CONDITION_FIRE)
			doSendMagicEffect(getCreaturePosition(cid), 14)
		elseif hasCondition(cid, CONDITION_POISON) == TRUE then
			npcHandler:say('You are poisoned. I will help you.')
			doRemoveCondition(cid, CONDITION_POISON)
			doSendMagicEffect(getCreaturePosition(cid), 13)
		elseif getCreatureHealth(cid) < 65 then
			npcHandler:say('You are looking really bad. Let me heal your wounds.')
			doCreatureAddHealth(cid, 65 - getCreatureHealth(cid))
			doSendMagicEffect(getCreaturePosition(cid), 12)
		else
			npcHandler:say('You aren\'t looking that bad. Sorry, I can\'t help you. But if you are looking for additional protection you should go on thepilgrimage of ashes.')
			end
	    elseif msgcontains(msg, 'time') then
	    local time = getTibiaTime()
	    npcHandler:say('Now, it is '.. time.hours .. string.char(58) .. time.minutes ..'. Ask Gorn for a watch, if you need one.')
		
		elseif msgcontains(msg, 'spiritual') or msgcontains(msg, 'shielding') or msgcontains(msg, 'spiritual shielding') then
		npcHandler:say('Here in the whiteflower temple you may receive the blessing of spiritual shielding. But we must ask of you to sacrifice 10.000 gold. Are you still interested?')
		talk_state = 1
		
		elseif msgcontains(msg, 'yes') and talk_state == 1 then
		if isPremium(cid) == TRUE then
			if getPlayerBlessing(cid, 1) == FALSE then
					if doPlayerRemoveMoney(cid,10000) == 1 then
						doSendMagicEffect(getCreaturePosition(cid), 13)
							npcHandler:say('So receive the shielding of your spirit, pilgrim.')
						doPlayerAddBlessing(cid,1)
					else
					npcHandler:say('Oh. You do not have enough money.')
					talk_state = 0
					end
			else
			npcHandler:say('you have this bless')
			end
		else
		npcHandler:say('I\'m sorry, but you need a premium account in order to buy blessing.')
		talk_state = 0
	end
	return TRUE
	end
	end


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