This is the error >.<
Here is my script!!
Here is my script!!
Lua:
-- by vDk, klekSu
local config = {
lottery_hour = "45 Min", -- Time to next lottery (real time you set on globalevents.xml, its only for broadcast message.)
rewards_id = {2494, 2472, 2514, 2195, 2470, 2656, 7895, 2160}, -- Rewards ID
crystal_counts = 20, -- used only if on rewards_id you have crystal coins (ID: 2160).
website = "yes" -- Do you have `lottery` table in your database?
}
function onThink(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)]
local random_item = config.rewards_id[math.random(1, #config.rewards_id)]
local item_name = getItemNameById(random_item)
local world = 0
if(random_item == 2160) then
doPlayerAddItem(winner, random_item, config.crystal_counts)
doBroadcastMessage('[SISTEMA DE LOTERIA] Ganador: '.. getCreatureName(winner) ..', Premio: '.. config.crystal_counts ..' '.. item_name ..'s! Felicidades! (Siguiente Loteria En '.. config.lottery_hour ..')')
else
doBroadcastMessage('[SISTEMA DE LOTERIA] Ganador: '.. getCreatureName(winner) ..', Premio: '.. item_name ..'! Felicidades! (Siguiente Loteria En '.. config.lottery_hour ..')')
doPlayerAddItem(winner, random_item, 1)
end
if(config.website == "yes") then
db.executeQuery("INSERT INTO `lottery` (`name`, `item`, `world_id`) VALUES ('".. getCreatureName(winner) .."', '".. item_name .."', '".. world .."');")
end
return TRUE
end