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

Solved Npc not working as should

Ray Rewind

Doctor
Joined
Jun 6, 2009
Messages
1,349
Reaction score
77
Location
Germany
Hey I try to make an NPC which trades certain amount of items for another item


Code:
16:10 GOD Rewind [500]: enchanted chicken wing
16:10 Yaman: Are you sure you would like to trade your boots of haste for an enchanted chicken wing?
16:10 GOD Rewind [500]: yes
16:10 Yaman: Sorry, you do not have four Warrior Helmets.


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

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

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
   
    if msgcontains(msg, "warrior's sweat") then
        if getPlayerItemCount(cid, 2475) >= 4 then
            npcHandler:say("Are you sure you would like to trade {four} or your helmet's for a {flask of warrior's sweat}?", cid)
            talkState[talkUser] = 1
        else
            npcHandler:say("Sorry, you do not have {four} Warrior Helmets.", cid)
            talkState[talkUser] = 0
        end
    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
        if getPlayerItemCount(cid, 2475) >= 4 then
            doPlayerRemoveItem(cid, 2475, 4)
            npcHandler:say("Here you are.", cid)
            doPlayerAddItem(cid, 5885, 1)
            talkState[talkUser] = 0
        else
            npcHandler:say("Sorry, you do not have {four} Warrior Helmets.", cid)
            talkState[talkUser] = 0
        end
    elseif msgcontains(msg, "no") then
        npcHandler:say("Then not.", cid)
        talkState[talkUser] = 0

   
   
    elseif msgcontains(msg, "enchanted chicken wing") then
        if getPlayerItemCount(cid, 2195) >= 1 then
            npcHandler:say("Are you sure you would like to trade your boots of haste for an {enchanted chicken wing}?", cid)
            talkState[talkUser] = 1
        else
            npcHandler:say("Sorry, you do not have a pair of Boots of Haste.", cid)
            talkState[talkUser] = 0
        end
    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
        if getPlayerItemCount(cid, 2195) >= 1 then
            doPlayerRemoveItem(cid, 2195, 1)
            npcHandler:say("Here you are.", cid)
            doPlayerAddItem(cid, 5891, 1)
            talkState[talkUser] = 0
        else
            npcHandler:say("Sorry, you do not have a pair of Boots of Haste.", cid)
            talkState[talkUser] = 0
        end
    elseif msgcontains(msg, "no") then
        npcHandler:say("Then not.", cid)
        talkState[talkUser] = 0


    elseif msgcontains(msg, "fighting spirit") then
        if getPlayerItemCount(cid, 2498) >= 2 then
            npcHandler:say("Are you sure you would like to trade {two} royal helmets for a {fighting spirit}?", cid)
            talkState[talkUser] = 1
        else
            npcHandler:say("Sorry, you do not have {two} Royal Helmets.", cid)
            talkState[talkUser] = 0
        end
    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
        if getPlayerItemCount(cid, 2498) >= 2 then
            doPlayerRemoveItem(cid, 2498, 2)
            npcHandler:say("Here you are.", cid)
            doPlayerAddItem(cid, 8182, 1)
            talkState[talkUser] = 0
        else
            npcHandler:say("Sorry, you do not have {two} Royal Helmets.", cid)
            talkState[talkUser] = 0
        end
    elseif msgcontains(msg, "no") then
        npcHandler:say("Then not.", cid)
        talkState[talkUser] = 0
    end
   
    return true
end
   
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
i have map tibia real full But ... Npc and quest not work :((
Most often distributions only come with the map 90%.. with maybe 60% of the spawns... and little to no working npc's. (real life map)
It's a clean slate so you can make tibia as you want it to be.
I know that the 1.0 or 1.1 has most working quests and npc's however I'm unsure of the map they use.
Either way you'll never get a fully working copy of real tibia unless someone puts in a tremendous amount of work, and then distributes it.
 
Back
Top