• 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 Scripts problem.

ruth

Veteran OT User
Joined
Aug 3, 2009
Messages
656
Solutions
2
Reaction score
374
1.Lever script doesn't move player when he stands on wall which must appear.
Console error says: creature not found.

Code:
function onUse(cid, item, frompos, item2, topos)
gatepos = {x=32780, y=32231, z=8, stackpos=1}
getgate = getThingfromPos(gatepos)

if item.uid == 4575 and item.itemid == 1945 and getgate.itemid == 387 then
doRemoveItem(getgate.uid,1)
doSendMagicEffect(gatepos,2)
doTransformItem(item.uid,item.itemid+1)



elseif item.uid == 4575 and item.itemid == 1946 and getgate.itemid == 0 then
   doCreateItem(387,1,gatepos)
   doTransformItem(item.uid,item.itemid-1)
        creature = {x=32780, y=32231, z=8, stackpos=253}
        getCreature = getThingfromPos(creature)
        creaturemove = {x=32780, y=32232, z=8, stackpos=253}
        getmove = getThingfromPos(creaturemove)
        doMoveCreature(getCreature.uid,getmove)
end
  return 1
end

2.Constructionkits.lua
Console error:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/constructionkits.lua:onUse

data/actions/scripts/constructionkits.lua:12: attempt to call global 'getTileInf
o' (a nil value)
stack traceback:
        data/actions/scripts/constructionkits.lua:12: in function <data/actions/
scripts/constructionkits.lua:9>

Script:
Code:
local CONSTRUCTIONS = {
	[3901] = 1650, [3902] = 1658, [3903] = 1666, [3904] = 1670, [3905] = 3813, [3906] = 3817, [3907] = 2093, [3908] = 2603, [3909] = 1614, [3910] = 1615,
	[3911] = 1616, [3912] = 1619, [3913] = 3805, [3914] = 3807, [3915] = 1740, [3916] = 1774, [3917] = 2084, [3918] = 2095, [3919] = 3809, [3920] = 3832,
	[3921] = 1714, [3922] = 2107, [3923] = 2104, [3924] = 7670, [3925] = 1740, [3926] = 2080, [3927] = 2098, [3928] = 1676, [3929] = 2101, [3930] = 1739,
	[3931] = 2105, [3932] = 1724, [3933] = 1728, [3934] = 1732, [3935] = 1775, [3936] = 3812, [3937] = 2064, [3938] = 6371, [5086] = 1738, [5087] = 1741, [5088] = 1770,
	[6114] = 2106, [6115] = 2034, [6372] = 3811, [6373] = 1736, [7503] = 1750, [7700] = 5928, [7960] = 3821, [7961] = 3811, [7962] = 2582, [8692] = 8688, [8693] = 7486
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(fromPosition.x == CONTAINER_POSITION) then
		doPlayerSendCancel(cid, "Put the construction kit on the floor first.")
	elseif getTileInfo(getThingPos(cid)).house == false then
		doPlayerSendCancel(cid,"You may construct this only inside a house.")
	elseif(CONSTRUCTIONS[item.itemid] ~= nil) then
		doTransformItem(item.uid, CONSTRUCTIONS[item.itemid])
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
	else
		return false
	end
 
	return true
end

3.Still i need something like King tibianus npc function. This means that he react only on 'hail king' msg greet.

Please help it is possible and sorry for my english ;)
 
1.
Lua:
local pos = {x=32780, y=32231, z=8}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		doRemoveItem(getTileItemById(pos, 387).uid)
		doSendMagicEffect(pos, CONST_ME_POFF)
	else
		doRelocate(pos, {x=32780, y=32232, z=8})
		doCreateItem(387, 1, pos)
	end
	return TRUE, doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
2.
Lua:
local CONSTRUCTIONS = {
	[3901] = 1650, [3902] = 1658, [3903] = 1666, [3904] = 1670, [3905] = 3813, [3906] = 3817, [3907] = 2093, [3908] = 2603, [3909] = 1614, [3910] = 1615,
	[3911] = 1616, [3912] = 1619, [3913] = 3805, [3914] = 3807, [3915] = 1740, [3916] = 1774, [3917] = 2084, [3918] = 2095, [3919] = 3809, [3920] = 3832,
	[3921] = 1714, [3922] = 2107, [3923] = 2104, [3924] = 7670, [3925] = 1740, [3926] = 2080, [3927] = 2098, [3928] = 1676, [3929] = 2101, [3930] = 1739,
	[3931] = 2105, [3932] = 1724, [3933] = 1728, [3934] = 1732, [3935] = 1775, [3936] = 3812, [3937] = 2064, [3938] = 6371, [5086] = 1738, [5087] = 1741, [5088] = 1770,
	[6114] = 2106, [6115] = 2034, [6372] = 3811, [6373] = 1736, [7503] = 1750, [7700] = 5928, [7960] = 3821, [7961] = 3811, [7962] = 2582, [8692] = 8688, [8693] = 7486
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if fromPosition.x == 65535 then
		doPlayerSendCancel(cid, "Put the construction kit on the floor first.")
	elseif getTileHouseInfo(fromPosition) == FALSE then
		doPlayerSendCancel(cid,"You may construct this only inside a house.")
	elseif CONSTRUCTIONS[item.itemid] then
		doTransformItem(item.uid, CONSTRUCTIONS[item.itemid])
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
	else
		return FALSE
	end

	return TRUE
end
3.
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = 0

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 (msgcontains(msg, "hail") or msgcontains(msg, "hello") or msgcontains(msg, "salutations")) and msgcontains(msg, "king") and npcHandler.focus ~= cid then
		npcHandler:say("I greet thee, my loyal subject "..getCreatureName(cid)..".", cid)
		npcHandler:addFocus(cid)
		Topic = 0
	elseif npcHandler.focus ~= cid then
		return false
	elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
		npcHandler:say("Good bye, "..getCreatureName(cid).."!", cid, TRUE)
		Topic = 0
		npcHandler:releaseFocus(cid)
	elseif msgcontains(msg, "job") then
		npcHandler:say("I am your sovereign, King Tibianus III, and it's my duty to uphold justice and provide guidance for my subjects.", cid)
		Topic = 0
	elseif msgcontains(msg, "justice") then
		npcHandler:say("I try my best to be just and fair to our citizens. The army and the TBI are a great help in fulfilling this duty.", cid)
		Topic = 0
	elseif msgcontains(msg, "name") then
		npcHandler:say("Preposterous! You must know the name of your own King!", cid)
		Topic = 0
	elseif msgcontains(msg, "news") then
		npcHandler:say("The latest news is usually brought to our magnificent town by brave adventurers. They recount tales of their journeys at Frodo's tavern.", cid)
		Topic = 0
	elseif msgcontains(msg, "tibia") or msgcontains(msg, "land") then
		npcHandler:say("Soon the whole land will be ruled by me once again!", cid)
		Topic = 0
	elseif msgcontains(msg, "how") and msgcontains(msg, "are") and msgcontains(msg, "you") then
		npcHandler:say("Thank you, I'm fine.", cid)
		Topic = 0
	elseif msgcontains(msg, "castle") then
		npcHandler:say("Rain Castle is my home.", cid)
		Topic = 0
	elseif msgcontains(msg, "sell") then
		npcHandler:say("Sell? Sell what? My kingdom isn't for sale!", cid)
		Topic = 0
	elseif msgcontains(msg, "god") then
		npcHandler:say("Honour the Gods and above all pay your taxes.", cid)
		Topic = 0
	elseif msgcontains(msg, "zathroth") then
		npcHandler:say("Please ask a priest about the gods.", cid)
		Topic = 0
	elseif msgcontains(msg, "citizen") then
		npcHandler:say("The citizens of Tibia are my subjects. Ask the old monk Quentin if you want to learn more about them.", cid)
		Topic = 0
	elseif msgcontains(msg, "sam") then
		npcHandler:say("He is a skilled blacksmith and a loyal subject.", cid)
		Topic = 0
	elseif msgcontains(msg, "frodo") then
		npcHandler:say("He is the owner of Frodo's Hut and a faithful tax-payer.", cid)
		Topic = 0
	elseif msgcontains(msg, "gorn") then
		npcHandler:say("He was once one of Tibia's greatest fighters. Now he sells equipment.", cid)
		Topic = 0
	elseif msgcontains(msg, "benjamin") then
		npcHandler:say("He was once my greatest general. Now he is very old and senile so we assigned him to work for the Royal Tibia Mail.", cid)
		Topic = 0
	elseif msgcontains(msg, "harkath") or msgcontains(msg, "bloodblade") or msgcontains(msg, "general") then
		npcHandler:say("Harkath Bloodblade is the general of our glorious army.", cid)
		Topic = 0
	elseif msgcontains(msg, "noodles") then
		npcHandler:say("The royal poodle Noodles is my greatest treasure!", cid)
		Topic = 0
	elseif msgcontains(msg, "ferumbras") then
		npcHandler:say("He is a follower of the evil God Zathroth and responsible for many attacks on us. Kill him on sight!", cid)
		Topic = 0
	elseif msgcontains(msg, "bozo") then
		npcHandler:say("He is my royal jester and cheers me up now and then.", cid)
		Topic = 0
	elseif msgcontains(msg, "treasure") then
		npcHandler:say("The royal poodle Noodles is my greatest treasure!", cid)
		Topic = 0
	elseif msgcontains(msg, "monster") then
		npcHandler:say("Go and hunt them! For king and country!", cid)
		Topic = 0
	elseif msgcontains(msg, "help") then
		npcHandler:say("Visit Quentin the monk for help.", cid)
		Topic = 0
	elseif msgcontains(msg, "quest") or msgcontains(msg, "mission") then
		npcHandler:say("I will call for heroes as soon as the need arises again and then reward them appropriately.", cid)
		Topic = 0
	elseif msgcontains(msg, "gold") or msgcontains(msg, "money") or (msgcontains(msg, "tax") and not msgcontains(msg, "collector")) then
		npcHandler:say("To pay your taxes, visit the royal tax collector.", cid)
		Topic = 0
	elseif msgcontains(msg, "sewer") then
		npcHandler:say("What a disgusting topic!", cid)
		Topic = 0
	elseif msgcontains(msg, "dungeon") then
		npcHandler:say("Dungeons are no places for kings.", cid)
		Topic = 0
	elseif msgcontains(msg, "equipment") then
		npcHandler:say("Feel free to buy it in our town's fine shops.", cid)
		Topic = 0
	elseif msgcontains(msg, "food") then
		npcHandler:say("Ask the royal cook for some food.", cid)
		Topic = 0
	elseif msgcontains(msg, "time") or msgcontains(msg, "hero") or msgcontains(msg, "adventurer") then
		npcHandler:say("It's a time for heroes!", cid)
		Topic = 0
	elseif msgcontains(msg, "tax") and msgcontains(msg, "collector") then
		npcHandler:say("That tax collector is the bane of my life. He is so lazy. I bet you haven't payed any taxes at all.", cid)
		Topic = 0
	elseif msgcontains(msg, "king") then
		npcHandler:say("I am the king, so watch what you say!", cid)
		Topic = 0
	elseif msgcontains(msg, "army") then
		npcHandler:say("Ask the soldiers about that.", cid)
		Topic = 0
	elseif msgcontains(msg, "enemy") or msgcontains(msg, "enemies") then
		npcHandler:say("Our enemies are numerous. The evil minotaurs, Ferumbras, and the renegade city of Carlin to the north are just some of them.", cid)
		Topic = 0
	elseif (msgcontains(msg, "city") and msgcontains(msg, "north")) or msgcontains(msg, "carlin") then
		npcHandler:say("They dare to reject my reign over the whole continent!", cid)
		Topic = 0
	elseif msgcontains(msg, "thais") or msgcontains(msg, "city") then
		npcHandler:say("Our beloved city has some fine shops, guildhouses and a modern sewerage system.", cid)
		Topic = 0
	elseif msgcontains(msg, "shop") then
		npcHandler:say("Visit the shops of our merchants and craftsmen.", cid)
		Topic = 0
	elseif msgcontains(msg, "merchant") or msgcontains(msg, "craftsmen") then
		npcHandler:say("Ask around about them.", cid)
		Topic = 0
	elseif msgcontains(msg, "guild") then
		npcHandler:say("The four major guilds are the knights, the paladins, the druids, and the sorcerers.", cid)
		Topic = 0
	elseif msgcontains(msg, "minotaur") then
		npcHandler:say("Vile monsters, but I must admit they are strong and sometimes even cunning ... in their own bestial way.", cid)
		Topic = 0
	elseif msgcontains(msg, "paladin") or msgcontains(msg, "elane") then
		npcHandler:say("The paladins are great protectors for Thais.", cid)
		Topic = 0
	elseif msgcontains(msg, "knight") or msgcontains(msg, "gregor") then
		npcHandler:say("The brave knights are necessary for human survival in Thais.", cid)
		Topic = 0
	elseif msgcontains(msg, "sorcerer") or msgcontains(msg, "muriel") then
		npcHandler:say("The magic of the sorcerers is a powerful tool to smite our enemies.", cid)
		Topic = 0
	elseif msgcontains(msg, "druid") or msgcontains(msg, "marvik") then
		npcHandler:say("We need the druidic healing powers to fight evil.", cid)
		Topic = 0
	elseif msgcontains(msg, "good") then
		npcHandler:say("The forces of good are hard pressed in these dark times.", cid)
		Topic = 0
	elseif msgcontains(msg, "evil") then
		npcHandler:say("We need all strength we can muster to smite evil!", cid)
		Topic = 0
	elseif msgcontains(msg, "order") then
		npcHandler:say("We need order to survive!", cid)
		Topic = 0
	elseif msgcontains(msg, "chaos") then
		npcHandler:say("Chaos arises from selfishness.", cid)
		Topic = 0
	elseif msgcontains(msg, "excalibug") then
		npcHandler:say("It's the sword of the Kings. If you return this weapon to me I will reward you beyond your wildest dreams.", cid)
		Topic = 0
	elseif msgcontains(msg, "reward") then
		npcHandler:say("Well, if you want a reward, go on a quest to bring me Excalibug!", cid)
		Topic = 0
	elseif msgcontains(msg, "chester") then
		npcHandler:say("A very competent person. A little nervous but very competent.", cid)
		Topic = 0
	elseif msgcontains(msg, "tbi") then
		npcHandler:say("This organisation is an essential tool for holding our enemies in check. Its headquarter is located in the bastion in the northwall.", cid)
		Topic = 0
	elseif msgcontains(msg, "promot") then
		npcHandler:say("Do you want to be promoted in your vocation for 20000 gold?", cid)
		Topic = 1
	elseif msgcontains(msg, "yes") and Topic == 1 then
		if getPlayerStorageValue(cid, 30018) > 0 then
			npcHandler:say('You are already promoted.', cid)
		elseif getPlayerLevel(cid) < 20 then
			npcHandler:say('You need to be at least level 20 in order to be promoted.', cid)
		elseif getPlayerMoney(cid) < 20000 then
			npcHandler:say('You do not have enough money.', cid)
		elseif isPremium(cid) == TRUE then
			npcHandler:say("Congratulations! You are now promoted. Visit the sage Eremo for new spells.", cid)
			doPlayerSetVocation(cid, getPromotedVocation(getPlayerVocation(cid)))
			doPlayerRemoveMoney(cid, 20000)
		else
			npcHandler:say("You need a premium account in order to promote.", cid)
		end
		Topic = 0
	elseif Topic == 1 then
		npcHandler:say("Ok, whatever.", cid)
		Topic = 0
	elseif msgcontains(msg, "eremo") then
		npcHandler:say("It is said that he lives on a small island near Edron. Maybe the people there know more about him.", cid)
		Topic = 0
	end
	return TRUE
end

npcHandler:setMessage(MESSAGE_WALKAWAY, "How rude!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
 
Last edited:
1. Working great!
2. Working good but i can open package on eq :(
3. He doesn't react on any word. Console error:

Code:
Lua Script Error: [Npc interface]
data/npc/scripts/tibianus.lua:onCreatureSay

data/npc/scripts/tibianus.lua:17: attempt to call method 'isFocused' (a nil valu
e)
stack traceback:
        data/npc/scripts/tibianus.lua:17: in function 'callback'
        data/npc/scripts/lib/npcsystem/npchandler.lua:299: in function 'onCreatu
reSay'
        data/npc/scripts/tibianus.lua:9: in function <data/npc/scripts/tibianus.
lua:9>
 
Last edited:
You have already reputation from me all the rest #1 and #2 working perfect, but i have the lastest problem with #3 king tibianus:
When i say 'hail' he still dont react. Console error

Code:
Lua Script Error: [Npc interface]
data/npc/scripts/tibianus.lua:onCreatureSay

data/npc/scripts/tibianus.lua:17: attempt to call method 'isFocused' (a nil valu
e)
stack traceback:
        data/npc/scripts/tibianus.lua:17: in function 'callback'
        data/npc/scripts/lib/npcsystem/npchandler.lua:299: in function 'onCreatu
reSay'
        data/npc/scripts/tibianus.lua:9: in function <data/npc/scripts/tibianus.
lua:9>
 
Back
Top