• 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+ Help Script Lottery - TFS 1.3

adriez

New Member
Joined
Aug 14, 2011
Messages
73
Reaction score
1
i want what god and staff not gain lottery too... only players for win lotterry

local rewards = {
{9002, 1},
{9004, 1},
{9693, 1},
{2160, 100},
}

function onTime(interval)
local players = Game.getPlayers()

if #players > 0 and #rewards > 0 then
local uid, n = math.random(1, #players), math.random(1, #rewards)
local ganhador = players[uid]
local reward, count = rewards[n][1], rewards[n][2]

if ganhador and reward and count then
ganhador:addItem(reward, count)
Game.broadcastMessage('O player '.. ganhador:getName()..' recebeu '.. count .. ' '..ItemType(reward):getName()..' na loteria.', MESSAGE_STATUS_WARNING)
end
end

return true
end
 
A fast way that i find is to verify in sql , group_id (1 is normal player, i dont know how u defined "staff "). You can do your lottery and then verify in sql, if the winner is god or staff, you do it again.
 
iam using this lottery system in globalevents/scripts/lottery.lua
add this
Code:
local config = {
    interval = "2 hours",
    rewards = {[2160] = 3, [2159] = 1, [24774] = 1},
    -- [itemid] = count; [2160] = 50 - it gives 50 crystal coins
    website = false
}
 
function onThink(interval)
    local players = {}
    for _, player in ipairs(Game.getPlayers()) do
        if not player:getGroup():getAccess() then
            table.insert(players, player)
        end
    end
 
    local c = #players
    if c <= 0 then
        return true
    end
 
    local winner  = players[math.random(#players)]
 
    local items = {}
    for itemid, count in pairs(config.rewards) do
        items[#items + 1] = itemid
    end
 
    local itemid = items[math.random(1, #items)]
    local amount = config.rewards[itemid]
    winner:addItem(itemid, amount)
 
    local it   = ItemType(itemid)
    local name = ""
    if amount == 1 then
        name = it:getArticle() .. " " .. it:getName()
    else
        name = amount .. " " .. it:getPluralName()
    end
 
    broadcastMessage("[LOTTERY SYSTEM] " .. winner:getName() .. " won " .. name .. "! Congratulations! (Next lottery in " .. config.interval .. ")")
 
    return true
end

and in globalevents.xml add this line
Code:
    <globalevent name="Lottery" interval="7200000" script="lottery.lua"/>
this will be casted every 2 hours
7200000 = 2 * 60 * 60 * 1000
if you want to change the time in hours change that 2 and to change item there is config in the first lines of the script good luck
 
Back
Top