Ir para conteúdo

Featured Replies

Postado
[20:22:12.798] [Error - GlobalEvent Interface]
[20:22:12.798] data/globalevents/scripts/lottery.lua:onThink
[20:22:12.798] Description:
[20:22:12.799] data/globalevents/scripts/lottery.lua:13: bad argument #2 to 'random' (interval is empty)
[20:22:12.799] stack traceback:
[20:22:12.799]  [C]: in function 'random'
[20:22:12.799]  data/globalevents/scripts/lottery.lua:13: in function <data/globalevents/scripts/lottery.lua:7>
[20:22:12.799] [Error - GlobalEvents::think] Couldn't execute event: lottery
 
 
ALGUÉM  AJUDA ARRUMAR ISSO AI  ?

  • Respostas 9
  • Visualizações 839
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

Postado
  • Autor

esta ai lottery.lua

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 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 = 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

Postado
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 random = math.random(1, #list)
        local winner = list[random]
        local random_item = config.rewards_id[math.random(1, #config.rewards_id)]
        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

Refiz uma pequena parte do script, para que funcione . Testa ae :)

infos40x40.png

Skype : duhw.carvalho

 

Ajude-nos a crescer, clicando em curtir

 

 

 

Postado
  • Autor

deu mais um erro mais ta funcionando parece .

 

olha ai 

 

 

[0:7:53.205] [Error - GlobalEvent Interface]
[0:7:53.205] data/globalevents/scripts/lottery.lua:onThink
[0:7:53.206] Description:
[0:7:53.206] data/globalevents/scripts/lottery.lua:12: bad argument #2 to 'random' (interval is empty)
[0:7:53.206] stack traceback:
[0:7:53.206]    [C]: in function 'random'
[0:7:53.206]    data/globalevents/scripts/lottery.lua:12: in function <data/globalevents/scripts/lottery.lua:7>
[0:7:53.207] [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: helmet of the ancients! Congratulations! (Next Lottery in 1 Hours)".
> Broadcasted message: "[DraconiaWorld Lottery] Winner: Lost Power, Reward: demon armor! Congratulations! (Next Lottery in 1 Hours)".
> Broadcasted message: "[DraconiaWorld Lottery] Winner: Lost Power, Reward: demon armor! Congratulations! (Next Lottery in 1 Hours)"

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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo