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

TFS 1.X+ Lucky Roulette

Pifafa

Active Member
Joined
Nov 9, 2010
Messages
100
Reaction score
39
Hello everyone, today I post my casino system for everyone who would like to have one working, despite everything there is a small bug, the person cannot log out when running the casino otherwise there may be a crash. Reminding everyone I use TFS 1.2
LUA:
local config = {
    effect = 28, -- efeito em cima do jogador
    effectReward = 31, -- efeito em cima do prêmio
    effectLever = 10, -- efeito em cima da alavanca
    eventCoin = 6064, -- valor para jogar = id do item
    qtdCoin = 1, -- quantidade do coin para jogar
    lose = true, -- se irá ter a opção de não ganhar nada
    itemLose = 3035, -- id do item que representará a perda (Obs: não se esqueça de adicioná-lo à lista de items)
    effectLose = 5, -- efeito em cima do prêmio quando perder
    exaust = 10.0, -- Segundos de exaust
    storage = 23113, -- Storage do exaust
    used_storage = 23114, -- Storage para verificar se a roleta está sendo usada
    used = 10,
    poss = {
        [1] = {x = 6001, y = 6044, z = 4}, -- Coordenada da POS1 no Map Editor
        [2] = {x = 6000, y = 6044, z = 4}, -- Coordenada da POS2 no Map Editor
        [3] = {x = 5999, y = 6044, z = 4}, -- Coordenada da POS3 no Map Editor - local do prêmio
        [4] = {x = 5998, y = 6044, z = 4}, -- Coordenada da POS4 no Map Editor
        [5] = {x = 5997, y = 6044, z = 4}  -- Coordenada da POS5 no Map Editor
    },
    items = { -- id = id do item - chance = chance de aparecer o item - count = a quantidade que a pessoa irá ganhar
[1] = {id = 3390, chance = 1, count = 1},    -- A Horned Helmet
[2] = {id = 3393, chance = 1, count = 1},    -- An Amazon Helmet
[3] = {id = 5701, chance = 1, count = 1},    -- A Angelical Helmet
[4] = {id = 5718, chance = 1, count = 1},    -- A Longhorn Helmet
[5] = {id = 5768, chance = 1, count = 1},    -- A Old Golden Helmet
[6] = {id = 5704, chance = 1, count = 1},    -- A Picon Helmet
[7] = {id = 6076, chance = 1, count = 1},    -- Helmet Of Eternal Flames
[8] = {id = 5994, chance = 1, count = 1},    -- A Vip Knight Helmet III
[9] = {id = 5990, chance = 1, count = 1},    -- A Vip Mages Legs III
[10] = {id = 5995, chance = 1, count = 1},   -- A Vip Mages Cape III
[11] = {id = 5992, chance = 1, count = 1},   -- A Vip Mages Helmet III
[12] = {id = 5993, chance = 1, count = 1},   -- A Vip Knight Legs III
[13] = {id = 5989, chance = 1, count = 1},   -- A Vip Knight Cape III
[14] = {id = 5997, chance = 1, count = 1},   -- A Wand of Vips III
[15] = {id = 5991, chance = 1, count = 1},   -- A Vip Paladin Helmet III
[16] = {id = 3035, chance = 35, count = 100}   -- platinum coin quando perde 3223
    }
}

local slot1, slot2, slot3, slot4, slot5

local function cleanTile(item, i)
    doCleanTile(config.poss[i], true)
    doCreateItem(item, 1, config.poss[i])
end

local function raffle(item)
    if slot4 ~= nil then
        slot5 = slot4
        cleanTile(2342, 5)
        doCreateItem(slot5.id, slot5.count, config.poss[5])
    end
    if slot3 ~= nil then
        slot4 = slot3
        cleanTile(2342, 4)
        doCreateItem(slot4.id, slot4.count, config.poss[4])
    end
    if slot2 ~= nil then
        slot3 = slot2
        cleanTile(2317, 3)
        doCreateItem(slot3.id, slot3.count, config.poss[3])
    end
    if slot1 ~= nil then
        slot2 = slot1
        cleanTile(2342, 2)
        doCreateItem(slot2.id, slot2.count, config.poss[2])
    end
    slot1 = {id = item.id, count = item.count}
    cleanTile(2342, 1)
    doCreateItem(slot1.id, slot1.count, config.poss[1])
end

local function result(uid)
    if isPlayer(uid) then
        if config.lose and slot3.id == config.itemLose then
            doSendMagicEffect(getCreaturePosition(uid), CONST_ME_POFF)
            doSendMagicEffect(config.poss[3], config.effectLose)
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE,
                                    "[ROULETTE] Que azar, tente de novo!")
        else
            doSendMagicEffect(getCreaturePosition(uid), config.effect)
            doSendMagicEffect(config.poss[3], config.effectReward)
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE,
                                    "[ROULETTE] Você ganhou " .. slot3.count .. " " .. getItemName(slot3.id) .. ". Parabéns!")
            broadcastMessage("[ROULETTE]: O jogador " .. getPlayerName(uid) .. " ganhou " .. slot3.count .. " " .. getItemName(slot3.id) .. ". Parabéns!", MESSAGE_STATUS_WARNING)
            doPlayerAddItem(uid, slot3.id, slot3.count)

            -- Armazena os dados do vencedor no banco de dados
            local playerName = getPlayerName(uid)
            local itemName = getItemName(slot3.id)
            local itemCount = slot3.count
            local itemId = slot3.id  -- Adiciona o ID do item

            db.query("INSERT INTO roulette_winners (player_name, item_name, item_id, item_count) VALUES ('" .. playerName .. "', '" .. itemName .. "', " .. itemId .. ", " .. itemCount .. ");")
        end
    end
end

-- para funciona precisa disso criar a tabela do script para conecta ao site:
--   CREATE TABLE roulette_winners (
--    id INT AUTO_INCREMENT PRIMARY KEY,
--    player_name VARCHAR(255),
--   item_name VARCHAR(255),
--    item_count INT,
--    win_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
--   );

function onUse(cid, item, pos, itemEx, posEx)
    if item.itemid == 2772 then
        doTransformItem(item.uid, item.itemid + 1)
    elseif item.itemid == 2773 then
        doTransformItem(item.uid, item.itemid - 1)
    end

    if getGlobalStorageValue(config.used_storage) <= os.time() then
        if not exhaustion.check(cid, config.storage) then
            if getPlayerItemCount(cid, config.eventCoin) >= config.qtdCoin then
                local rand = math.random(10, 30)
                doSendMagicEffect(pos, config.effectLever)
                setGlobalStorageValue(config.used_storage, rand + 5 + os.time())
                exhaustion.set(cid, config.storage, rand)
                doPlayerRemoveItem(cid, config.eventCoin, config.qtdCoin)
                local loop = 0
                slot1, slot2, slot3, slot4, slot5 = nil, nil, nil, nil, nil

                for i = 1, #config.poss do
                    if i == 3 then
                        cleanTile(2317, i)
                    else
                        cleanTile(2342, i)
                    end
                end

                while rand >= loop do
                    local roll = math.random(1, 100)
                    local index = math.random(#config.items)
                    if roll <= config.items[index].chance then
                        local item = config.items[index]
                        loop = loop + 1
                        addEvent(function() raffle(item) end, loop * 1000)
                    end
                end
                addEvent(function() result(cid) end, (rand + 2) * 1000)
            else
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,
                                        "[ROULETTE] Você deve ter " .. config.qtdCoin .. " " .. getItemName(config.eventCoin) .. " na mochila!")
            end
        else
            doSendMagicEffect(pos, CONST_ME_POFF)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,
                                    "Exhaustion, espere " .. exhaustion.get(cid, config.storage) .. " segundos para usar a roleta novamente!")
            return false
        end
        return true
    else
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[ROULETTE] Roleta em andamento, aguarde terminar antes de começar novamente.")
    end
end

function doCleanTile(position, destroy)
    local tile = Tile(position)
    if tile then
        local items = tile:getItems()
        for i = 1, #items do
            if destroy then
                items[i]:remove()
            else
                items[i]:moveTo(Position(0, 0, 0))
            end
        end
    end
end

exhaustion = {
    check = function(cid, storage, t)
        return getPlayerStorageValue(cid, storage) >= os.time()
    end,
    set = function(cid, storage, t)
        setPlayerStorageValue(cid, storage, os.time() + t)
    end,
    get = function(cid, storage)
        return (getPlayerStorageValue(cid, storage) - os.time())
    end
}

I would like the person who pulls the lever to gain PZ status, so they would stay online for a few seconds and it would be possible to deliver the item, avoiding the crash, or if someone who understands more could help solve this problem?
 
I recommend you use Xiniki's roulette system; it's much better. Once, I helped a guy using TFS 1.2 8.0 Sabrehaven. I advised him to remove the custom revscripts, convert them into common actions, and also look for the 'onMoveItem' line in events/scripts/player.lua. He needed to adapt it... and when he did, everything worked perfectly.

 
I recommend you use Xiniki's roulette system; it's much better. Once, I helped a guy using TFS 1.2 8.0 Sabrehaven. I advised him to remove the custom revscripts, convert them into common actions, and also look for the 'onMoveItem' line in events/scripts/player.lua. He needed to adapt it... and when he did, everything worked perfectly.

My system works perfectly, I just wish it activated the pz in the player.
 

Similar threads

Back
Top