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

Help npc fast !!!

arthurluna

Member
Joined
Apr 12, 2008
Messages
180
Reaction score
15
ERRO:


Code:
[0:35:37.804] [Error - NpcScript Interface] 
[0:35:37.804] data/npc/scripts/Rabaz.lua
[0:35:37.804] Description: 
[0:35:37.804] data/npc/lib/npc_we.lua:57: attempt to index local 'message' (a n
[0:35:37.804] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scr




Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

        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

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addBuyableItem({'spellbook'}, 2175, 150, 'spellbook')
shopModule:addBuyableItem({'magic lightwand'}, 2163, 400, 'magic lightwand')
shopModule:addBuyableItem({'wand of vortex'}, 2190, 500, 'wand of vortex')
shopModule:addBuyableItem({'wand of dragonbreath'}, 2191, 1000, 'wand of dragonbreath')
shopModule:addBuyableItem({'wand of decay'}, 2188, 5000, 'wand of decay')
shopModule:addBuyableItem({'wand of draconia'}, 8921, 7500, 'wand of draconia')
shopModule:addBuyableItem({'wand of cosmic energy'}, 2189, 10000, 'wand of cosmic energy')
shopModule:addBuyableItem({'wand of inferno'}, 2187, 15000, 'wand of inferno')
shopModule:addBuyableItem({'wand of starstorm'}, 8920, 18000, 'wand of starstorm')
shopModule:addBuyableItem({'wand of voodoo'}, 8922, 22000, 'wand of voodoo')
shopModule:addBuyableItem({'snakebite rod'}, 2182, 500, 'snakebite rod')
shopModule:addBuyableItem({'moonlight rod'}, 2186, 1000, 'moonlight rod')
shopModule:addBuyableItem({'necrotic rod'}, 2185, 5000,  'necrotic rod')
shopModule:addBuyableItem({'northwind rod'}, 8911, 7500,'northwind rod')
shopModule:addBuyableItem({'terra rod'}, 2181, 10000, 'terra rod')
shopModule:addBuyableItem({'hailstorm rod'}, 2183, 15000, 'hailstorm rod')
shopModule:addBuyableItem({'springsprout rod'}, 8912, 18000, 'springsprout rod')
shopModule:addBuyableItem({'underworld rod'}, 8910, 22000, 'underworld rod')
shopModule:addBuyableItem({'small health'}, 8704, 20, 'small health potion')
shopModule:addBuyableItem({'health potion'}, 7618, 45, 'health potion')
shopModule:addBuyableItem({'mana potion'}, 7620, 50, 1, 'mana potion')
shopModule:addBuyableItem({'strong health'}, 7588, 100, 'strong health potion')
shopModule:addBuyableItem({'strong mana'}, 7589, 80, 'strong mana potion')
shopModule:addBuyableItem({'great health'}, 7591, 190, 'great health potion')
shopModule:addBuyableItem({'great mana'}, 7590, 120, 'great mana potion')
shopModule:addBuyableItem({'great spirit'}, 8472, 190, 'great spirit potion')
shopModule:addBuyableItem({'ultimate health'}, 8473, 310, 'ultimate health potion')
shopModule:addSellableItem({'normal potion flask', 'normal flask'}, 7636, 5, 'empty small potion flask')
shopModule:addSellableItem({'strong potion flask', 'strong flask'}, 7634, 10, 'empty strong potion flask')
shopModule:addSellableItem({'great potion flask', 'great flask'}, 7635, 15, 'empty great potion flask')
shopModule:addBuyableItem({'instense healing'}, 2265, 95, 'intense healing rune')
shopModule:addBuyableItem({'ultimate healing'}, 2273, 175, 'ultimate healing rune')
shopModule:addBuyableItem({'fire bomb'}, 2305, 235,  'fire bomb')
shopModule:addBuyableItem({'energy bomb'}, 2262, 325, 'energy bomb')
shopModule:addBuyableItem({'destroy field'}, 2261, 45,'destroy field rune')
shopModule:addBuyableItem({'light magic missile'}, 2287, 40, 'light magic missile rune')
shopModule:addBuyableItem({'heavy magic missile'}, 2311, 120,  'heavy magic missile rune')
shopModule:addBuyableItem({'great fireball'}, 2304, 180, 'great fireball rune')
shopModule:addBuyableItem({'explosion'}, 2313, 250, 'explosion rune')
shopModule:addBuyableItem({'sudden death'}, 2268, 325, 'sudden death rune')
shopModule:addBuyableItem({'animate dead'}, 2316, 375, 'animate dead rune')
shopModule:addBuyableItem({'convince creature'}, 2290, 80, 'convince creature rune')
shopModule:addBuyableItem({'chameleon'}, 2291, 210, 'chameleon rune')
shopModule:addBuyableItem({'desintegrate'}, 2310, 80, 'desintegreate rune')
shopModule:addBuyableItem({'fire field'}, 2301, 85, 'fire field rune')
shopModule:addBuyableItem({'energy field'}, 2301, 115, 'energy field rune')
shopModule:addBuyableItem({'avalanche rune'}, 2274, 180,  'avalanche rune')
shopModule:addBuyableItem({'antidote rune'}, 2266, 65,  'antidote rune')
shopModule:addBuyableItem({'energy bomb'}, 2262, 325,  'energy bomb rune')
shopModule:addBuyableItem({'energy wall'}, 2279, 340,  'energy wall rune')
shopModule:addBuyableItem({'fire ball'}, 2302, 150,  'fire ball rune')
shopModule:addBuyableItem({'icicle'}, 2271, 150,  'icicle rune')
shopModule:addBuyableItem({'poison field'}, 2285, 65,  'poison field rune')
shopModule:addBuyableItem({'poison wall'}, 2289, 210,  'poison wall rune')
shopModule:addBuyableItem({'blank'}, 2260, 10, 'blank rune')
shopModule:addBuyableItemContainer({'bp blank'},1998, 2260, 220, 'bp blank rune')
shopModule:addBuyableItemContainer({'bp animate dead'},1998, 2316, 7520, 'bp animate dead rune')
shopModule:addBuyableItemContainer({'bp antidote'},2003, 2266, 1320,  'bp antidote rune')
shopModule:addBuyableItemContainer({'bp avalanche'},2002, 2274, 3600, 'bp avalanche rune')
shopModule:addBuyableItemContainer({'bp chameleon'},1998, 2291, 4220, 'bp chameleon rune')
shopModule:addBuyableItemContainer({'bp convince creature'},1998, 2290, 1620, 'bp convince creature rune')
shopModule:addBuyableItemContainer({'bp desintegrate'},2001, 2310, 1620, 'bp desintegrate rune')
shopModule:addBuyableItemContainer({'bp destroy field'},2003, 2261, 920,  'bp destroy field')
shopModule:addBuyableItemContainer({'bp energy bomb'},2003, 2262, 6520, 'bp energy bomb rune')
shopModule:addBuyableItemContainer({'bp energy field'},1998, 2277, 2320, 'bp energy field')
shopModule:addBuyableItemContainer({'bp energy wall'},2002, 2279, 6820, 'bp energy wall rune')
shopModule:addBuyableItemContainer({'bp explosion'},2001, 2313, 3820, 'bp explosion rune')
shopModule:addBuyableItemContainer({'bp fire bomb'},2000, 2305, 4720, 'bp fire bomb rune')
shopModule:addBuyableItemContainer({'bp fire field'},2000, 2301, 1720,  'bp fire field rune')
shopModule:addBuyableItemContainer({'bp fireball'},2000, 2302, 3020,  'bp fire ball')
shopModule:addBuyableItemContainer({'bp gfb'},2000, 2304, 3620, 'bp gfb')
shopModule:addBuyableItemContainer({'bp hmm'},2001, 2311, 2420, 'bp hmm')
shopModule:addBuyableItemContainer({'bp icicle'},2002, 2271, 3020, 'bp icicle')
shopModule:addBuyableItemContainer({'bp ih'},2003, 2265, 1920, 'bp ih')
shopModule:addBuyableItemContainer({'bp lmm'},1998, 2287, 820, 'bp lmm')
shopModule:addBuyableItemContainer({'bp poison field'},1998, 2285, 1320,  'bp poison field')
shopModule:addBuyableItemContainer({'bp poison wall'},1998, 2289, 4220, 'bp poison wall rune')
shopModule:addBuyableItemContainer({'bp sd'},2003, 2268, 6500, 'bp sd')
shopModule:addBuyableItemContainer({'bp uh'},2002, 2273, 3520, 'bp uh')
shopModule:addBuyableItemContainer({'bp shp'}, 2000, 8704, 400, 'backpack of small health potions')
shopModule:addBuyableItemContainer({'bp hp'}, 2000, 7618, 900, 'backpack of health potions')
shopModule:addBuyableItemContainer({'bp mp'}, 2001, 7620, 1000, 'backpack of mana potions')
shopModule:addBuyableItemContainer({'bp shp'}, 2000, 7588, 2000, 'backpack of strong health potions')
shopModule:addBuyableItemContainer({'bp smp'}, 2001, 7589, 1600, 'backpack of strong mana potions')
shopModule:addBuyableItemContainer({'bp ghp'}, 2000, 7591, 3800, 'backpack of great health potions')
shopModule:addBuyableItemContainer({'bp gmp'}, 2001, 7590, 2400, 'backpack of great mana potions')
shopModule:addBuyableItemContainer({'bp gsp'}, 1999, 8472, 3820, 'backpack of great spirit potions')
shopModule:addBuyableItemContainer({'bp uhp'}, 2000, 8473, 6200, 'backpack of ultimate health potions')


function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	local items = {[1] = 2190, [2] = 2182, [5] = 2190, [6] = 2182}

	if(msgcontains(msg, 'first rod') or msgcontains(msg, 'first wand')) then
		if(isSorcerer(cid) or isDruid(cid)) then
			if(getPlayerStorageValue(cid, 30002) == -1) then
				selfSay('So you ask me for a {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '} to begin your advanture?', cid)
				talkState[talkUser] = 1
			else
				selfSay('What? I have already gave you one {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '}!', cid)
			end
		else
			selfSay('Sorry, you aren\'t a druid either a sorcerer.', cid)
		end
	elseif(msgcontains(msg, 'yes')) then
		if(talkState[talkUser] == 1) then
			doPlayerAddItem(cid, items[getPlayerVocation(cid)], 1)
			selfSay('Here you are young adept, take care yourself.', cid)
			setPlayerStorageValue(cid, 30002, 1)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		selfSay('Ok then.', cid)
		talkState[talkUser] = 0
	end

	return true
end

item = 'You do not have the required items.'
done = 'Here you are.'
	
		if msgcontains(msg, 'mission') then
		if getPlayerStorageValue(cid,649) == 1 and getPlayerStorageValue(cid,650) == 1 and getPlayerStorageValue(cid,651) == -1 then
		npcHandler:say("Well fantastic work, you gathered both samples! Now I can continue my work on the almanach, thank you very much for your help indeed. Can I take a look at my book please?",cid)
		talkState[talkUser] = 2
		else
		npcHandler:say("Why yes, there is indeed some minor issue I could need your help with. I was always a friend of nature and it was not recently I discovered the joys of plants, growths, of all the flora around us. ...",cid)
        npcHandler:say("Botany my friend. The study of plants is of great importance for our future. Many of the potions we often depend on are made of plants you know. Plants can help us tending our wounds, cure us from illness or injury. ...",cid)
        npcHandler:say("I am currently writing an excessive compilation of all the knowledge I have gathered during my time here in Farmine and soon hope to publish it as 'Rabaz' Unabridged Almanach Of Botany'. ...",cid)
        npcHandler:say("However, to actually complete my botanical epitome concerning Zao, I would need someone to enter these dangerous lands. Someone able to get closer to the specimens than I can. ...",cid)
		npcHandler:say("And this is where you come in. There are two extremely rare species I need samples from. Typically not easy to come by but it should not be necessary to venture too far into Zao to find them. ...",cid)
		npcHandler:say("Explore the anterior outskirts of Zao, use my almanach and find the two specimens with missing samples on their pages. The almanach can be found in a chest in my storage, next to my shop. It's the door over there. ...",cid)
		npcHandler:say("If you lose it I will have to write a new one and put it in there again - which will undoubtedly take me a while. So keep an eye on it on your travels. ...",cid)
		npcHandler:say("Once you find what I need, best use a knife to carefully cut and gather a leaf or a scrap of their integument and press it directly under their appropriate entry into my botanical almanach. ...",cid)
		npcHandler:say("Simply return to me after you have done that and we will discuss your reward. What do you say, are you in?",cid)
		talkState[talkUser] = 3
		end
		if msgcontains(msg,'yes') and talkState[talkUser] == 2   then
		npcHandler:say("Ah, thank you. Now look at that texture and fine colour, simply marvellous. ...",cid)
		npcHandler:say("I hope the sun in the steppe did not exhaust you too much? Shellshock. A dangerous foe in the world of field science and exploration. ...",cid)
		npcHandler:say("Here, I always wore this comfortable hat when travelling, take it. It may be of use for you on further reconnaissances in Zao. Again you have my thanks, friend.",cid)
		setPlayerStorageValue(cid,651,1)
		elseif msgcontains(msg,'yes') and talkState[talkUser] == 3 then
		npcHandler:say("Yes? Yes! That's the enthusiasm I need! Remember to bring a sharp knife to gather the samples, plants - even mutated deformed plants - are very sensitive you know. Off you go and be careful out there, Zao is no place for the feint hearted mind you.",cid)
         setPlayerStorageValue(cid,652,1)
		
   		return true
	end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
-- Include the Advanced NPC System
dofile(getDataDir() .. 'npc/lib/npcsystem/npcsystem.lua')

function selfIdle()
following = false
attacking = false

selfAttackCreature(0)
target = 0
end

function selfSayChannel(cid, message)
return selfSay(message, cid, false)
end

function selfMoveToCreature(id)
if(not id or id == 0) then
return
end

local t = getCreaturePosition(id)
if(not t.x or t.x == nil) then
return
end

selfMoveTo(t.x, t.y, t.z)
return
end

function getNpcDistanceToCreature(id)
errors(false)
local thing = getThing(id)

errors(true)
if(thing.uid == 0) then
return nil
end

local c = getCreaturePosition(id)
if(not isValidPosition(c)) then
return nil
end

local s = getCreaturePosition(getNpcId())
if(not isValidPosition(s) or s.z ~= c.z) then
return nil
end

return math.max(math.abs(s.x - c.x), math.abs(s.y - c.y))
end

function doMessageCheck(message, keyword)
if(type(keyword) == "table") then
return table.isStrIn(keyword, message)
end

local a, b = message:lower():find(keyword:lower())
if(a ~= nil and b ~= nil) then
return true
end

return false
end

function doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack)
local amount = amount or 1
local subType = subType or 1
local ignoreCap = ignoreCap and true or false

local item = 0
if(isItemStackable(itemid)) then
item = doCreateItemEx(itemid, amount)
if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
return 0, 0
end

return amount, 0
end

local a = 0
if(inBackpacks) then
local container = doCreateItemEx(backpack, 1)
local b = 1
for i = 1, amount do
item = doAddContainerItem(container, itemid, subType)
if(itemid == ITEM_PARCEL) then
doAddContainerItem(item, ITEM_LABEL)
end

if(isInArray({(getContainerCapById(backpack) * b), amount}, i)) then
if(doPlayerAddItemEx(cid, container, ignoreCap) ~= RETURNVALUE_NOERROR) then
b = b - 1
break
end

a = i
if(amount > i) then
container = doCreateItemEx(backpack, 1)
b = b + 1
end
end
end

return a, b
end

for i = 1, amount do
item = doCreateItemEx(itemid, subType)
if(itemid == ITEM_PARCEL) then
doAddContainerItem(item, ITEM_LABEL)
end

if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
break
end

a = i
end

return a, 0
end

function doRemoveItemIdFromPos (id, n, position)
local thing = getThingFromPos({x = position.x, y = position.y, z = position.z, stackpos = 1})
if(thing.itemid == id) then
doRemoveItem(thing.uid, n)
return true
end

return false
end

function getNpcName()
return getCreatureName(getNpcId())
end

function getNpcPos()
return getCreaturePosition(getNpcId())
end

function selfGetPosition()
local t = getNpcPos()
return t.x, t.y, t.z
end

msgcontains = doMessageCheck
moveToPosition = selfMoveTo
moveToCreature = selfMoveToCreature
selfMoveToPosition = selfMoveTo
selfGotoIdle = selfIdle
isPlayerPremiumCallback = isPremium
doPosRemoveItem = doRemoveItemIdFromPos
doNpcBuyItem = doPlayerRemoveItem
doNpcSetCreatureFocus = selfFocus
getNpcCid = getNpcId
getDistanceTo = getNpcDistanceTo
getDistanceToCreature = getNpcDistanceToCreature
 
You pasted your mission stuff outside the function creatureSayCallback(cid, type, msg) callback.
You should fix that.
 
Back
Top