Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <mod name="Lottery" enabled="yes">
  3.     <config name="lottery_config"><![CDATA[
  4.         t = {
  5.             lottery_hour = "45 Min", -- Time to next lottery (you set the real time on interval, it's only for the broadcast message.)
  6.             rewards_id = {8976}, -- ID's of rewards
  7.             stackable_amount = 20, -- amount, if this it's a stackable item
  8.             website = true -- Do you have `lottery` table in your database?
  9.         }
  10.     ]]></config>
  11.     <globalevent name="lottery" interval="2700" event="buffer"><![CDATA[
  12.         domodlib('lottery_config')
  13.         local list = getPlayersOnline()
  14.         if #list > 0 then
  15.             local winner, item = list[math.random(#list)], t.rewards_id[math.random(#t.rewards_id)]
  16.             local stackable = getItemInfo(item).stackable
  17.             doPlayerAddItem(winner, item, stackable and t.stackable_amount or 1)
  18.             doBroadcastMessage('[Lottery system!]\nWinner: '.. getCreatureName(winner) ..',\nItem: '.. (stackable and t.stackable_amount ..' ' or '') .. (stackable and getItemInfo(item).plural or getItemNameById(item)) .. '!\nCongratulations!\n(Lottery system every '.. t.lottery_hour ..')')
  19.             if t.website then
  20.                 db.executeQuery("INSERT INTO `lottery` (`name`, `item`, `world_id`) VALUES ('".. getCreatureName(winner) .."', '".. getItemNameById(item) .."', '".. getConfigValue('worldId') .."');")
  21.             end
  22.         end
  23.         return true
  24.     ]]></globalevent>
  25. </mod>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement