Jump to content
Close
bpm91

Scripting Storage npc barco

Recommended Posts

olá, estou com um pequeno problema pra primeira missao da postman, o npc manda eu viajar de barco e dps retornar nele. bom esse script após viajar e retornar ao npc ele nao reconhece o storage, ele manda eu fazer a missao, então o que acontece é, se eu mudar a palavra carlin por carlim, ele entende, mas se eu falar carlin ele me faz viajar e nao me da a storage. alguem sabe solucionar isso?
 

Spoiler

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
local Topic = {}
local storage = 100167
local storage2 = 100168
 
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


        
        -- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
        
    local travelNode = keywordHandler:addKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to {Carlin} for 110 gold coins?'})
            travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 0, cost = 110, destination = {x=32387, y=31820, z=7} })
            travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'We would like to serve you some time.'})
        
    local travelNode = keywordHandler:addKeyword({'ab\'dendriel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to {Ab\'dendriel} for 130 gold coins?'})
            travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 0, cost = 130, destination = {x=32734, y=31668, z=7} })
            travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'We would like to serve you some time.'})
        
    local travelNode = keywordHandler:addKeyword({'edron'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to {Edron} for 160 gold coins?'})
            travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 160, destination = {x=33178, y=31766, z=7} })
            travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'We would like to serve you some time.'})
            
            local travelNode = keywordHandler:addKeyword({'venore'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to {Venore} for 170 gold coins?'})
            travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 0, cost = 170, destination = {x=32959, y=32021, z=7} })
            travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'We would like to serve you some time.'})
        
    local travelNode = keywordHandler:addKeyword({'port hope'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to {Port Hope} for 160 gold coins?'})
            travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 160, destination = {x=32532, y=32783, z=7} })
            travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'We would like to serve you some time.'})
       
        keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Edron}, {Venore} or {Port Hope}.'})
        keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I am the {captain} of this ship.'})
        keywordHandler:addKeyword({'captain'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I am the captain of this ship.'})

function greetCallback(cid)
    Topic[cid] = 0
    return true
end

local carlin_cost = 110

function creatureSayCallback(cid, type, msg)
        if (not npcHandler:isFocused(cid)) then return false end
    if (msgcontains(msg, 'no') and Topic[cid] >= 1) then
        npcHandler:say("We would like to serve you some time.",cid)
        Topic[cid] = 0
    end             
            
    if (msgcontains(msg, "carlin") and getPlayerStorageValue(cid,storage) == 1 and getPlayerStorageValue(cid,storage2) == -1) then
           npcHandler:say("Do you want to sail to Carlin for 110 gold coins?",cid)
        Topic[cid] = 1
    elseif (Topic[cid] == 1) then
    if (msgcontains(msg, 'yes') and doPlayerRemoveMoney(cid,carlin_cost) and Topic[cid] == 1) then
        doTeleportThing(cid,{x=32387, y=31820, z=7})
        doSendMagicEffect({x=32387, y=31820, z=7},CONST_ME_TELEPORT)
        setPlayerStorageValue(cid,storage2, 1)
        setPlayerStorageValue(cid,100171,3)
    else
        npcHandler:say("You dont have enough of gold.",cid)
        end
    end
    if (msgcontains(msg, "carlin")) and (getPlayerStorageValue(cid,storage) == -1) then
           npcHandler:say("Do you want to sail to Carlin for 110 gold coins?",cid)
        Topic[cid] = 2
      elseif (Topic[cid] == 2) then
    if (msgcontains(msg, 'yes') and doPlayerRemoveMoney(cid,carlin_cost) and Topic[cid] == 2) then
        doTeleportThing(cid,{x=32387, y=31820, z=7})
        doSendMagicEffect({x=32387, y=31820, z=7},CONST_ME_TELEPORT)
    else
        npcHandler:say("You dont have enough of gold.",cid)
        end
    end
    if (msgcontains(msg, "carlin")) and (getPlayerStorageValue(cid,storage) >= 1 and getPlayerStorageValue(cid,storage2) >= 1) then
           npcHandler:say("Do you want to sail to Carlin for 110 gold coins?",cid)
        Topic[cid] = 3
      elseif (Topic[cid] == 3) then
    if (msgcontains(msg, 'yes') and doPlayerRemoveMoney(cid,carlin_cost) and Topic[cid] == 3) then
        doTeleportThing(cid,{x=32387, y=31820, z=7})
        doSendMagicEffect({x=32387, y=31820, z=7},CONST_ME_TELEPORT)
    else
        npcHandler:say("You dont have enough of gold.",cid)
        end
    end    
    return true    
end
       

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 


Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


Open Tibia Server

Quer aprender a criar seu próprio servidor de Tibia? Então está no lugar certo, aqui você encontrará milhares de tutorias, scripts, códigos, mapas e utilitários para que você possa fazer o seu próprio servidor de Tibia partindo do zero.

Redes Sociais

Anuncie no Tibia King

Precisa de mais visibilidade em seus projetos? Quer publicidade para o seu servidor? Anuncie no Tibia King e faça sua divulgação, possuímos centenas de acessos simultâneos e milhares diários, com certeza será a sua solução! A publicação do seu anuncio é instantânea!

×
×
  • Create New...