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

Lottery system

xaii

Member
Joined
Nov 17, 2018
Messages
42
Reaction score
5
How i can disable this for GM? only players can take this.

Lua:
-- Lottery System

local config = {

    lottery_hour = "1 Hour", -- Tempo ate a proxima loteria (Esse tempo vai aparecer somente como broadcast message)

    rewards_id = {2160, 18918}, -- ID dos Itens Sorteados na Loteria

    crystal_counts = 1, -- Usado somente se a rewards_id for crystal coin (ID: 2160).

    website = "no" -- Only if you have php scripts and table `lottery` in your database!

    }

function onThink(interval, lastExecution)

        if(getWorldCreatures(0) == 0)then

                return true

        end


    local list = {}

    for i, tid in ipairs(getPlayersOnline()) do

                list[i] = tid

        end


        local winner = list[math.random(1, #list)]

        local random_item = config.rewards_id[math.random(1, #config.rewards_id)]


        if(random_item == 2160) then

                doPlayerAddItem(winner, random_item, config.crystal_counts)

                doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. config.crystal_counts .. " " .. getItemNameById(random_item) .. " Congratulations! (Next Lottery on " .. config.lottery_hour .. ")")

        else

                doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. getItemNameById(random_item) .. " Congratulations! (Next Lottery on " .. config.lottery_hour .. ")")

                doPlayerAddItem(winner, random_item, 1)

        end


        if(config.website == "yes") then

                db.executeQuery("INSERT INTO `lottery` (`name`, `item`) VALUES ('".. getCreatureName(winner) .."', '".. getItemNameById(random_item) .."');")

        end

        return true

end
 
Assuming you're ussing 0.3/0.4 (which you should always specify), try this:
Lua:
-- Lottery System

local config = {
    lottery_hour = "1 Hour", -- Tempo ate a proxima loteria (Esse tempo vai aparecer somente como broadcast message)
    rewards_id = {2160, 18918}, -- ID dos Itens Sorteados na Loteria
    crystal_counts = 1, -- Usado somente se a rewards_id for crystal coin (ID: 2160).
    website = "no" -- Only if you have php scripts and table `lottery` in your database!
}

function onThink(interval, lastExecution)

    if(getWorldCreatures(0) == 0)then
        return true
    end

    local list = {}

    for i, tid in ipairs(getPlayersOnline()) do
        if(getPlayerAccess(tid) < 2) then
            list[i] = tid
        end
    end

    if(#list == 0) then
        return true
    end

    local winner = list[math.random(1, #list)]
    local random_item = config.rewards_id[math.random(1, #config.rewards_id)]
    if(random_item == 2160) then
        doPlayerAddItem(winner, random_item, config.crystal_counts)
        doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. config.crystal_counts .. " " .. getItemNameById(random_item) .. " Congratulations! (Next Lottery on " .. config.lottery_hour .. ")")
    else
        doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. getItemNameById(random_item) .. " Congratulations! (Next Lottery on " .. config.lottery_hour .. ")")
        doPlayerAddItem(winner, random_item, 1)
    end

    if(config.website == "yes") then
        db.executeQuery("INSERT INTO `lottery` (`name`, `item`) VALUES ('".. getCreatureName(winner) .."', '".. getItemNameById(random_item) .."');")
    end

    return true
end
 
Last edited:
Back
Top