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

Error on npc

wafuboe

Active Member
Joined
Dec 24, 2010
Messages
884
Solutions
2
Reaction score
26
Well i got this error when talking to this npc, also it doesnt respond

aoxtop.jpg


heres the script

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local random_texts = {'I should find a way to fix that house.', 'Come in, please.', 'I want to paaaaaarty!', 'Come in, I have candies.', '<sings> A true, true friend helps a friend in need,\na friend will be there to help them see...', '<sings>All you have to do is take a cup of flour,\nadd it to the mix!', 'Neki! You should stop talking to yourself... starting from Now!'}
local random_texts_chance = 10 -- percent
local random_texts_interval = 5 -- seconds
local talkState = {}
local function round(num, idp)
    local mult = 10^(idp or 0)
    if num >= 0 then return math.floor(num * mult + 0.5) / mult
    else return math.ceil(num * mult - 0.5) / mult end
end
random_word_neki = 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()
    if(random_word_neki < os.time()) then
        random_word_neki = (os.time() + random_texts_interval)
        if(math.random(1, 100) < random_texts_chance) then
            selfSay(random_texts[math.random(1, #random_texts)])
        end
    end
    npcHandler:onThink()
end

function greetCallback(cid)
    local talkUser = cid
    local msg = {
        "Hi. What are you doing here? Are you alone? Because, you know I don't meet guests here often.",
        "So your name is " .. getPlayerName(cid) .. ". Come and be my guest.",
        "Finally! Somepo... someone! I don't meet guests often, come in.",
        "Come, I was about to make {cupcakes}, it appears I don't need to eat them alone!",
    }
    local msgknow = {
        "Welcome again. Oh I am so happy you're back. It was like eternity when you ran last time, you know?",
        "Hey, I remember you, you are that po... person I met last time, aren't you?",
        "Come in, my little warrior. Have you enjoyed your last visit here?",
        "Hello again, " .. getPlayerName(cid) .. ". I was just wondering why don't move to the {city} centre and have a massive party here! Is that good idea?",
    }
    if getPlayerStorageValue(cid, 49950) < 1 then
    npcHandler:setMessage(MESSAGE_GREET, msg[math.random(1, #msg)])
    talkState[talkUser] = 0
    doCreatureSetStorage(cid, 49950, 1)
    else
    npcHandler:setMessage(MESSAGE_GREET, msgknow[math.random(1, #msgknow)])
    talkState[talkUser] = 5
    end
    return true
end

function creatureSayCallback(cid, type, msg)
local talkUser = cid
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    if msgcontains(msg, "page") then
            if getCreatureStorage(cid, 49951) < 1 then
                selfSay("What? Someone took that page? No! It was one of stories of my childhood. Find it and bring it back.", cid)
                doCreatureSetStorage(cid, 49951, 1)
                talkState[talkUser] = 0
            else
                if getCreatureStorage(cid, 49951) == 1 then
                    selfSay("Did you found that missing page?", cid)
                    talkState[talkUser] = 7
                else
                    selfSay("Thank you for your hard work. My childhood memory is complete again.", cid)
                    talkState[talkUser] = 0
                end
            end
    end
    if msgcontains(msg, "yes") and talkState[talkUser] == 7 then
        if doPlayerRemoveItem(cid,9663,1) then
            if getCreatureStorage(cid, 35712) == 1 then
                selfSay("You found it where? Yesim did what? It wasn't nice, he didn't even told me. Great work! Really wonderful. I should reward you, but I don't have anything. Take these clothes as a reward.", cid)
                doCreatureSetStorage(cid, 49951, 2)
                doPlayerAddOutfit(cid, 514, 1)
                doPlayerAddOutfit(cid, 516, 1)
                doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
                talkState[talkUser] = 0   
            else
                selfSay("You found it where? I have no idea how could I lose that. Great work! Really wonderful. I should reward you, but I don't have anything. Take these clothes as a reward.", cid)
                doCreatureSetStorage(cid, 49951, 2)
                doPlayerAddOutfit(cid, 514, 1)
                doPlayerAddOutfit(cid, 516, 1)
                doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
                talkState[talkUser] = 0
            end
        else
            selfSay("This is not the page we are looking for.", cid)
            talkState[talkUser] = 0
        end
    end
    if msgcontains(msg, "no") and talkState[talkUser] == 16 then
        selfSay("Go to temple and let the priestess heal you. I will not teleport you due to my lack of magic skill.", cid)
        talkState[talkUser] = 0
    end
    if msgcontains(msg, "yes") and talkState[talkUser] == 16 then
        selfSay("Good. If you would try it again one day, ask me.", cid)
        talkState[talkUser] = 0
    end
    if msgcontains(msg, "no") and talkState[talkUser] == 7 then
        selfSay('Well, things hide from us sometimes, teehee.', cid)
        talkState[talkUser] = 0
    end
    if msgcontains(msg, "no") and talkState[talkUser] == 40 then
        selfSay('Okay. If you want to extend your spell bring me 3 demonic essences.', cid)
        talkState[talkUser] = 0
    end
     if msgcontains(msg, "yes") and talkState[talkUser] == 5 then
        selfSay("I knew you would answer like that. Come in, let's have a {party}!", cid)
    talkState[talkUser] = 0
    end
    if msgcontains(msg, "no") and talkState[talkUser] == 5 then
    selfSay('Why? Where I made mistake? What have I done wrong? Why do all the people run from me that fast?', cid)
    talkState[talkUser] = 0
    end
    if msgcontains(msg, "enchant") then
    if getCreatureStorage(cid, 35715) < 1 then
    selfSay("Hmm... strange stuff, I would try, but I forgot how to enchant. Bring me something to try... hmm... My last {axe} was broken on a tree near my house. Would be nice if you could bring me a new one and I will see what I can do with that. Maybe it will be able to work longer than normal one.", cid)
    talkState[talkUser] = 0
    doCreatureSetStorage(cid, 35715, 1)
    else
    if getPlayerItemCount(cid, 2386) > 0 then
    selfSay("Yes, this one looks perfect! Would you give it to me now?", cid)
    talkState[talkUser] = 8
    else
    selfSay("This one is too complicated to enchant. I don't even know how to use it if it's really an axe as you think.", cid)
    talkState[talkUser] = 0
    end
    end
    end
   
    if msgcontains(msg, "yes") and talkState[talkUser] == 8 then
        if getPlayerItemCount(cid, 2386) > 0 then
        local random = math.random(1,100)
        doPlayerTakeItem(cid, 2386, 1)
        if random >= 50 then
        doPlayerAddItem(cid, 8293, 1)
        selfSay("It worked, it worked! I can't believe I still can do such stuff. When you finish testing leave it near my house.",cid)
        talkState[talkUser] = 0
        else
        selfSay("Looks like my {destiny} is not for this. Try to find another one while I will read a book about enchanting.",cid)
        talkState[talkUser] = 0
        end
        else
            selfSay("Come on, I know you have that axe, stop kidding and give it to me.",cid)
            talkState[talkUser] = 0
        end
    end
   
    if msgcontains(msg, "axe") then
        selfSay("I've broken my axe last time I was earning some wood. Maybe enchanted one will stay longer. Do you have any axe with you?", cid)
        talkState[talkUser] = 8
    end
   
    if msgcontains(msg, "no") and talkState[talkUser] == 8 then
        selfSay('Okay. Then go and bring me some wood yourself.', cid)
        talkState[talkUser] = 0
    end
   
    if msgcontains(msg, "vanilla") then
        selfSay("Did you found some? Where? Did you found it?", cid)
        talkState[talkUser] = 9
    end
   
    if msgcontains(msg, "no") and talkState[talkUser] == 9 then
        selfSay("It's really hard to find one these days.", cid)
        talkState[talkUser] = 0
    end
   
    if msgcontains(msg, "yes") and talkState[talkUser] == 9 then
        selfSay("This doesn't even look like vanilla. Keep searching.", cid)
        talkState[talkUser] = 0
    end
    if msgcontains(msg, "demon") or msgcontains(msg, "oak") then
        if getCreatureStorage(cid, storages.done) == 1 then
            if getCreatureStorage(cid, 49952) < 1 then
                selfSay("What? A tree which cannot be defeated by giggling? Interesting. And what have you done for that? Ouch. I have some stuff after my grandad, he was some kind of enchanter or something. I think you are the warrior worth wearing it. Do you accept with my point of view?", cid)
                talkState[talkUser] = 4
            else
                selfSay("Thank you once again. If outfit wasn't enough you may eat some {candies} from upper floor.", cid)
                talkState[talkUser] = 0
            end
        else
        selfSay("There are no demon trees. I'm telling you. Giggle at them, you will see.", cid)
        talkState[talkUser] = 0
        end
    end
    if msgcontains(msg, "yes") and talkState[talkUser] == 4 then
        selfSay("Take them. Wear them with pride and listen. There is old legend nana told me when I was little girl: Where the brambles are thickest, there you will find a pond, beyond the most twisted of vines, the mirror pool... I don't know maybe it helps you somehow, who knows?", cid)
        doPlayerAddOutfit(cid, 514, 2)
        doPlayerAddOutfit(cid, 516, 2)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
        doCreatureSetStorage(cid, 49952, 1)
        talkState[talkUser] = 0
    end
    if msgcontains(msg, "no") and talkState[talkUser] == 4 then
        selfSay("Get back here instantly when you change your mind.", cid)
        talkState[talkUser] = 0
    end
        if(msgcontains(msg, 'white') and msgcontains(msg, 'magic')) then
    selfSay('The white magic book, I saw it in library when I was young enchantress. I have no idea if its still there.', cid)
    talkState[talkUser] = 0
    end
    if(msgcontains(msg, 'expert') and msgcontains(msg, 'spell')) then
    selfSay('Looks like my {destiny} is not for this. Try to find another one while I will read a book about enchanting.', cid)
    talkState[talkUser] = 0
    end
    if(msgcontains(msg, 'stationary') and msgcontains(msg, 'shield')) then
    selfSay('How was this going? From one to another, another to one... no, no, no. This wasn\'t it. Better not cast anything without proper lecture.', cid)
    talkState[talkUser] = 0
    end
    if(msgcontains(msg, 'age') and msgcontains(msg, 'spell')) then
    selfSay('I tried it once, nothing happend.', cid)
    talkState[talkUser] = 0
    end
    if(msgcontains(msg, 'soft') and msgcontains(msg, 'wings')) then
    selfSay('Ha! I heard about it! Flying was always my dream, but my skill was too poor to cast it.', cid)
    talkState[talkUser] = 0
    end
    if(msgcontains(msg, 'lightbringer')) then
    selfSay('I saw one, maybe two. One rider owned one, but refused to tell where he found it.', cid)
    talkState[talkUser] = 0
    end
    if(msgcontains(msg, 'cloudwalking')) then
    local spelldur = round((getPlayerStorageValue(cid, 22444)-os.time())/3600)
        if getPlayerStorageValue(cid,22444) < os.time() then
            if getPlayerItemCount(cid, 6500) > 2 then
            selfSay('I think I know how to cast it, but I failed in finding a good ladder to the sky, <giggles>. I need three demonic essences <whines> which are obviously less rare than vanilla. I have no idea if this spell works, but consumes essences so it\'s worth a try! Do you have them with you?', cid)
            talkState[talkUser] = 15
            else
            selfSay('I think I know how to cast it, but I failed in finding a good ladder to the sky, <giggles>. I need three demonic essences <whines> which are obviously less rare than vanilla. I have no idea if this spell works, but consumes essences so it\'s worth a try!', cid)
            talkState[talkUser] = 0
            end
        else
            if getPlayerItemCount(cid, 6500) > 2 then
            if spelldur == 1 then rt = '' else rt = 's' end
            selfSay('It seems you still have ' .. spelldur .. ' hour' .. rt .. ' of spell more or something. Do you want me to try to extend your spell?', cid)            talkState[talkUser] = 15
            else
            selfSay('Your spell is still active. Wanna some tea?', cid)
            talkState[talkUser] = 40
            end       
        end
    end
    if msgcontains(msg, "yes") and talkState[talkUser] == 40 then
        selfSay('Here you are.', cid)
        doPlayerAddItem(cid, 2012, 35)
        talkState[talkUser] = 0
        return true
    end
    if msgcontains(msg, "yes") and talkState[talkUser] == 15 then
    if doPlayerTakeItem(cid, 6500, 3) then
    local hurt = math.random(1,100)
    if hurt >= 70 then
            if getCreatureHealth(cid) < 300 then
                npcHandler:say("I think it went wrong. Are you alright?", cid)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_EXPLOSIONAREA)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
            else
                npcHandler:say("Sweet Estalice! I didn't mean to hurt you. I'm sorry. Are you alright?", cid)
                doCreatureAddHealth(cid, -200)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_EXPLOSIONAREA)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
            end
        talkState[talkUser] = 16
    else
    doCreatureSetStorage(cid, 22444, os.time() + (86400 * 3))
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
    selfSay('I have no idea if it worked, but if you know any heaven lift <laughs>, you should try it out.', cid)
    talkState[talkUser] = 0
    end
    else
    selfSay('No, silly! They ain\'t essences. Not demonic either.', cid)
    talkState[talkUser] = 0
    end
    end
    if msgcontains(msg, "no") and talkState[talkUser] == 15 then
        selfSay("Get back here instantly when you change your mind.", cid)
        talkState[talkUser] = 0
    end
    return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
change doCreatureSetStorage to doPlayerSetStorageValue
there's 2 different scripts and 2 separate errors
cant help you with the first error if you dont send iodship.lua
 
here is iod
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic, Town = {}, {}
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 thinkCallback(cid)
    if math.random(300) == 1 then
        npcHandler:say("Harr! Wanna go off this island? Need me an' my ship!")
    end
    return true
end
function creatureSayCallback(cid, type, msg)
    if (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and (not npcHandler:isFocused(cid)) then
        local player = Player(cid)
        local v, k = player:getVocation(), getCreatureName(cid)
        if v == 0 then
            npcHandler:say(getPlayerSex(cid) == 0 and "Well hello there, lovely lady! Can't sail you anywhere without a {vocation}, though. Y'should talk to the four vocation {masters} first, " .. k .. "." or "How cute, a freshly hatched newcomer. Harr. Can't leave this island without a {vocation}, y'know? Y'should talk to the four vocation {masters} first, " .. k.. ".", cid)
            Topic[cid] = 0
        else
            npcHandler:say("Harrr, a new " .. v:getName() .. "! Can't wait to get off this lousy island and head for adventure, eh? Want me to bring ya somewhere nice, I rlly recomend you thais cuz the king lives ther an also if u wanna hav' lot f fun, " .. k .. "?", cid)
            Topic[cid] = 1
        end
        Town[cid] = nil
        npcHandler:addFocus(cid)
    elseif(not npcHandler:isFocused(cid)) then
        return false
    elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
        npcHandler:say("Hrrrm. Better y'stay here for a bit, aight.", cid, TRUE)
        Topic[cid] = nil
        Town[cid] = nil
        npcHandler:releaseFocus(cid)
    elseif Topic[cid] == 1 then
        if msgcontains(msg, "yes") then
            npcHandler:say("Take a hint from old Cap'n Kurt. Make sure y'dun leave here before yer equipped well. Ya went for rob- err, shopping and got stuff like rope, armor, and weap'n?", cid)
            Topic[cid] = 2
        elseif msgcontains(msg, "no") then
            npcHandler:say("Then what'd ya want? Learn about the main avalian city?", cid)
            Topic[cid] = 3
        else
            npcHandler:say("Kid, one thing y'should learn. Answer with {yes} or {no} and ya'll get much farther than with random babbling.", cid)
            Topic[cid] = 1
        end
    elseif Topic[cid] == 2 then
        if msgcontains(msg, "yes") then
            npcHandler:say("Harrharr. Good answer. Wanna know somethin' about the main avalian city before you choose yer new home?", cid)
            Topic[cid] = 3
        elseif msgcontains(msg, "no") then
            npcHandler:say("Then prepare yourself and come back later, eh?", cid)
            npcHandler:releaseFocus(cid)
            Topic[cid] = nil
        end
    elseif Topic[cid] == 3 then
        if msgcontains(msg, "yes") then
            npcHandler:say("Aye. Wanna know about {Thanis}?", cid)
            Topic[cid] = 0
        elseif msgcontains(msg, "no") then
            npcHandler:say(isPremium(cid) and "So ya know it all, eh? Where dyou want to go, kid? {Thanis}?" or "So ya know it all, eh? Where'd ya want me to bring ya then, kid? {Thanis}?", cid)
            Topic[cid] = 4
        end
    elseif Topic[cid] == 4 then
        if msgcontains(msg, "lllll") then
            npcHandler:say("So it's Ab'Dendriel y'wanna live in? What y'say, {yes} or {no}?", cid)
            Topic[cid] = 5
            Town[cid] = "Ab'Dendriel"
        elseif msgcontains(msg, "sdfsdfds") then
            if isPremium(cid) then
                npcHandler:say("So it's Ankrahmun y'wanna live in? What y'say, {yes} or {no}?", cid)
                Topic[cid] = 5
                Town[cid] = 'Ankrahmun'
            else
                npcHandler:say("Nope, can't bring y'there without a premium account. Y'should be glad you get to travel by ship, usually a premium service, too, y'know.", cid)
                Topic[cid] = 0
            end
        elseif msgcontains(msg, "fdff") then
            npcHandler:say("So it's Carlin y'wanna live in? What y'say, {yes} or {no}?", cid)
            Topic[cid] = 5
            Town[cid] = 'Carlin'
        elseif msgcontains(msg, "dfsfdsf") then
            if isPremium(cid) then
                npcHandler:say("So it's Darashia y'wanna live in? What y'say, {yes} or {no}?", cid)
                Topic[cid] = 5
                Town[cid] = 'Darashia'
            else
                npcHandler:say("Nope, can't bring y'there without a premium account. Y'should be glad you get to travel by ship, usually a premium service, too, y'know.", cid)
                Topic[cid] = 0
            end
        elseif msgcontains(msg, "cdfsd") then
            if isPremium(cid) then
                npcHandler:say("So it's Edron y'wanna live in? What y'say, {yes} or {no}?", cid)
                Topic[cid] = 5
                Town[cid] = 'Edron'
            else
                npcHandler:say("Nope, can't bring y'there without a premium account. Y'should be glad you get to travel by ship, usually a premium service, too, y'know.", cid)
                Topic[cid] = 0
            end
        elseif msgcontains(msg, "sadsad") and msgcontains(msg, "sdfds") then
            if isPremium(cid) then
                npcHandler:say("So it's Liberty Bay y'wanna live in? What y'say, {yes} or {no}?", cid)
                Topic[cid] = 5
                Town[cid] = 'Liberty Bay'
            else
                npcHandler:say("Nope, can't bring y'there without a premium account. Y'should be glad you get to travel by ship, usually a premium service, too, y'know.", cid)
                Topic[cid] = 0
            end
        elseif msgcontains(msg, "dsasda") and msgcontains(msg, "dasads") then
            if isPremium(cid) then
                npcHandler:say("So it's Port Hope y'wanna live in? What y'say, {yes} or {no}?", cid)
                Topic[cid] = 5
                Town[cid] = 'Port Hope'
            else
                npcHandler:say("Nope, can't bring y'there without a premium account. Y'should be glad you get to travel by ship, usually a premium service, too, y'know.", cid)
                Topic[cid] = 0
            end
        elseif msgcontains(msg, "wewqeqw") then
            npcHandler:say("So it's Thais y'wanna live in? What y'say, {yes} or {no}?", cid)
            Topic[cid] = 5
            Town[cid] = 'Thais'
        elseif msgcontains(msg, "Thanis") then
            npcHandler:say("So it's Thanis y'wer heading. What y'say, {yes} or {no}?", cid)
            Topic[cid] = 5
            Town[cid] = 'Thanis'
        else
            npcHandler:say("Nope, wha'ever that is, I dun sail there. ".. isPremium(cid) and "{Ab'Dendriel}, {Ankrahmun}, {Carlin}, {Darashia}, {Edron}, {Liberty Bay}, {Port Hope}, {Thais} or {Venore}" or "{Ab'Dendriel}, {Carlin}, {Thais} or {Venore}" .."?", cid)
            Topic[cid] = 5
        end
    elseif msgcontains(msg, "passage") or msgcontains(msg, "sail") or msgcontains(msg, "travel") then
        if getPlayerVocation(cid) == 0 then
            npcHandler:say("Nope, yer not going anywhere. Can't transport ya without a {vocation}, y'know?", cid)
            Topic[cid] = 0
        else
            npcHandler:say("So, y'chose your new home city? Which one's it gonna be?", cid)
            Topic[cid] = 4
        end
    elseif Topic[cid] == 5 then
        if msgcontains(msg, 'yes') then
            npcHandler:say("And off we go! If yer lost, dun forget t'talk to the guide on the ship!", cid)
            local v = getTownId(Town[cid])
            npcHandler:releaseFocus(cid)
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
            doTeleportThing(cid, getTownTemplePosition(v))
            doSendMagicEffect(getTownTemplePosition(v), CONST_ME_TELEPORT)
            doPlayerSetTown(cid, v)
            Topic[cid] = nil
        else
            npcHandler:say("Changed yer mind? What city d'ya wanna head to, {Ab'Dendriel}, {Ankrahmun}, {Carlin}, {Darashia}, {Edron}, {Liberty Bay}, {Port Hope}, {Thais} or {Venore}?", cid)
        end

        Topic[cid] = 0
    elseif msgcontains(msg, "thanis") then
        npcHandler:say("Old-school city. Actually the oldest main city in Tibia. Be careful on those streets, there're bandits everywhere. I can {sail} there if ya like.", cid)
   
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_WALKAWAY, "Hrrrrm. And a good day to you, too!")
npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
 
Back
Top