Jump to content
  • 0

ITEM IR DENTRO DE UMA BP


880123

Question

Alguem altera esse script para que o item va dentro de uma bp porfavor ! >.<

 

Citar

local config = {
    monsters = {"The Mega Boss Rox"},
    rewards = {
        {itemID = 2160, chanceToGainInPercent = 3, quantity = 100},
        {itemID = 2148, chanceToGainInPercent = 3, quantity = 100},
    }, 
    effect = 27,
}

-- Função para selecionar um item com base na porcentagem
function selectRandomItem()
    local totalChance = 0

    for _, reward in pairs(config.rewards) do
        totalChance = totalChance + reward.chanceToGainInPercent
    end

    local randomValue = math.random(1, totalChance)
    local cumulativeChance = 0

    for _, reward in pairs(config.rewards) do
        cumulativeChance = cumulativeChance + reward.chanceToGainInPercent

        if randomValue <= cumulativeChance then
            return reward
        end
    end
end


function onKill(cid, target, lastHit)
    if isPlayer(cid) and isMonster(target) then
        
        if getCreatureMaster(target) ~= nil then
            return true
        end

        local monsterNameKilled = getCreatureName(target)

        if isInArray(config.monsters, monsterNameKilled) then            
            local selectedItem = selectRandomItem()
            doPlayerAddItem(cid, selectedItem.itemID, selectedItem.quantity)
            doSendMagicEffect(getCreaturePosition(cid), config.effect)
            doBroadcastMessage("Mataram o boss.", 19)
        end 
        
    end
    return true
end

function onLogin(cid)
    registerCreatureEvent(cid, "killTheBoss")
    return true
end

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0
local config = {
    monsters = {"The Mega Boss Rox"},
    rewards = {
        {itemID = 2160, chanceToGainInPercent = 3, quantity = 100},
        {itemID = 2148, chanceToGainInPercent = 3, quantity = 100},
    }, 
    effect = 27,
    backpackID = 1988, -- ID da Backpack
}

-- Função para selecionar um item com base na porcentagem
function selectRandomItem()
    local totalChance = 0

    for _, reward in pairs(config.rewards) do
        totalChance = totalChance + reward.chanceToGainInPercent
    end

    local randomValue = math.random(1, totalChance)
    local cumulativeChance = 0

    for _, reward in pairs(config.rewards) do
        cumulativeChance = cumulativeChance + reward.chanceToGainInPercent

        if randomValue <= cumulativeChance then
            return reward
        end
    end
end


function onKill(cid, target, lastHit)
    if isPlayer(cid) and isMonster(target) then
        
        if getCreatureMaster(target) ~= nil then
            return true
        end

        local monsterNameKilled = getCreatureName(target)

        if isInArray(config.monsters, monsterNameKilled) then            
            local selectedItem = selectRandomItem()
            local backpack = doPlayerAddItem(cid, config.backpackID, 1)
            if backpack ~= RETURNVALUE_NOERROR then
                local item = doCreateItemEx(selectedItem.itemID, selectedItem.quantity)
                doAddContainerItem(backpack, item)
                doSendMagicEffect(getCreaturePosition(cid), config.effect)
                doBroadcastMessage("Mataram o boss.", 19)
            else
                doPlayerAddItem(cid, selectedItem.itemID, selectedItem.quantity)
                doSendMagicEffect(getCreaturePosition(cid), config.effect)
                doBroadcastMessage("Mataram o boss.", 19)
            end
        end 
        
    end
    return true
end

function onLogin(cid)
    registerCreatureEvent(cid, "killTheBoss")
    return true
end

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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