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

NPC Real Tibian NPC - 0.6.2 - not in progress

May not be a very important NPC, but it's exactly like real tibia, (not sure if it works in NPC window). It's Ruprecht, the guy you give Christmas tokens too. Anyway I released it on another OT site and I figured I'd lend you a hand, it's just the .lua, not the .xml. I made it when clients we're still 8.1 by the way.

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

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
    -- 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.
    if(npcHandler.focus ~= cid) then
        return false
    end

    -- use the real conversation? (true/false)
    real = true
    
    if real == true then
        tradeMsg = 'I accept presents that were stolen from Santa by those little pest Grynch Goblins in exchange for christmas tokens.'
        presentMsg = 'Do you want trade a present bag for a christmas token?'
        gingerMsg = 'Do you want trade a christmas token for a gingerbread man?'
        recipeMsg = 'Do you want trade 10 christmas tokens for a gingerbread man recipe?'
        jewelMsg = 'Do you want trade 25 christmas tokens for a jewel case?'
        hatMsg = 'Do you want trade 50 christmas tokens for a santa hat?'
        dollMsg = 'Do you want trade 100 christmas tokens for a santa doll?'
        hasNoMsg = 'I only want present bags.'
        askMsg = 'I will trade a gingerbread man for 1 token, the gingerbread recipe for 10, a jewel case for 25, a santa hat for 50 and a santa doll for 100 tokens.'
        noMsg = 'I\'ll be here when you\'re ready.'
    else
        tradeMsg = 'I accept presents that were stolen from Santa by those little pest Grynch Goblins in exchange for christmas tokens.'
        presentMsg = 'Do you want trade a present bag for a christmas token?'
        gingerMsg = 'Do you want trade a christmas token for a gingerbread man?'
        recipeMsg = 'Do you want trade 10 christmas tokens for a gingerbread man recipe?'
        jewelMsg = 'Do you want trade 25 christmas tokens for a jewel case?'
        hatMsg = 'Do you want trade 50 christmas tokens for a santa hat?'
        dollMsg = 'Do you want trade 100 christmas tokens for a santa doll?'
        hasNoMsg = 'I only want present bags.'
        askMsg = 'I will trade a gingerbread man for 1 token, the gingerbread recipe for 10, a jewel case for 25, a santa hat for 50 and a santa doll for 100 tokens.'
        noMsg = 'I\'ll be here when you\'re ready.'
    end
        if msgcontains(msg, 'items') or msgcontains(msg, 'item') or msgcontains(msg, 'offers') or msgcontains(msg, 'offer') then
            selfSay(tradeMsg)
        elseif msgcontains(msg, 'christmas token') or msgcontains(msg, 'token') or msgcontains(msg, 'xmas token') then
            selfSay(askMsg)
        elseif msgcontains(msg, 'present bag') or msgcontains(msg, 'present') or msgcontains(msg, 'bag') then
            selfSay(presentMsg)
            talk_state = 1
        elseif msgcontains(msg, 'gingerbread man') or msgcontains(msg, 'gingerbread cookie') or msgcontains(msg, 'ginger cookie') then
            selfSay(gingerMsg)
            talk_state = 2
        elseif msgcontains(msg, 'gingerbread recipe') or msgcontains(msg, 'recipe') or msgcontains(msg, 'cookie recipe') then
            selfSay(recipeMsg)
            talk_state = 3
        elseif msgcontains(msg, 'jewel case') or msgcontains(msg, 'case') or msgcontains(msg, 'jewel') or msgcontains(msg, 'jewels') or msgcontains(msg, 'locket') or msgcontains(msg, 'jewel box') then
            selfSay(jewelMsg)
            talk_state = 4
        elseif msgcontains(msg, 'santa hat') or msgcontains(msg, 'santas hat') or msgcontains(msg, 'hat') or msgcontains(msg, 'santa\'s hat') then
            selfSay(hatMsg)
            talk_state = 5
        elseif msgcontains(msg, 'santa doll') or msgcontains(msg, 'santas doll') or msgcontains(msg, 'doll') or msgcontains(msg, 'santa\'s doll') then
            selfSay(dollMsg)
            talk_state = 6
------------------------------------------------ confirm yes ------------------------------------------------
        elseif msgcontains(msg, 'yes') and talk_state == 1 then
            if getPlayerItemCount(cid,6497) >= 1 then
                if doPlayerTakeItem(cid,6497,1) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6527,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 2 then
            if getPlayerItemCount(cid,6527) >= 1 then
                if doPlayerTakeItem(cid,6527,1) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6501,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 3 then
            if getPlayerItemCount(cid,6527) >= 10 then
                if doPlayerTakeItem(cid,6527,10) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6523,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 4 then
            if getPlayerItemCount(cid,6527) >= 25 then
                if doPlayerTakeItem(cid,6527,25) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6104,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 5 then
            if getPlayerItemCount(cid,6527) >= 50 then
                if doPlayerTakeItem(cid,6527,50) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6531,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 6 then
            if getPlayerItemCount(cid,6527) >= 100 then
                if doPlayerTakeItem(cid,6527,100) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6512,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
------------------------------------------------ confirm no ------------------------------------------------
        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay(noMsg)
            talk_state = 0
        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())

thanks but this is just an edited sweaty cyclops :eek: but anyways, thanks :p
 
these don't even have looktypes in the xml. if ya want looktypes and so download my npcs theres atleast name and looktype in the xml
 
May not be a very important NPC, but it's exactly like real tibia, (not sure if it works in NPC window). It's Ruprecht, the guy you give Christmas tokens too. Anyway I released it on another OT site and I figured I'd lend you a hand, it's just the .lua, not the .xml. I made it when clients we're still 8.1 by the way.

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

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
    -- 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.
    if(npcHandler.focus ~= cid) then
        return false
    end

    -- use the real conversation? (true/false)
    real = true
    
    if real == true then
        tradeMsg = 'I accept presents that were stolen from Santa by those little pest Grynch Goblins in exchange for christmas tokens.'
        presentMsg = 'Do you want trade a present bag for a christmas token?'
        gingerMsg = 'Do you want trade a christmas token for a gingerbread man?'
        recipeMsg = 'Do you want trade 10 christmas tokens for a gingerbread man recipe?'
        jewelMsg = 'Do you want trade 25 christmas tokens for a jewel case?'
        hatMsg = 'Do you want trade 50 christmas tokens for a santa hat?'
        dollMsg = 'Do you want trade 100 christmas tokens for a santa doll?'
        hasNoMsg = 'I only want present bags.'
        askMsg = 'I will trade a gingerbread man for 1 token, the gingerbread recipe for 10, a jewel case for 25, a santa hat for 50 and a santa doll for 100 tokens.'
        noMsg = 'I\'ll be here when you\'re ready.'
    else
        tradeMsg = 'I accept presents that were stolen from Santa by those little pest Grynch Goblins in exchange for christmas tokens.'
        presentMsg = 'Do you want trade a present bag for a christmas token?'
        gingerMsg = 'Do you want trade a christmas token for a gingerbread man?'
        recipeMsg = 'Do you want trade 10 christmas tokens for a gingerbread man recipe?'
        jewelMsg = 'Do you want trade 25 christmas tokens for a jewel case?'
        hatMsg = 'Do you want trade 50 christmas tokens for a santa hat?'
        dollMsg = 'Do you want trade 100 christmas tokens for a santa doll?'
        hasNoMsg = 'I only want present bags.'
        askMsg = 'I will trade a gingerbread man for 1 token, the gingerbread recipe for 10, a jewel case for 25, a santa hat for 50 and a santa doll for 100 tokens.'
        noMsg = 'I\'ll be here when you\'re ready.'
    end
        if msgcontains(msg, 'items') or msgcontains(msg, 'item') or msgcontains(msg, 'offers') or msgcontains(msg, 'offer') then
            selfSay(tradeMsg)
        elseif msgcontains(msg, 'christmas token') or msgcontains(msg, 'token') or msgcontains(msg, 'xmas token') then
            selfSay(askMsg)
        elseif msgcontains(msg, 'present bag') or msgcontains(msg, 'present') or msgcontains(msg, 'bag') then
            selfSay(presentMsg)
            talk_state = 1
        elseif msgcontains(msg, 'gingerbread man') or msgcontains(msg, 'gingerbread cookie') or msgcontains(msg, 'ginger cookie') then
            selfSay(gingerMsg)
            talk_state = 2
        elseif msgcontains(msg, 'gingerbread recipe') or msgcontains(msg, 'recipe') or msgcontains(msg, 'cookie recipe') then
            selfSay(recipeMsg)
            talk_state = 3
        elseif msgcontains(msg, 'jewel case') or msgcontains(msg, 'case') or msgcontains(msg, 'jewel') or msgcontains(msg, 'jewels') or msgcontains(msg, 'locket') or msgcontains(msg, 'jewel box') then
            selfSay(jewelMsg)
            talk_state = 4
        elseif msgcontains(msg, 'santa hat') or msgcontains(msg, 'santas hat') or msgcontains(msg, 'hat') or msgcontains(msg, 'santa\'s hat') then
            selfSay(hatMsg)
            talk_state = 5
        elseif msgcontains(msg, 'santa doll') or msgcontains(msg, 'santas doll') or msgcontains(msg, 'doll') or msgcontains(msg, 'santa\'s doll') then
            selfSay(dollMsg)
            talk_state = 6
------------------------------------------------ confirm yes ------------------------------------------------
        elseif msgcontains(msg, 'yes') and talk_state == 1 then
            if getPlayerItemCount(cid,6497) >= 1 then
                if doPlayerTakeItem(cid,6497,1) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6527,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 2 then
            if getPlayerItemCount(cid,6527) >= 1 then
                if doPlayerTakeItem(cid,6527,1) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6501,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 3 then
            if getPlayerItemCount(cid,6527) >= 10 then
                if doPlayerTakeItem(cid,6527,10) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6523,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 4 then
            if getPlayerItemCount(cid,6527) >= 25 then
                if doPlayerTakeItem(cid,6527,25) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6104,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 5 then
            if getPlayerItemCount(cid,6527) >= 50 then
                if doPlayerTakeItem(cid,6527,50) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6531,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 6 then
            if getPlayerItemCount(cid,6527) >= 100 then
                if doPlayerTakeItem(cid,6527,100) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6512,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
------------------------------------------------ confirm no ------------------------------------------------
        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay(noMsg)
            talk_state = 0
        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())

dont work, when you sayt christmas token, santa doll, present bag, he ignore you, dont say nothing
 
Back
Top