Jump to content
  • 0

[OTX - 8.64] Pergaminho de Boost Skill


BrunoBrilha

Question

Queria que o player ao usar o pergaminho ele ganhasse 50% de velocidade para  upar as skill por 7 dias (item consumível).

 

Se possivel: 

Pergaminho: Magic Leve

Pergaminho: Fist, Club, Sword, Axe, Distance

Pergaminho: Shielding

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
local scrolls = {
    ["Magic Level Scroll"] = {skill = SKILL__MAGLEVEL, duration = 7, multiplier = 1.5},
    ["Fist Fighting Scroll"] = {skill = SKILL__FIST, duration = 7, multiplier = 1.5},
    ["Club Fighting Scroll"] = {skill = SKILL__CLUB, duration = 7, multiplier = 1.5},
    ["Sword Fighting Scroll"] = {skill = SKILL__SWORD, duration = 7, multiplier = 1.5},
    ["Axe Fighting Scroll"] = {skill = SKILL__AXE, duration = 7, multiplier = 1.5},
    ["Distance Fighting Scroll"] = {skill = SKILL__DISTANCE, duration = 7, multiplier = 1.5},
    ["Shielding Scroll"] = {skill = SKILL__SHIELD, duration = 7, multiplier = 1.5}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local scroll = scrolls[itemEx.itemid]
    if scroll then
        if not doPlayerAddSkillTry(cid, scroll.skill, 0) then
            doPlayerSendCancel(cid, "You already have this skill at maximum.")
            return true
        end

        if doPlayerAddSkill(cid, scroll.skill, scroll.multiplier * getPlayerSkillLevel(cid, scroll.skill)) then
            doRemoveItem(item.uid)
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have received a boost of " .. tostring(scroll.multiplier * 100) .. "% to your " .. getItemNameById(itemEx.itemid) .. " skill for 7 days.")
            setPlayerStorageValue(cid, 1000 + scroll.skill, 1)
            addEvent(function(cid, skill)
                if isPlayer(cid) then
                    doPlayerRemoveSkill(cid, skill)
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your boost to " .. getItemNameById(itemEx.itemid) .. " skill has worn off.")
                    setPlayerStorageValue(cid, 1000 + skill, -1)
                end
            end, scroll.duration * 24 * 3600 * 1000, cid, scroll.skill)
        else
            doPlayerSendCancel(cid, "You cannot use this item right now.")
        end
    end
    return true
end

 

Link to comment
Share on other sites

  • 0
Posted (edited)

o mano brigado mesmo de coração, tinha abandonado o projeto um tempo voltei so agora, muito bom obrigado pelo conteudo! vou utilizar ele brigado mesmo!


So uma coisa

 

isso seria um action ou uma lib? 

nao funcionou, e tambem nao deu erro, deve ser pq nao entendi mas vlw

Edited by BrunoBrilha
Link to comment
Share on other sites

  • 0

Testa assim:

 

local scrolls = {
    [1234] = {skill = SKILL__MAGLEVEL, duration = 7, multiplier = 1.5}, -- Substitua 1234 pelo ID do item do scroll de Magia
    [5678] = {skill = SKILL__FIST, duration = 7, multiplier = 1.5}, -- Substitua 5678 pelo ID do item do scroll de Luta de Punhos
    -- Adicione mais entradas conforme necessário para outros scrolls
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local scroll = scrolls[item:getId()]
    if scroll then
        if not player:addSkillTry(scroll.skill, 0) then
            player:sendCancelMessage("You already have this skill at maximum.")
            return true
        end

        if player:addSkill(scroll.skill, scroll.multiplier * player:getSkillLevel(scroll.skill)) then
            item:remove(1)
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have received a boost of " .. tostring(scroll.multiplier * 100) .. "% to your " .. getItemNameById(item:getId()) .. " skill for 7 days.")
            player:setStorageValue(1000 + scroll.skill, 1)
            addEvent(function(cid, skill)
                local player = Player(cid)
                if player then
                    player:removeSkill(skill)
                    player:sendTextMessage(MESSAGE_INFO_DESCR, "Your boost to " .. getItemNameById(item:getId()) .. " skill has worn off.")
                    player:setStorageValue(1000 + skill, -1)
                end
            end, scroll.duration * 24 * 3600 * 1000, player:getId(), scroll.skill)
        else
            player:sendCancelMessage("You cannot use this item right now.")
        end
    end
    return true
end


E leva algumas coisas em consideraçao tambem, por exemplo:

1.Variáveis Globais:  SKILL__MAGLEVEL, SKILL__FIST, SKILL__CLUB, SKILL__SWORD, SKILL__AXE, SKILL__DISTANCE, SKILL__SHIELD, MESSAGE_INFO_DESCR, CONST_ME_MAGIC_BLUE e getPlayerSkillLevel realmente existem no seu servidor?

2. O seu servidor usa a função doPlayerAddSkillTry?

3.Certifique-se de que todas as variáveis e funções utilizadas no script estejam corretamente definidas e disponíveis.

4.Verificação de item inválido: Adicione uma verificação para garantir que o itemEx não seja nil antes de acessar itemEx.itemid. Isso evitará um possível erro caso o script seja acionado com um itemEx inválido.

+- nessa pegada:

 

local scrolls = {
    [1234] = {skill = SKILL__MAGLEVEL, duration = 7, multiplier = 1.5}, -- Substitua 1234 pelo ID do item do scroll de Magia
    [5678] = {skill = SKILL__FIST, duration = 7, multiplier = 1.5}, -- Substitua 5678 pelo ID do item do scroll de Luta de Punhos
    -- Adicione mais entradas conforme necessário para outros scrolls
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local itemEx = target
    if not itemEx or not itemEx:isItem() then
        return false
    end

    local scroll = scrolls[itemEx:getId()]
    if scroll then
        if not player:addSkillTry(scroll.skill, 0) then
            player:sendCancelMessage("You already have this skill at maximum.")
            return true
        end

        if player:addSkill(scroll.skill, scroll.multiplier * player:getSkillLevel(scroll.skill)) then
            item:remove(1)
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have received a boost of " .. tostring(scroll.multiplier * 100) .. "% to your " .. getItemNameById(item:getId()) .. " skill for 7 days.")
            player:setStorageValue(1000 + scroll.skill, 1)
            addEvent(function(cid, skill)
                local player = Player(cid)
                if player then
                    player:removeSkill(skill)
                    player:sendTextMessage(MESSAGE_INFO_DESCR, "Your boost to " .. getItemNameById(item:getId()) .. " skill has worn off.")
                    player:setStorageValue(1000 + skill, -1)
                end
            end, scroll.duration * 24 * 3600 * 1000, player:getId(), scroll.skill)
        else
            player:sendCancelMessage("You cannot use this item right now.")
        end
    end
    return true
end

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...