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

Action Script: Demon Oak Quest

when I give him the axe and pay the money, the NPC only takes the axe and not money, and the hallowed axe does not appear

and only said that the NPC:
Oldrak: The Hallowed Axe is too heavy for you. Make sure that you have enough capacity.
 
Code:
function isPremium(cid)
	return (isPlayer(cid) == TRUE and (getPlayerPremiumDays(cid) > 0 or getConfigInfo('freePremium') == "yes")) and TRUE or FALSE
end

Add to global.lua or functions.lua
 
and this why?

Code:
when I give him the axe and pay the money, the NPC only takes the axe and not money, and the hallowed axe does not appear

and only said that the NPC:
Oldrak: The Hallowed Axe is too heavy for you. Make sure that you have enough capacity.


but the hallowed axe still do not see ;/
 
Code:
-- WAS NOT Made by Coltain13 // Coltain, I only made it work for TFS --


local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end
	item = 8293 --Hallowed Axe
	
	if msgcontains(msg, 'hallowed axe') then
		if isPremium(cid) == TRUE then
			selfSay('Do you want to buy a Hallowed Axe from me?')
			talk_state = 1
		else
			selfSay('You need premium to buy this axe from me.')
			talk_state = 0
		end
	elseif msgcontains(msg, 'yes') and talk_state == 1 then
		talk_state = 0
		if doPlayerTakeItem(cid, 2386, 1) == 1 then
			if doPlayerRemoveMoney(cid, 3500000) == TRUE then
				selfSay('Here you are. You can now defeat the demon oak with this axe.')
				doPlayerAddItem(cid, item, 1)		
			else
				selfSay('You do not have enough money.')
			end
		else
			selfSay('You do not have an axe.')
		end
	elseif msgcontains(msg, 'demon oak') then
		if getPlayerStorageValue(cid, 21545) == 1 then
			selfSay('Did you defeat the demon oak?')
			talk_state = 2
		else
			selfSay('Go defeat the demon oak.')
			talk_state = 0
		end
	elseif msgcontains(msg, 'yes') and talk_state == 2 then
		talk_state = 0
		if getPlayerStorageValue(cid, 21545) == 1 then
			selfSay('Good job!')
			setPlayerStorageValue(cid, 21545, 2)			
		end
------------------------------------------------ confirm no ------------------------------------------------
	elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 1) then
		selfSay('Ok thanks.')
		talk_state = 0
	end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end

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

Edited a bit... NPCs in tibia arent that smart (except trading ones) to check the cap :p
 
in the serv the hallowed axe is 4355, i change this in the script, but when i give him the axe to the NPC only takes the axe and the hallowed axe still without appear, and later th npc said:

Oldrak: You do not have an axe.


Excuse me for much bother to you and for my bad english :(


P.D. if u want give me u msn
 
Uhm... try changing this:
Code:
if doPlayerTakeItem(cid, 2386, 1) == 1 then
			if doPlayerRemoveMoney(cid, 3500000) == TRUE then
				selfSay('Here you are. You can now defeat the demon oak with this axe.')
				doPlayerAddItem(cid, item, 1)		
			else
				selfSay('You do not have enough money.')
			end
		else
			selfSay('You do not have an axe.')
		end

to:
Code:
if doPlayerTakeItem(cid, 2386, 1) == 1 and doPlayerRemoveMoney(cid, 3500000) == TRUE then
	selfSay('Here you are. You can now defeat the demon oak with this axe.')
		doPlayerAddItem(cid, item, 1)			
else
	selfSay('You need an axe and 3500000 gold coins to buy this item.')
end

idk if it helps... :O

... btw, any errors in console?
 
Can anyone please check the quest script?
I have some problems with my server(can't compile it), therefore I need someone to test the script on a server that supports otb v.3.

EDIT: Here is the bugfree(I'm 90% sure) npc:
Code:
-- WAS NOT Made by Coltain13 // Coltain, I only made it work for TFS --


local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end

		player_gold = getPlayerItemCount(cid,2148)
		player_plat = getPlayerItemCount(cid,2152)*100
		player_crys = getPlayerItemCount(cid,2160)*10000
		player_money = player_gold + player_plat + player_crys
		playerCap = getPlayerFreeCap(cid)
		item = 8293 --Hallowed Axe
		itemweight = getItemWeight(item, 1)
		
		if msgcontains(msg, 'hallowed axe') then
			if isPremium(cid) == TRUE then
				if getPlayerItemCount(cid,2386) >= 1 and player_money >= 3500000 then
					selfSay('Do you want to buy a Hallowed Axe from me?')
					talk_state = 1
				else
					selfSay('You have to bring me an axe and 3500000 gp first.')
					talk_state = 0
				end
			else
				selfSay('You need premium to buy this axe from me.')
				talk_state = 0
			end
		elseif msgcontains(msg, 'yes') and talk_state == 1 then
			talk_state = 0
			if getPlayerItemCount(cid,2386) >= 1 and player_money >= 3500000 then
				if playerCap >= itemweight then
					if doPlayerTakeItem(cid,2386,1) == 1 and pay(cid,3500000) then
						selfSay('Here you are. You can now defeat the demon oak with this axe.')
						doPlayerAddItem(cid,item,1)
						talk_state = 0
					else
						talk_state = 0
					end
				else
					selfSay('The Hallowed Axe is too heavy for you. Make sure that you have enough capacity.')
					talk_state = 0
				end
			else
				selfSay('Please bring with you an axe and enough with money.')
				talk_state = 0
			end
		elseif msgcontains(msg, 'demon oak') then
			if getPlayerItemCount(cid,2386) >= 1 player_money >= 3500000 then
				selfSay('Did you defeat the demon oak?')
				talk_state = 2
			else
				selfSay('Go defeat the demon oak.')
				talk_state = 0
			end
		elseif msgcontains(msg, 'yes') and talk_state == 2 then
			talk_state = 0
			if getPlayerStorageValue(cid,21545) == 1 then
				selfSay('Good job!')
				setPlayerStorageValue(cid,21545,2)
			end
------------------------------------------------ confirm no ------------------------------------------------
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 1) then
			selfSay('Ok thanks.')
			talk_state = 0
		end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end

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

I made it check the capacity before it takes the money and the axe. So ppl with low capacity wont lose anything.
 
Last edited:
Can anyone please check the quest script?
I have some problems with my server(can't compile it), therefore I need someone to test the script on a server that supports otb v.3.

EDIT: Here is the bugfree(I'm 90% sure) npc:
Code:
-- WAS NOT Made by Coltain13 // Coltain, I only made it work for TFS --


local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end

		player_gold = getPlayerItemCount(cid,2148)
		player_plat = getPlayerItemCount(cid,2152)*100
		player_crys = getPlayerItemCount(cid,2160)*10000
		player_money = player_gold + player_plat + player_crys
		playerCap = getPlayerFreeCap(cid)
		item = 8293 --Hallowed Axe
		itemweight = getItemWeight(item, 1)
		
		if msgcontains(msg, 'hallowed axe') then
			if isPlayer(cid) then
				if getPlayerItemCount(cid,2386) >= 1 player_money >= 3500000 then
					selfSay('Do you want to buy a Hallowed Axe from me?')
					talk_state = 1
				else
					selfSay('You have to bring me an axe and 3500000 gp first.')
					talk_state = 0
				end
			else
				selfSay('You need premium to buy this axe from me.')
				talk_state = 0
			end
		elseif msgcontains(msg, 'yes') and talk_state == 1 then
			talk_state = 0
			if getPlayerItemCount(cid,2386) >= 1 player_money >= 3500000 then
				if playerCap >= itemweight then
					if doPlayerTakeItem(cid,2386,1) == 1 and pay(cid,3500000) then
						selfSay('Here you are. You can now defeat the demon oak with this axe.')
						doPlayerAddItem(cid,item,1)
						talk_state = 0
					else
						talk_state = 0
					end
				else
					selfSay('The Hallowed Axe is too heavy for you. Make sure that you have enough capacity.')
					talk_state = 0
				end
			else
				selfSay('Please bring with you an axe and enough with money.')
				talk_state = 0
			end
		elseif msgcontains(msg, 'demon oak') then
			if getPlayerItemCount(cid,2386) >= 1 player_money >= 3500000 then
				selfSay('Did you defeat the demon oak?')
				talk_state = 2
			else
				selfSay('Go defeat the demon oak.')
				talk_state = 0
			end
		elseif msgcontains(msg, 'yes') and talk_state == 2 then
			talk_state = 0
			if getPlayerStorageValue(cid,21545) == 1 then
				selfSay('Good job!')
				setPlayerStorageValue(cid,21545,2)
			end
------------------------------------------------ confirm no ------------------------------------------------
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 1) then
			selfSay('Ok thanks.')
			talk_state = 0
		end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end

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

I made it check the capacity before it takes the money and the axe. So ppl with low capacity wont lose anything.

Missing "and"s... isPlayer(cid) check again - of course it is player, because he talks with NPC ._. - change it to isPremium(cid) == TRUE
 
this later of the next?
Code:
if isPremium(cid) == TRUE then

mmm u what serv use for this script?
 
The Forgotten Server.

You can try to remove this line
Code:
if isPremium(cid) == TRUE then
and if you do, remove the lines where the NPC says you need premium starting from else ending at end

e.g:
Code:
else
    selfSay("you need premium")
end

something liek this
 
u can give me the link of serv? :S

i dont know what serv i use of tfs and maybe for this appear the error
 
Try the updated script:
Code:
-- WAS NOT Made by Coltain13 // Coltain, I only made it work for TFS --


local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end

		player_gold = getPlayerItemCount(cid,2148)
		player_plat = getPlayerItemCount(cid,2152)*100
		player_crys = getPlayerItemCount(cid,2160)*10000
		player_money = player_gold + player_plat + player_crys
		playerCap = getPlayerFreeCap(cid)
		item = 8293 --Hallowed Axe
		itemweight = getItemWeight(item, 1)
		
		if msgcontains(msg, 'hallowed axe') then
			if isPremium(cid) == TRUE then
				if getPlayerItemCount(cid,2386) >= 1 and player_money >= 3500000 then
					selfSay('Do you want to buy a Hallowed Axe from me?')
					talk_state = 1
				else
					selfSay('You have to bring me an axe and 3500000 gp first.')
					talk_state = 0
				end
			else
				selfSay('You need premium to buy this axe from me.')
				talk_state = 0
			end
		elseif msgcontains(msg, 'yes') and talk_state == 1 then
			talk_state = 0
			if getPlayerItemCount(cid,2386) >= 1 and player_money >= 3500000 then
				if playerCap >= itemweight then
					if doPlayerTakeItem(cid,2386,1) == 1 and pay(cid,3500000) then
						selfSay('Here you are. You can now defeat the demon oak with this axe.')
						doPlayerAddItem(cid,item,1)
						talk_state = 0
					else
						talk_state = 0
					end
				else
					selfSay('The Hallowed Axe is too heavy for you. Make sure that you have enough capacity.')
					talk_state = 0
				end
			else
				selfSay('Please bring with you an axe and enough with money.')
				talk_state = 0
			end
		elseif msgcontains(msg, 'demon oak') then
			if getPlayerItemCount(cid,2386) >= 1 and player_money >= 3500000 then
				selfSay('Did you defeat the demon oak?')
				talk_state = 2
			else
				selfSay('Go defeat the demon oak.')
				talk_state = 0
			end
		elseif msgcontains(msg, 'yes') and talk_state == 2 then
			talk_state = 0
			if getPlayerStorageValue(cid,21545) == 1 then
				selfSay('Good job!')
				setPlayerStorageValue(cid,21545,2)
			end
------------------------------------------------ confirm no ------------------------------------------------
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 1) then
			selfSay('Ok thanks.')
			talk_state = 0
		end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Try the updated script:
Code:
-- WAS NOT Made by Coltain13 // Coltain, I only made it work for TFS --


local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end

		player_gold = getPlayerItemCount(cid,2148)
		player_plat = getPlayerItemCount(cid,2152)*100
		player_crys = getPlayerItemCount(cid,2160)*10000
		player_money = player_gold + player_plat + player_crys
		playerCap = getPlayerFreeCap(cid)
		item = 8293 --Hallowed Axe
		itemweight = getItemWeight(item, 1)
		
		if msgcontains(msg, 'hallowed axe') then
			if isPremium(cid) == TRUE then
				if getPlayerItemCount(cid,2386) >= 1 and player_money >= 3500000 then
					selfSay('Do you want to buy a Hallowed Axe from me?')
					talk_state = 1
				else
					selfSay('You have to bring me an axe and 3500000 gp first.')
					talk_state = 0
				end
			else
				selfSay('You need premium to buy this axe from me.')
				talk_state = 0
			end
		elseif msgcontains(msg, 'yes') and talk_state == 1 then
			talk_state = 0
			if getPlayerItemCount(cid,2386) >= 1 and player_money >= 3500000 then
				if playerCap >= itemweight then
					if doPlayerTakeItem(cid,2386,1) == 1 and pay(cid,3500000) then
						selfSay('Here you are. You can now defeat the demon oak with this axe.')
						doPlayerAddItem(cid,item,1)
						talk_state = 0
					else
						talk_state = 0
					end
				else
					selfSay('The Hallowed Axe is too heavy for you. Make sure that you have enough capacity.')
					talk_state = 0
				end
			else
				selfSay('Please bring with you an axe and enough with money.')
				talk_state = 0
			end
		elseif msgcontains(msg, 'demon oak') then
			if getPlayerItemCount(cid,2386) >= 1 player_money >= 3500000 then
				selfSay('Did you defeat the demon oak?')
				talk_state = 2
			else
				selfSay('Go defeat the demon oak.')
				talk_state = 0
			end
		elseif msgcontains(msg, 'yes') and talk_state == 2 then
			talk_state = 0
			if getPlayerStorageValue(cid,21545) == 1 then
				selfSay('Good job!')
				setPlayerStorageValue(cid,21545,2)
			end
------------------------------------------------ confirm no ------------------------------------------------
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 1) then
			selfSay('Ok thanks.')
			talk_state = 0
		end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end

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

Code:
		elseif msgcontains(msg, 'demon oak') then
			if getPlayerItemCount(cid,2386) >= 1 [COLOR="Red"]and[/COLOR] player_money >= 3500000 then
				selfSay('Did you defeat the demon oak?')
				talk_state = 2

You still didnt fix it xd
 
Back
Top