local config =
{
lottery_hour = "24 Hours", -- Time to next lottery (real time you set on globalevents.xml, its only for broadcast message.)
points = 15, -- how many points winner get?
website = "yes" -- Do you have `lottery` table in your database?
}
function onTimer()
local random, name = math.random(1, #getOnlinePlayers()), getPlayerNameByGUID(random)
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` +" .. config.points .. " WHERE `id` = ".. getAccountIdByName(name) ..";")
doBroadcastMessage('[LOTTERY SYSTEM] Winner: '.. name ..', Reward: +' .. points ..' points to the SMS Shop! Congratulations! (Next Lottery in '.. config.lottery_hour ..')')
if(config.website == "yes") then
db.executeQuery("INSERT INTO `lottery` (`name`, `item`) VALUES ('".. name .."', '".. config.points .." premium points');")
end
return true
end