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(interval, lastExecution)
local players = getPlayersOnline()
local list = {}
for i, tid in ipairs(players) do
list[i] = tid
end
local winner = list[math.random(1, #list)]
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` +" .. config.points .. " WHERE `name` = ".. getAccountByName(winner) ..";")
doBroadcastMessage('[LOTTERY SYSTEM] Winner: '.. getCreatureName(winner) ..', 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 ('".. getCreatureName(winner) .."', '".. config.points .." premium points');")
end
return TRUE
end