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

Problem with npc script

Darqneez

ShaC-Ohhhh
Joined
Dec 30, 2009
Messages
72
Reaction score
2
Location
Poland/Wroclaw
I'd like to make my own npc, which would buy some items, and I made a script for this, but it doesnt work. Can someone help me to solve it? here's script:

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Kowal" script="kowal.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="131" head="0" body="114" legs="114" feet="0" addons="3"/>
<parameters>
<parameter key="message_greet" value="Witaj |PLAYERNAME|, Masz moze towary, ktore mnie interesuja?" />
</parameters>
</npc>

and Lua:

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

function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addSellableItem({''}, 2463, 1000, 'devil helmet')
shopModule:addSellableItem({''}, 2491, 2500, 'crown helmet')
shopModule:addSellableItem({''}, 2497, 6000, 'crusader helmet')
shopModule:addSellableItem({''}, 2475, 5000, 'warrior helmet')
shopModule:addSellableItem({''}, 2498, 30000, 'royal helmet')

shopModule:addSellableItem({''}, 2656, 10000, 'blue robe')
shopModule:addSellableItem({''}, 2476, 5000, 'knight armor')
shopModule:addSellableItem({''}, 2487, 12000, 'crown armor')
shopModule:addSellableItem({''}, 8891, 15000, 'paladin armor')
shopModule:addSellableItem({''}, 2492, 40000, 'dragon scale mail')
shopModule:addSellableItem({''}, 2466, 20000, 'golden armor')
shopModule:addSellableItem({''}, 2472, 200000, 'magic plate armor')

shopModule:addSellableItem({''}, 2488, 12000, 'crown legs')
shopModule:addSellableItem({''}, 2477, 5000, 'knight legs')
shopModule:addSellableItem({''}, 2470, 80000, 'golden legs')

shopModule:addSellableItem({''}, 2195, 30000, 'boots of haste')
shopModule:addSellableItem({''}, 2645, 30000, 'steel boots')

shopModule:addSellableItem({''}, 2515, 2000, 'guardian shield')
shopModule:addSellableItem({''}, 2516, 4000, 'dragon shield')
shopModule:addSellableItem({''}, 2519, 8000, 'crown shield')
shopModule:addSellableItem({''}, 2528, 8000, 'tower shield')
shopModule:addSellableItem({''}, 2536, 9000, 'medusa shield')
shopModule:addSellableItem({''}, 2534, 15000, 'vampire shield')
shopModule:addSellableItem({''}, 2520, 30000, 'demon shield')
shopModule:addSellableItem({''}, 2514, 70000, 'mastermind shield')




npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
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

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addSellableItem({'devil helmet'}, 2463, 1000, 'devil helmet')
shopModule:addSellableItem({'crown helmet'}, 2491, 2500, 'crown helmet')
shopModule:addSellableItem({'crusader helmet'}, 2497, 6000, 'crusader helmet')
shopModule:addSellableItem({'warrior helmet'}, 2475, 5000, 'warrior helmet')
shopModule:addSellableItem({'royal helmet'}, 2498, 30000, 'royal helmet')

shopModule:addSellableItem({'blue robe'}, 2656, 10000, 'blue robe')
shopModule:addSellableItem({'knight armor'}, 2476, 5000, 'knight armor')
shopModule:addSellableItem({'crown armor'}, 2487, 12000, 'crown armor')
shopModule:addSellableItem({'paladin armor'}, 8891, 15000, 'paladin armor')
shopModule:addSellableItem({'dragon scale mail'}, 2492, 40000, 'dragon scale mail')
shopModule:addSellableItem({'golden armor'}, 2466, 20000, 'golden armor')
shopModule:addSellableItem({'magic plate armor'}, 2472, 200000, 'magic plate armor')

shopModule:addSellableItem({'crown legs'}, 2488, 12000, 'crown legs')
shopModule:addSellableItem({'knight legs'}, 2477, 5000, 'knight legs')
shopModule:addSellableItem({'golden legs'}, 2470, 80000, 'golden legs')

shopModule:addSellableItem({'boots of haste'}, 2195, 30000, 'boots of haste')
shopModule:addSellableItem({'steel boots'}, 2645, 30000, 'steel boots')

shopModule:addSellableItem({'guardian shield'}, 2515, 2000, 'guardian shield')
shopModule:addSellableItem({'dragon shield'}, 2516, 4000, 'dragon shield')
shopModule:addSellableItem({'crown shield'}, 2519, 8000, 'crown shield')
shopModule:addSellableItem({'tower shield'}, 2528, 8000, 'tower shield')
shopModule:addSellableItem({'medusa shield'}, 2536, 9000, 'medusa shield')
shopModule:addSellableItem({'vampire shield'}, 2534, 15000, 'vampire shield')
shopModule:addSellableItem({'demon shield'}, 2520, 30000, 'demon shield')
shopModule:addSellableItem({'mastermind shield'}, 2514, 70000, 'mastermind shield')

npcHandler:addModule(FocusModule:new())
 
ok cykotitan, thanks but I don't understand 1 thing. I'd like to make a very similar npc script to this. Only items has changed, I've pasted your script and only changed the names of items their ids etc. But it doesn't work... I don't get it, I've tried many ways to solve this problem, but I just can't repair this, here's code:

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

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addSellableItem({'platinum amulet'}, 2171, 2500, 'platinum amulet')
shopModule:addSellableItem({'amulet of loss'}, 2173, 45000, 'amulet of loss')
shopModule:addSellableItem({'demonbone amulet'}, 2136, 32000, 'demonbone amulet')
shopModule:addSellableItem({'magma amulet'}, 7890, 1500, 'magma amulet')
shopModule:addSellableItem({'glacier amulet'}, 7888, 1500, 'glacier amulet')
shopModule:addSellableItem({'lightning pendant'}, 7889, 1500, 'lightning pendant')
shopModule:addSellableItem({'terra amulet'}, 7887, 1500, 'terra amulet')

shopModule:addSellableItem({'ring of the sky'}, 2123, 30000, 'ring of the sky')
shopModule:addSellableItem({'death ring'}, 6301, 1000, 'death ring')

shopModule:addBuyableItem({'amulet of loss'}, 2173, 50000, 'amulet of loss')
shopModule:addBuyableItem({'stealth ring'}, 2165, 5000, 'stealth ring')
shopModule:addBuyableItem({'time ring'}, 2169, 2000, 'time ring')
shopModule:addBuyableItem({'wedding ring'}, 2121, 50000, 'wedding ring')
shopModule:addBuyableItem({'gold ingot'}, 9971, 5000, 'gold ingot')

npcHandler:addModule(FocusModule:new())
 
here's error in TFS (Sorry that I took so long, but I had pause with building my own ots)
Code:
[07/06/2010 17:19:42] [Error - Npc interface] 
[07/06/2010 17:19:42] (Unknown script file)
[07/06/2010 17:19:42] Description: 
[07/06/2010 17:19:42] data/npc/lib/npcsystem/modules.lua:1151: bad argument #2 to 'error' (number expected, got string)
[07/06/2010 17:19:42] stack traceback:
[07/06/2010 17:19:42] 	[C]: in function 'error'
[07/06/2010 17:19:42] 	data/npc/lib/npcsystem/modules.lua:1151: in function 'callbackOnBuy'
[07/06/2010 17:19:42] 	data/npc/lib/npcsystem/npchandler.lua:263: in function 'processModuleCallback'
[07/06/2010 17:19:42] 	data/npc/lib/npcsystem/npchandler.lua:440: in function 'onBuy'
[07/06/2010 17:19:42] 	data/npc/lib/npcsystem/modules.lua:1292: in function <data/npc/lib/npcsystem/modules.lua:1291>
I can't buy anything and even if I have right item, I can't sell it :\
Please help me
 
Back
Top