Ir para conteúdo
  • 0

Colocando npc para viajar se tiver tal reset


julhinhuu

Pergunta

Olá galera do XT,

 

Alguem poderia me ajudar com 1 npc que só viaja se tiver tantos reset?

o npc é esse:

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
   

    
-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
local travelNode = keywordHandler:addKeyword({'mandagascar'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 0, cost = 450, destination = {x=32215, y=31116, z=7} })

    -- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())

e o meu sistema de reset e pela DB com site.

 

Link para o comentário
Compartilhar em outros sites

7 respostass a esta questão

Posts Recomendados

  • 0
  Em 31/03/2016 em 01:17, TheSumm disse:

Posta a lib dos npcs.

  Mostrar conteúdo oculto

 

Editado por julhinhokullitz
Link para o comentário
Compartilhar em outros sites

  • 0

em /data/lib/core/player.lua adicione isso no final do script :

function Player.getResets(self)
    local result = db.storeQuery("SELECT `resets` FROM `players` WHERE `id` = ".. self:getId())
    if result == false then
        resets = 0
    else
        resets = result
    end
    return resets 
end

agora em /data/npc/lib/npcsystem/modules.lua troque seu Stdmodule.travel por esse :

function StdModule.travel(cid, message, keywords, parameters, node)
        local npcHandler = parameters.npcHandler
        if npcHandler == nil then
            error("StdModule.travel called without any npcHandler instance.")
        end

        if not npcHandler:isFocused(cid) then
            return false
        end

        local player = Player(cid)
        if player:isPremium() or not parameters.premium then
            if player:isPzLocked() then
                npcHandler:say("First get rid of those blood stains! You are not going to ruin my vehicle!", cid)
            elseif parameters.level and player:getLevel() < parameters.level then
                npcHandler:say("You must reach level " .. parameters.level .. " before I can let you go there.", cid)
            elseif not player:removeMoney(parameters.cost) then
                npcHandler:say("You don't have enough money.", cid)
            elseif player:getResets() < parameters.reset then
                 npcHandler:say("You must reach reset " .. parameters.reset .. " before I can let you go there.", cid)
            else
                npcHandler:say(parameters.msg or "Set the sails!", cid)
                npcHandler:releaseFocus(cid)

                local destination = Position(parameters.destination)
                local position = player:getPosition()
                player:teleportTo(destination)

                position:sendMagicEffect(CONST_ME_TELEPORT)
                destination:sendMagicEffect(CONST_ME_TELEPORT)
            end
        else
            npcHandler:say("I'm sorry, but you need a premium account in order to travel onboard our ships.", cid)
        end
        npcHandler:resetNpc(cid)
        return true
    end

Pronto para usar, adicione o parametro reset= numero de resets.

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...