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

Lua Npc Error.

Lucenzo

The Way You Move :)
Joined
Jan 29, 2011
Messages
363
Reaction score
14
Location
UK
Heya

LUA:
[18:5:25.643] [Error - NpcScript Interface]
[18:5:25.643] data/npc/scripts/Haroun.lua:onCreatureSay
[18:5:25.643] Description:
[18:5:25.643] data/npc/scripts/Haroun.lua:120: attempt to compare number with nil
[18:5:25.643] stack traceback:
[18:5:25.643]   data/npc/scripts/Haroun.lua:120: in function 'callback'
[18:5:25.643]   data/npc/lib/npcsystem/npchandler.lua:385: in function 'onCreatureSay'
[18:5:25.643]   data/npc/scripts/Haroun.lua:7: in function <data/npc/scripts/Haroun.lua:7>


Any ideas? x x

Thanks in Advance. x x
 
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local t, q = {}, {
	['sweat'] = {2475, 4, 5885, 'four warrior helmets', 'a flask of warrior\'s sweat', 'Al Kaus Jadi Dalw!'},
	['sulphur'] = {2392, 3, 5904, 'three fireswords', 'one ounce of magic sulphur', 'Al Adhra Zubana Akras!'},
	['wing'] = {2195, 1, 5891, 'one pair of boots of haste', 'one enchanted chicken wing', 'Al Tauaman Saratan Asad!'},
	['spirit'] = {2498, 2, 5884, 'two royal helmets', 'one container of fighting spirit', 'Al Adhra Zubana Akras!'}
}

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 g(cid)
	t[cid] = nil
	return true
end

function c(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	elseif msgcontains(msg, 'offer') then
		selfSay('You can here change some items for {warrior\'s sweat}, {magic sulphur}, {enchanted chicken wing} and {spirit container}.', cid)
	elseif t[cid] and msgcontains(msg, 'yes') then
		local v = q[t[cid]]
		if doPlayerRemoveItem(cid, v[1], v[2]) then
			npcHandler:say(v[6], cid)
			doPlayerAddItem(cid, v[3], 1)
		else
			npcHandler:say('I hate to disappoint you, but it seems you do not have the required amount.', cid)
		end
	else
		for k, v in pairs(q) do
			if msgcontains(msg, k) then
				npcHandler:say('I need ' .. v[4] .. ' to extract ' .. v[5] .. '. Would you like me to perform the extraction?', cid)
				t[cid] = k
				break
			end
		end
	end
	return true
end

npcHandler:setCallback(CALLBACK_GREET, g)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, c)
npcHandler:addModule(FocusModule:new())
removed silks because they're not exchanged at haroun/yaman
 
Back
Top