• 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!

Help with a "Golden Box"

Braah

New Member
Joined
Jul 3, 2017
Messages
11
Reaction score
0
Sup guys, i need a script that when a player uses a certain item he will receive a random reward, it would be nice to be able to set the chance to drop and how many items...

Im using an OTX 3.7... TFS 1.2 (Ty Static_)

Do you know something like that?

Could you help me with that?
 
Last edited:
Solution
Lua:
local rewards = {
    -- {min, max} chance
    [{0, 50}] = {
        {id = 3982, count = 1},
        {id = 2476, count = 1},
        {id = 2479, count = 1},
        {id = 2148, count = {10, 50}}
    },
    [{51, 100}] = {
        {id = 7730, count = 1},
        {id = 2466, count = 1},
        {id = 2497, count = 1},
        {id = 2152, count = {1, 20}}
    },
}


function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local rand = math.random(100)
    for k, v in pairs(rewards) do
        if rand >= k[1] and rand <= k[2] then
            local reward = v[math.random(#v)]
            local count = type(reward.count) == 'table' and math.random(reward.count[1], reward.count[2]) or reward.count...
Code:
rewards = {
    [1] = {id = 2160, count = 1},
    [2] = {id = 2160, count = 5}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local randItem = rewards[math.random(#rewards)]

    player:addItem(randItem.id, randItem.count)
    item:remove(1)
  
    return true
end
 
Lua:
local rewards = {
    -- {min, max} chance
    [{0, 50}] = {
        {id = 3982, count = 1},
        {id = 2476, count = 1},
        {id = 2479, count = 1},
        {id = 2148, count = {10, 50}}
    },
    [{51, 100}] = {
        {id = 7730, count = 1},
        {id = 2466, count = 1},
        {id = 2497, count = 1},
        {id = 2152, count = {1, 20}}
    },
}


function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local rand = math.random(100)
    for k, v in pairs(rewards) do
        if rand >= k[1] and rand <= k[2] then
            local reward = v[math.random(#v)]
            local count = type(reward.count) == 'table' and math.random(reward.count[1], reward.count[2]) or reward.count
            player:addItem(reward.id, count)
            item:remove(1)
            return true
        end
    end
    return true
end
 
Solution
Back
Top