Ir para conteúdo
  • 0

Loteria ? Erro chatinho!


raynerjr

Pergunta

- Olá estou com um pequeno problema no sistema de loteria.


Ele entrega o item para jogador, faz tudo certo.


Mais não esta adicionando na tabela da database, que seria lottery, e da um pequeno erro, onde não parece na página de Loteria do meu site os ganhadores!



Alguém sabe por que? Vi vários com o mesmo problema!


Link para o comentário
Compartilhar em outros sites

6 respostass a esta questão

Posts Recomendados

  • 0

@@raynerjr

 

Tente assim:

 

local config = {
	lottery_hour = "3 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, 2173, 2160, 2520}, -- Rewards ID
	crystal_counts = 100, -- 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()
	if #players > 0 then
		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('[Baiak Rock Lottery] Winner: '.. getCreatureName(winner) ..', Reward: '.. config.crystal_counts ..' '.. item_name ..'s! Congratulations! (Next Lottery in '.. config.lottery_hour ..')')
		else
			doBroadcastMessage('[Baiak Rock 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.query("INSERT INTO `lottery` (`name`, `item`, `world_id`) VALUES ('".. getCreatureName(winner) .."', '".. item_name .."', '".. world .."');")
		end
	end
	return true
end
Link para o comentário
Compartilhar em outros sites

  • 0

Sistema de Loteria:

 

local config = {
lottery_hour = "3 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, 2173, 2160, 2520}, -- Rewards ID
crystal_counts = 100, -- 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 = tonumber(getPlayerWorldId(winner))
if(random_item == 2160) then
doPlayerAddItem(winner, random_item, config.crystal_counts)
doBroadcastMessage('[Baiak Rock Lottery] Winner: '.. getCreatureName(winner) ..', Reward: '.. config.crystal_counts ..' '.. item_name ..'s! Congratulations! (Next Lottery in '.. config.lottery_hour ..')')
else
doBroadcastMessage('[Baiak Rock 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

 


@up

Link para o comentário
Compartilhar em outros sites

  • 0

e qual o erro?? vc usa sqlite ou mysql??

 

ele tinha um bug, se n tivesse nenhum online da erro...

 

 

local config = {
lottery_hour = "3 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, 2173, 2160, 2520}, -- Rewards ID
crystal_counts = 100, -- 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)
if #getPlayersOnline() > 0 then
local players = getPlayersOnline()
local winner, r_item = players[math.random(1, #players)], config.rewards_id[math.random(1, #config.rewards_id)]
local item_name = getItemNameById(r_item)
doPlayerAddItem(winner, r_item, isItemStackable(r_item) and 100 or 1)
doBroadcastMessage('[Baiak Rock Lottery] Winner: '.. getCreatureName(winner) ..', Reward: '..(isItemStackable(r_item) and 100 or 1)..' '.. item_name ..'(s)! Congratulations! (Next Lottery in '.. config.lottery_hour ..')')
if(config.website == "yes") then
db.query("INSERT INTO `lottery` (`name`, `item`, `world_id`) VALUES ('".. getCreatureName(winner) .."', '".. item_name .."', '".. world .."');")
end
end
return true
end
Editado por Vodkart
Link para o comentário
Compartilhar em outros sites

  • 0

@@raynerjr

 

Tente assim:

 

 

local config = {
	lottery_hour = "3 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, 2173, 2160, 2520}, -- Rewards ID
	crystal_counts = 100, -- 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()
	if #players > 0 then
		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('[Baiak Rock Lottery] Winner: '.. getCreatureName(winner) ..', Reward: '.. config.crystal_counts ..' '.. item_name ..'s! Congratulations! (Next Lottery in '.. config.lottery_hour ..')')
		else
			doBroadcastMessage('[Baiak Rock 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.query("INSERT INTO `lottery` (`name`, `item`, `world_id`) VALUES ('".. getCreatureName(winner) .."', '".. item_name .."', '".. world .."');")
		end
	end
	return true
end

 

 

 

Sistema do @Bruno Minervino deu certinho.

Já o do @Vodkart deu erro.

Mais obrigado pela atenção os dois.

 

Rep+

Resolvido

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...