I have 0.4 TFS
i want to do lottery v2
i have:
into functions.lua:
MOD:
And website scripts,
My question is: do i need something else?
Where can i change interval or something like that?
i want to do lottery v2
i have:
into functions.lua:
function getPlayerWorldId(cid)
if not(isPlayer(cid)) then
return false
end
local pid = getPlayerGUID(cid)
local worldPlayer = 0
local result_plr = db.getResult("SELECT * FROM `players` WHERE `id` = "..pid..";")
if(result_plr:getID() ~= -1) then
worldPlayer = tonumber(result_plr:getDataInt("world_id"))
result_plr:free()
else
return false
end
MOD:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Lottery" enabled="yes">
<config name="lottery_config"><![CDATA[
t = {
lottery_hour = "180 Min", -- Time to next lottery (you set the real time on interval, it's only for the broadcast message.)
rewards_id = {11114, 7405, 2493, 8851, 2421, 7453, 6391, 2494, 2470, 2160}, -- ID's of rewards
stackable_amount = 20, -- amount, if this it's a stackable item
website = true -- Do you have `lottery` table in your database?
}
]]></config>
<globalevent name="lottery" interval="2700" event="buffer"><![CDATA[
domodlib('lottery_config')
local list = getPlayersOnline()
if #list > 0 then
local winner, item = list[math.random(#list)], t.rewards_id[math.random(#t.rewards_id)]
local stackable = getItemInfo(item).stackable
doPlayerAddItem(winner, item, stackable and t.stackable_amount or 1)
doBroadcastMessage('[SISTEMA DE LOTERIA]\nGanador: '.. getCreatureName(winner) ..',\nPremio: '.. (stackable and t.stackable_amount ..' ' or '') .. (stackable and getItemInfo(item).plural or getItemNameById(item)) .. '!\nFelicidades!\n(Siguiente Loteria En '.. t.lottery_hour ..')')
if t.website then
db.executeQuery("INSERT INTO `lottery` (`name`, `item`, `world_id`) VALUES ('".. getCreatureName(winner) .."', '".. getItemNameById(item) .."', '".. getConfigValue('worldId') .."');")
end
end
return true
]]></globalevent>
</mod>
CREATE TABLE `lottery` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`item` varchar(255) NOT NULL,
`world_id` tinyint(2) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
INSERT INTO `lottery` (`id`, `name`, `item`, `world_id`) VALUES
(NULL, 'Nobody', 'nothing', 0);
And website scripts,
My question is: do i need something else?
Where can i change interval or something like that?
Last edited: