• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

RevScripts help revscript merge same items with % to die and lose item

miguelshta

Member
Joined
Mar 21, 2009
Messages
351
Solutions
1
Reaction score
13
Location
Toronto, Canada
hello i wanted to create a good action: like

item: Mind stone id: 3062 and if u have mind stone + 2 wands same type like 2 wands of inferno u can merge them and gain stats like + 10 fire damange but with 50% to die and destroy the both items
 
Solution
View attachment bandicam 2022-02-14 05-10-44-985.mp4

Use mindstone on wand of inferno -> mindstone + 2 wand of inferno are removed. 50% chance of gaining wand of everblazing.

add more combinations to the table if you like.
Lua:
local mindstoneId = 2178

local config = {
    [2187] = {2, 18409, 50},  -- [wand_of_inferno]  = {amountRequired, wand_of_everblazing, chanceOfFailing}
    --[1111] = {2, 3333, 50}, -- [itemToBeCombined] = {amountRequired, itemTheyTurnInto, chanceOfFailing/100}
    --[1111] = {2, 3333, 50}
}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not target then
        return true
    end
    local targetId = target:getId()
    local index = config[targetId]
    if not index then
        player:sendCancelMessage("This item cannot be...
View attachment bandicam 2022-02-14 05-10-44-985.mp4

Use mindstone on wand of inferno -> mindstone + 2 wand of inferno are removed. 50% chance of gaining wand of everblazing.

add more combinations to the table if you like.
Lua:
local mindstoneId = 2178

local config = {
    [2187] = {2, 18409, 50},  -- [wand_of_inferno]  = {amountRequired, wand_of_everblazing, chanceOfFailing}
    --[1111] = {2, 3333, 50}, -- [itemToBeCombined] = {amountRequired, itemTheyTurnInto, chanceOfFailing/100}
    --[1111] = {2, 3333, 50}
}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not target then
        return true
    end
    local targetId = target:getId()
    local index = config[targetId]
    if not index then
        player:sendCancelMessage("This item cannot be combined.")
        return true
    end
    if player:getItemCount(targetId) < index[1] then
        player:sendCancelMessage("Not enough materials to combine. (Requires: " .. index[1] .. " " .. ItemType(targetId):getName() .. " in inventory)")
        return true
    end
    item:remove(1)
    player:removeItem(targetId, index[1])
    if math.random(100) <= index[3] then
        player:say("Failed.", TALKTYPE_MONSTER_SAY)
        return true
    end
    player:say("Succeeded!", TALKTYPE_MONSTER_SAY)
    player:addItem(index[2], 1, true)
    return true
end

action:id(mindstoneId)
action:register()
 
Solution
it looks perfect @Xikini thank you <3
Post automatically merged:

View attachment 65526

Use mindstone on wand of inferno -> mindstone + 2 wand of inferno are removed. 50% chance of gaining wand of everblazing.

add more combinations to the table if you like.
Lua:
local mindstoneId = 2178

local config = {
    [2187] = {2, 18409, 50},  -- [wand_of_inferno]  = {amountRequired, wand_of_everblazing, chanceOfFailing}
    --[1111] = {2, 3333, 50}, -- [itemToBeCombined] = {amountRequired, itemTheyTurnInto, chanceOfFailing/100}
    --[1111] = {2, 3333, 50}
}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not target then
        return true
    end
    local targetId = target:getId()
    local index = config[targetId]
    if not index then
        player:sendCancelMessage("This item cannot be combined.")
        return true
    end
    if player:getItemCount(targetId) < index[1] then
        player:sendCancelMessage("Not enough materials to combine. (Requires: " .. index[1] .. " " .. ItemType(targetId):getName() .. " in inventory)")
        return true
    end
    item:remove(1)
    player:removeItem(targetId, index[1])
    if math.random(100) <= index[3] then
        player:say("Failed.", TALKTYPE_MONSTER_SAY)
        return true
    end
    player:say("Succeeded!", TALKTYPE_MONSTER_SAY)
    player:addItem(index[2], 1, true)
    return true
end

action:id(mindstoneId)
action:register()
encontered an error:

Lua:
timerEvent: []
 callbackId:[]
function: []
error [C++ exception]
Post automatically merged:

my bad wrong item id it worked perfectly well
 
Last edited:
Back
Top