- Awards
- 38
Hola,
Aqui os comparto el Lottery system,
Pueden colocar el Item Id que desean,
Aqui os comparto el Lottery system,
Pueden colocar el Item Id que desean,
Código:
local lottery = GlobalEvent("lottery")
local config = {
interval = "2 hours",
rewards = {[2160] = 5, [2152] = 5, [24774] = 5}, -- Rewards aleatorio, separados por coma, 2160 es crystal coin = cuantos, 2152, platinium coins, cuantos, 24774 son tibia coins, cuantos etc
website = false
}
function lottery.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
lottery:interval(7200000) --- aqui son 2 horas, hay que modificarlo si se quiere augmentar o disminuir
lottery:register()