Advertisement
Guest User

Untitled

a guest
Jan 30th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. local config = {
  2.     rewards = {[2195] = 1, [2472] = 1, [2493] = 1}
  3. }
  4.  
  5. function onTime(interval)
  6.     if Game.getPlayerCount() == 0 then
  7.         return true
  8.     end
  9.  
  10.     local players = Game.getPlayers()
  11.     local winner  = players[math.random(1, #players)]
  12.  
  13.     local items = {}
  14.     for itemid, count in pairs(config.rewards) do
  15.         items[#items + 1] = itemid
  16.     end
  17.  
  18.     local itemid = items[math.random(1, #items)]
  19.     local amount = config.rewards[itemid]
  20.     winner:addItem(itemid, amount)
  21.  
  22.     local it   = ItemType(itemid)
  23.     local name = ""
  24.     if amount == 1 then
  25.         name = it:getArticle() .. " " .. it:getName()
  26.     else
  27.         name = amount .. " " .. it:getPluralName()
  28.     end
  29.  
  30.     Game.broadcastMessage("" .. winner:getName() .. " won " .. name .. "! Congratulations.", MESSAGE_STATUS_WARNING)
  31.     return true
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement