• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Unrealized tfs 1.2 request

Here is something you can work on.
Code:
local config = {
    fromPosition = Position(1000, 1000, 7),
    toPosition = Position(1100, 1100, 7),
    rewards = {
        {chance = {from = 0, to = 30.5}, message = 'You try to concentrate and your dream comes true. You wished for something cool.', itemId = 123, count = 2},
        {chance = {from = 30.5, to = 60}, message = 'You try to concentrate and your dream comes true. You wished for something cool.', itemId = 123, count = 2},
        {chance = {from = 60, to = 100}, message = 'You try to concentrate and your dream comes true. You wished for something cool.', itemId = 123, count = 2},
    }
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not isInRange(player:getPosition(), config.fromPosition, config.toPosition) then
        return false
    end

    local chance = math.random(0, 10000) / 100
    for _, reward in ipairs(config.rewards) do
        if chance >= reward.chance.from and chance < reward.chance.to then
            player:addItem(reward.itemId, reward.count)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, reward.message)
            item:remove(1)
            return true
        end
    end

    return true
end
 
Back
Top