Postado Maio 23, 2014 11 anos local config = { lottery_hour = "1 Hours", -- Time to next lottery (real time you set on globalevents.xml, its only for broadcast message.) rewards_id = {2494, 2472, 2514, 2493, 2470, 2195, 2342, 2160}, -- Rewards ID crystal_counts = 100, -- used only if on rewards_id you have crystal coins (ID: 2160). website = "no" -- Do you have `lottery` table in your database? } function onThink(interval, lastExecution) local list = {} for _, pid in pairs(getPlayersOnline()) do table.insert(list, pid) end local random1 = math.random(1, #list) local winner = list[random1] local random2 = math.random(1, #config.rewards_id) local random_item = config.rewards_id[random2] local item_name = getItemNameById(random_item) local world = tonumber(getPlayerWorldId(winner)) if(random_item == 2160) then doPlayerAddItem(winner, random_item, config.crystal_counts) doBroadcastMessage('[DraconiaWorld Lottery] Winner: '.. getCreatureName(winner) ..', Reward: '.. config.crystal_counts ..' '.. item_name ..'s! Congratulations! (Next Lottery in '.. config.lottery_hour ..')') else doBroadcastMessage('[DraconiaWorld Lottery] Winner: '.. getCreatureName(winner) ..', Reward: '.. item_name ..'! Congratulations! (Next Lottery in '.. 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 Agora vai ! Skype : duhw.carvalho Ajude-nos a crescer, clicando em curtir
Postado Maio 23, 2014 11 anos Eduardo Carvalho você pode arruma para TFS 1.0 ? e se você arruma o com script para o site.
Postado Maio 23, 2014 11 anos Autor foi não ainda ta com esse erro [8:52:45.778] [Error - GlobalEvent Interface] [8:52:45.787] data/globalevents/scripts/lottery.lua:onThink [8:52:45.798] Description: [8:52:45.811] data/globalevents/scripts/lottery.lua:12: bad argument #2 to 'random' (interval is empty) [8:52:45.820] stack traceback: [8:52:45.830] [C]: in function 'random' [8:52:45.846] data/globalevents/scripts/lottery.lua:12: in function <data/globalevents/scripts/lottery.lua:7> [8:52:45.852] [Error - GlobalEvents::think] Couldn't execute event: lottery > Broadcasted message: "[DraconiaWorld Lottery] Winner: Lost Power, Reward: helmet of the ancients! Congratulations! (Next Lottery in 1 Hours)". > Broadcasted message: "[DraconiaWorld Lottery] Winner: Lost Power, Reward: 100 crystal coins! Congratulations! (Next Lottery in 1 Hours)". > Broadcasted message: "[DraconiaWorld Lottery] Winner: Lost Power, Reward: magic plate armor! Congratulations! (Next Lottery in 1 Hours)".> Broadcasted message: "[DraconiaWorld Lottery] Winner: Lost Power, Reward: demon armor! Congratulations! (Next Lottery in 1 Hours)".
Postado Maio 23, 2014 11 anos Amigo teste esse local premio = { [1] = {item = 2157, count = 1}, } local configs = { minute = 30, -- quantas em quantas horas, vai acontecer. winners = 1 -- qntos players podem ganhar. } function onThink(interval, lastExecution) local p = getPlayersOnline() local winners = configs.winners if #p < winners then winners = #p end for i = 1, winners do local p = getPlayersOnline() local c, w = #p, #premio local d, e = math.random©, math.random(w) local playerwin = p[d] doPlayerAddItem(playerwin, premio[e].item, premio[e].count) doBroadcastMessage("[Mega Sena] Ganhador:" .. getCreatureName(playerwin) .. ", Recompensa: " .. premio[e].count .. " " .. getItemNameById(premio[e].item) .. ", Parabéns!, Proxima Loteria Em 30 Minutos !") if i == winners then doBroadcastMessage("(Próxima loteria só " .. configs.minute .. " minutos.)") end doSendMagicEffect(getThingPos(playerwin), 12) end return true end Para adicionar mais itens apenas faça assim local premio = { [1] = {item = 2157, count = 1}, [2] = {item = 2157, count = 1}, Id do item e a quantidade que sera add } Obs:é um script globalevent... O tempo vc define na tag.. <globalevent name="lotery" interval="1800000" event="script" value="lotery.lua"/> ( em tfs 0.4 isso seria 30 min) Scripter: |||||||||| 10% Te ajudei?? REP + e ficamos quites... Atenciosamente, Lucas. Abraços!
Postado Maio 25, 2014 11 anos foi não ainda ta com esse erro [8:52:45.778] [Error - GlobalEvent Interface] [8:52:45.787] data/globalevents/scripts/lottery.lua:onThink [8:52:45.798] Description: [8:52:45.811] data/globalevents/scripts/lottery.lua:12: bad argument #2 to 'random' (interval is empty) [8:52:45.820] stack traceback: [8:52:45.830] [C]: in function 'random' [8:52:45.846] data/globalevents/scripts/lottery.lua:12: in function <data/globalevents/scripts/lottery.lua:7> [8:52:45.852] [Error - GlobalEvents::think] Couldn't execute event: lottery > Broadcasted message: "[DraconiaWorld Lottery] Winner: Lost Power, Reward: helmet of the ancients! Congratulations! (Next Lottery in 1 Hours)". > Broadcasted message: "[DraconiaWorld Lottery] Winner: Lost Power, Reward: 100 crystal coins! Congratulations! (Next Lottery in 1 Hours)". > Broadcasted message: "[DraconiaWorld Lottery] Winner: Lost Power, Reward: magic plate armor! Congratulations! (Next Lottery in 1 Hours)".> Broadcasted message: "[DraconiaWorld Lottery] Winner: Lost Power, Reward: demon armor! Congratulations! (Next Lottery in 1 Hours)". Testei aqui , funcionou :s Skype : duhw.carvalho Ajude-nos a crescer, clicando em curtir
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.