Advertisement
Guest User

Untitled

a guest
Aug 1st, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.52 KB | None | 0 0
  1. local par = { }
  2. local running = false
  3.  
  4. function startGiveaway()
  5.     if running ~= true then
  6.         running = true
  7.         outputChatBox("Tell the players here, that the giveaway has started, the amount to win and how to participate", root, 255, 255, 255)
  8.         setTimer(function ()
  9.             local randomWinner = par[math.random(#par)]
  10.             if randomWinner then
  11.                 outputChatBox(("%s has won!"):format(getPlayerName(randomWinner)), root, 255, 255, 255)
  12.                 givePlayerMoney(randomWinner, 0) -- change the 0 to an amount you like
  13.                 running = false
  14.                 for index, p in ipairs(par) do
  15.                     table.remove(par, index)
  16.                 end
  17.             end
  18.         end, 0, 1) -- 0 = time in ms (1000 ms = 1 second); change the 0 to a value you like
  19.     end
  20. end
  21.  
  22. -- Server
  23. addEventHandler("onResourceStart", resourceRoot,
  24. function ()
  25.     startGiveaway()
  26. end)
  27.  
  28. addCommandHandler("par",
  29. function (player, cmd)
  30.     local money = getPlayerMoney(player)
  31.     if money >= 500 then
  32.         if not par[player] then
  33.             par[player] = true
  34.             takePlayerMoney(player, 500)
  35.             outputChatBox("Inform the player here, that he is participating in the giveaway", player, 255, 255, 255)
  36.         else
  37.             outputChatBox("Inform the player here, that he is already participating", player, 255, 255, 255)
  38.         end
  39.     else
  40.         outputChatBox("Tell the player here, that is money is not enough", player, 255, 255, 255)
  41.     end
  42. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement