Ir para conteúdo
  • 0

NPC Promotion/Reset


CaraiDeNome

Pergunta

Olá, gostaria de saber se alguém tem um script de algum npc que ao pegar promotion com ele reseta o level do player.

 

Exemplo:  Knight Level 200 pega promotion pra Elite Knight (Ele Voltaria Level 8, Com HP, MANA e CAP de Level 8 )

 

Acho que deu pra intender.

 

 

@edit

Eu consegui um script mas ta dando um erro.

erro que está dando é esse

Spoiler

npc.jpg

 

o script que to usando é esse

Spoiler

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


--Config
local cost = 2000000
local level = 200
local needPremium = true --If the player will need premium account
local promotionNumber = 1
local basics = { --Adjust the level 8 stats
    health = 185,
    mana = 35,
    cap = 400
}
local willTeleport = false --will the player be teleported to his town?
local willLogout = false -- will the player be forced to logout?


--/Config

local function getExpForLevel(level)
    level = level - 1
    return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3
end

local function doPromote(cid)
    if player:getStorageValue(Storage.Promotion) == promotionNumber then
        npcHandler:say("You are already promoted!", cid)
    elseif player:getStorageValue(Storage.Promotion) == 1 and promotionNumber == 2 then
        npcHandler:say("You need the first promotion!", cid)
    else
        player:setStorageValue(Storage.Promotion, promotionNumber)
        player:setVocation(player:getVocation():getPromotion())
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
        npcHandler:say("Congratulations! You are now promoted.", cid)
        player:setMaxHealth(basics.health)
        player:setMaxMana(basics.mana)
        player:setCapacity(basics.cap)
        player:removeExperience(player:getExperience() - getExpForLevel(8), false)
        npcHandler.topic[cid] = 0
        if willTeleport then
            player:teleportTo(player:getTown():getTemplePosition())
        end
        if willLogout then
            player:remove()
        end
    end
end

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 function greetCallback(cid)
    npcHandler.topic[cid] = 0
    return true
end

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

    elseif msgcontains(msg, "promotion") and npcHandler.topic[cid] == 0 then
        npcHandler:say({"Do you want to be promoted?"}, cid)
        npcHandler.topic[cid] = 1

    elseif npcHandler.topic[cid] == 1 and msgcontains(msg, "yes") then

        if player:getLevel()<level then
            npcHandler:say({"You need level " .. level .. " to be promoted."}, cid)
            npcHandler.topic[cid] = 0
        elseif needPremium and not player:isPremium() then
            npcHandler:say({"You need a premium account to be promoted."}, cid)
            npcHandler.topic[cid] = 0
        elseif player:removeMoneyNpc(cost) then
            doPromote(cid)
        else
            npcHandler:say({"You can\'t be promoted."}, cid)
            npcHandler.topic[cid] = 0
        end

    elseif npcHandler.topic[cid] == 1 and msgcontains(msg, "no") then
        npcHandler:say({"Then no."}, cid)
        npcHandler.topic[cid] = 0
    end
    
    return true
end


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

 

Alguém pode me ajuda com isso ?

 

Agradeço deis de já.

Obrigado.

npc.jpg.20f2ba13e0e62229f734f590eba7e777.jpg

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

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

×
×
  • Criar Novo...