Can anyone help me with this script?
I need him to deliver the items, only for promoted players.
Since now. Thanks!
I need him to deliver the items, only for promoted players.
Lua:
local lottery = GlobalEvent("lottery")
local config = {
interval = "5 minutes.",
rewards = {
[3040] = 3, -- GOLD NUGGET
[3053] = 1, -- TIME RING
[2995] = 1, -- PIGGY BANK
[8072] = 1, -- SPELLBOOK OF ENLIGHTENMENT
[7367] = 1, -- ENCHANTED SPEAR
[8043] = 1, -- FOCUS CAPE
[3725] = 12, -- BROWN MUSHROOMS
[5710] = 1, -- LIGHT SHOVEL
[3567] = 1, -- BLUE ROBE
[2995] = 1, -- PIGGY BANK
[3055] = 1, -- PLATINUM AMULET
[5908] = 1, -- OBSIDIAN KNIFE
[3414] = 1 -- MASTERMIND SHIELD
},
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("Congratulations " .. winner:getName() .. " won " .. name .. ". Next lottery in " .. config.interval .. "")
return true
end
lottery:interval(300000) --- Exemple: 60000 = 1 minute.
lottery:register()
Since now. Thanks!