Ir para conteúdo

Featured Replies

Postado

Algum mago da programação por gentileza poderia me ajudar com o npc de promotion?

Gostaria que após ele dar a promotion o player seja teleportado para um outro local, e se possível eu escolher a posição no script.



local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
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
 
local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to be promoted in your vocation for 20000 gold?'})
node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 1, level = 200, promotion = 1, text = 'Congratulations! You are now promoted.'})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
 
npcHandler:addModule(FocusModule:new())

Postado
Em 01/11/2015 14:04:52, BrunoLeo disse:

Gostaria que após ele dar a promotion o player seja teleportado para um outro local, e se possível eu escolher a posição no script.

 

OK.

Substitua a função StdModule.promotePlayer do arquivo modules.lua (data\npc\lib\npcsystem) por essa:

 

function StdModule.promotePlayer(cid, message, keywords, parameters, node)
    local npcHandler = parameters.npcHandler
    
    if(npcHandler == nil) then
        return print('[Warning - ' .. getCreatureName(getNpcId()) .. '] NpcSystem:', 'StdModule.promotePlayer - Call without any npcHandler instance.') and false
    end

 

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

 

    if(isPremium(cid) or not getBooleanFromString(getConfigValue('premiumForPromotion'))) then
        if(getPlayerPromotionLevel(cid) >= parameters.promotion) then
            npcHandler:say('You are already promoted!', cid)
        elseif(getPlayerLevel(cid) < parameters.level) then
            npcHandler:say('I am sorry, but I can only promote you once you have reached level ' .. parameters.level .. '.', cid)
        elseif(not doPlayerRemoveMoney(cid, parameters.cost)) then
            npcHandler:say('You do not have enough money!', cid)
        else
            doPlayerSetPromotionLevel(cid, parameters.promotion)
            doTeleportThing(cid, parameters.pos)
            doSendMagicEffect(parameters.pos, CONST_ME_TELEPORT)
            npcHandler:say(parameters.text, cid)
        end
    else
        npcHandler:say("You need a premium account in order to get promoted.", cid)
    end

 

    return npcHandler:resetNpc(cid)
end

 

 

 

E o script do NPC por esse:

 

local destiny = {x = 123, y = 456, z = 7}
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

 

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 onPlayerEndTrade(cid)                npcHandler:onPlayerEndTrade(cid)            end
function onPlayerCloseChannel(cid)            npcHandler:onPlayerCloseChannel(cid)        end

 

local node = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to be promoted in your vocation for 20000 gold?'})
    node:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 1, level = 200, promotion = 1, pos = destiny, text = 'Congratulations! You are now promoted.'})
    node:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})

 

npcHandler:addModule(FocusModule:new())

 

PS: o botão de <code> está indisponível via mobile

Editado por Wise (veja o histórico de edições)

The corrupt fear us.

The honest support us.

The heroic join us.

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo