Postado Maio 14, 2016 9 anos Seu sistema de cast é diferente, nesse caso tenta: Spoiler local function getCastsOnline() local ret, result = {}, db.getResult("SELECT `id` FROM `players` WHERE `broadcasting` >= 1") if(result:getID() ~= -1) then while(result:next()) do local player = getPlayerByGUID(tonumber(result:getDataInt("id"))) if(player) then table.insert(ret, player) end end result:free() end return ret end -- Lottery System By Jeff local config = { lottery_hour = "1 Hours", -- Tempo ate a proxima loteria (Esse tempo vai aparecer somente como broadcast message) rewards_id = {2160, 9810, 9822, 9819, 2173, 9693}, -- ID dos Itens Sorteados na Loteria crystal_counts = 100, -- Usado somente se a rewards_id for crystal coin (ID: 2160). website = "no" -- Only if you have php scripts and table `lottery` in your database! } function onThink(interval, lastExecution) if(getWorldCreatures(0) == 0)then return true end local list = {} for i, tid in ipairs(getCastsOnline()) do list[i] = tid end local winner = list[math.random(1, #list)] local random_item = config.rewards_id[math.random(1, #config.rewards_id)] if(random_item == 2160) then doPlayerAddItem(winner, random_item, config.crystal_counts) doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. config.crystal_counts .. " " .. getItemNameById(random_item) .. "s! Congratulations! (Proxima Loteria em " .. config.lottery_hour .. ")") else doBroadcastMessage("[LOTTERY SYSTEM] Ganhador: " .. getCreatureName(winner) .. ", Item: " .. getItemNameById(random_item) .. "! Parabens! (Proxima Loteria em " .. config.lottery_hour .. ") Premios que podem cair: 1kk, Rusty Armor, Rusty Helmet, Rusty Boots ou Addon Doll. Fique online! Quem sabe vc pode ser o proximo ganhador?") doPlayerAddItem(winner, random_item, 1) end if(config.website == "yes") then db.executeQuery("INSERT INTO `lottery` (`name`, `item`) VALUES ('".. getCreatureName(winner) .."', '".. getItemNameById(random_item) .."');") end return true end Editado Maio 14, 2016 9 anos por MaTTch (veja o histórico de edições)
Postado Maio 14, 2016 9 anos Autor 39 minutos atrás, MaTTch disse: Seu sistema de cast é diferente, nesse caso tenta: Ocultar conteúdo local function getCastsOnline() local ret, result = {}, db.getResult("SELECT `id` FROM `players` WHERE `broadcasting` >= 1") if(result:getID() ~= -1) then while(result:next()) do local player = getPlayerByGUID(tonumber(result:getDataInt("id"))) if(player) then table.insert(ret, player) end end result:free() end return ret end -- Lottery System By Jeff local config = { lottery_hour = "1 Hours", -- Tempo ate a proxima loteria (Esse tempo vai aparecer somente como broadcast message) rewards_id = {2160, 9810, 9822, 9819, 2173, 9693}, -- ID dos Itens Sorteados na Loteria crystal_counts = 100, -- Usado somente se a rewards_id for crystal coin (ID: 2160). website = "no" -- Only if you have php scripts and table `lottery` in your database! } function onThink(interval, lastExecution) if(getWorldCreatures(0) == 0)then return true end local list = {} for i, tid in ipairs(getCastsOnline()) do list[i] = tid end local winner = list[math.random(1, #list)] local random_item = config.rewards_id[math.random(1, #config.rewards_id)] if(random_item == 2160) then doPlayerAddItem(winner, random_item, config.crystal_counts) doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. config.crystal_counts .. " " .. getItemNameById(random_item) .. "s! Congratulations! (Proxima Loteria em " .. config.lottery_hour .. ")") else doBroadcastMessage("[LOTTERY SYSTEM] Ganhador: " .. getCreatureName(winner) .. ", Item: " .. getItemNameById(random_item) .. "! Parabens! (Proxima Loteria em " .. config.lottery_hour .. ") Premios que podem cair: 1kk, Rusty Armor, Rusty Helmet, Rusty Boots ou Addon Doll. Fique online! Quem sabe vc pode ser o proximo ganhador?") doPlayerAddItem(winner, random_item, 1) end if(config.website == "yes") then db.executeQuery("INSERT INTO `lottery` (`name`, `item`) VALUES ('".. getCreatureName(winner) .."', '".. getItemNameById(random_item) .."');") end return true end Funcionou certinho!! VLW MAN! @ MaTTch @ Talesigorvr Acabaram meus reps, mas vou colocar amanha! Dia 15! VLW!!!
Postado Maio 14, 2016 9 anos =) Não dou suporte via PM, crie um tópico caso tenha dúvidas. Isso previne que outras pessoas com a mesma dúvida criem tópicos desnecessários.
Postado Maio 18, 2016 9 anos Autor @UP outro probleminha: Sempre o Mesmo Player está ganhando na loteria, sendo que tem ao menos uns 10 com Cast aberto...
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.