Moj mistrz
Monster Creator
Witam. Chciałbym, żeby ktoś mi przerobił skrypt NPC. Zrobiłem go sam lecz gdy podchodzę do npc i pisze 'hi' to wyskakują błędy w konsoli. Dam tutaj skrypta i chciałbym, żeby mi ktoś pomogł.
W tym npc chodzi o to, żeby skupował itemy za expa i żeby np. podchodzę do niego i piszę, 'hi' 'midnight shard' (on piszę 'Do you want change all of midnight shards for experience?') ja piszę 'yes' i on zabiera wszystkie midnight shardy jakie mam.
Tu jest błąd jaki wyskakuje.
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandlernCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandlernCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandlernCreatureSay(cid, type, msg) end
function onThink() npcHandlernThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local exp = formula * formula2
local formula2 = getPlayerItemCount(cid, 10531)
local level = getPlayerLevel(cid)
local formula = (level * 30)
if msgcontains(msg, 'midnight shard') then
selfSay('Do you want change all of midnight shards for experience?')
talk_state = 1
elseif msgcontains(msg, 'yes') and talk_state == 1 then
selfSay('Are you really sure?')
talk_state = 2
elseif msgcontains(msg, 'yes') then
if doPlayerTakeItem(cid, formula2) == 0 then
selfSay('Thank you very much! Ill give you '..exp..' experience for returning it!')
doPlayerAddExp(cid, formula)
doSendMagicEffect(getPlayerPosition(cid), 14)
doSendAnimatedText(getPlayerPosition(cid), formula, TEXTCOLOR_WHITE)
talk_state = 3
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then
selfSay('Good bye. |PLAYERNAME|!')
talk_state = 0
end
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())
W tym npc chodzi o to, żeby skupował itemy za expa i żeby np. podchodzę do niego i piszę, 'hi' 'midnight shard' (on piszę 'Do you want change all of midnight shards for experience?') ja piszę 'yes' i on zabiera wszystkie midnight shardy jakie mam.
Tu jest błąd jaki wyskakuje.
[04/12/2009 14:32:19] Lua Script Error: [Npc interface]
[04/12/2009 14:32:19] data/npc/scripts/shardnpc.luanCreatureSay
[04/12/2009 14:32:19] data/npc/lib/npcsystem/npchandler.lua:550: attempt to call global 'getDistanceTo' (a nil value)
[04/12/2009 14:32:19] stack traceback:
[04/12/2009 14:32:19] data/npc/lib/npcsystem/npchandler.lua:550: in function 'isInRange'
[04/12/2009 14:32:19] data/npc/lib/npcsystem/npchandler.lua:375: in function 'onCreatureSay'
[04/12/2009 14:32:19] data/npc/scripts/shardnpc.lua:8: in function <data/npc/scripts/shardnpc.lua:8>