God Mythera
Veteran OT User
If someone could help me i need it so it does not give reward to group id 2-3 (GM, God)
Code:
local config = {
interval = "1 hour",
rewards = {[2160] = 3},
-- [itemid] = count; [2160] = 50 - it gives 50 crystal coins
website = false
}
function onThink(interval)
if Game.getPlayerCount() == 0 then
return true
end
local players = Game.getPlayers()
local winner = players[math.random(1, #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 .. ")")
if config.website then
db.query("INSERT INTO `lottery` (`name`, `item`) VALUES (\"".. db.escapeString(winner:getName()) .."\", \"".. db.escapeString(it:getName()) .."\");")
end
return true
end