Tbol
Well-Known Member
- Joined
- Apr 7, 2019
- Messages
- 529
- Reaction score
- 56
Hi im using this tfs 1.2 auto lottery script but i wonder is it possible to add different rewards if there is more online people, so like if there is
10-20 online people you get dif items
21-40 online people you get dif items
41-100 online people you get dif items
and etc
10-20 online people you get dif items
21-40 online people you get dif items
41-100 online people you get dif items
and etc
Lua:
local config = {
interval = "4 hours",
rewards = {[12757] = 1, [12779] = 10, [12778] = 10, [12780] = 5, [2160] = 20, [12764] = 1, [2678] = 50},
-- [itemid] = count; [2160] = 50 - it gives 50 crystal coins
website = false
}
function Game.broadcastMessage(message, messageType)
if messageType == nil then
messageType = MESSAGE_STATUS_CONSOLE_ORANGE
end
for _, player in ipairs(Game.getPlayers()) do
player:sendTextMessage(messageType, message)
end
end
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
Game.broadcastMessage("Test" .. winner:getName() .. " won " .. name .. "! (Next lottery in " .. config.interval .. ")")
return true
end