Ir para conteúdo
  • Cadastre-se

[ERRO] SCRIPT LOTTERY.LUA


Posts Recomendados

[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  ?

Link para o post
Compartilhar em outros sites

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

Link para o post
Compartilhar em outros sites
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

 

 

 

Link para o post
Compartilhar em outros sites

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)". 

Link para o post
Compartilhar em outros sites
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 ! :D

infos40x40.png

Skype : duhw.carvalho

 

Ajude-nos a crescer, clicando em curtir

 

 

 

Link para o post
Compartilhar em outros sites

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)".

Link para o post
Compartilhar em outros sites

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...  ;D

 

Atenciosamente,

                   Lucas.

Abraços!

Link para o post
Compartilhar em outros sites

 

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

infos40x40.png

Skype : duhw.carvalho

 

Ajude-nos a crescer, clicando em curtir

 

 

 

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo