Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local par = { }
- local running = false
- function startGiveaway()
- if running ~= true then
- running = true
- outputChatBox("Tell the players here, that the giveaway has started, the amount to win and how to participate", root, 255, 255, 255)
- setTimer(function ()
- local randomWinner = par[math.random(#par)]
- if randomWinner then
- outputChatBox(("%s has won!"):format(getPlayerName(randomWinner)), root, 255, 255, 255)
- givePlayerMoney(randomWinner, 0) -- change the 0 to an amount you like
- running = false
- for index, p in ipairs(par) do
- table.remove(par, index)
- end
- end
- end, 0, 1) -- 0 = time in ms (1000 ms = 1 second); change the 0 to a value you like
- end
- end
- -- Server
- addEventHandler("onResourceStart", resourceRoot,
- function ()
- startGiveaway()
- end)
- addCommandHandler("par",
- function (player, cmd)
- local money = getPlayerMoney(player)
- if money >= 500 then
- if not par[player] then
- par[player] = true
- takePlayerMoney(player, 500)
- outputChatBox("Inform the player here, that he is participating in the giveaway", player, 255, 255, 255)
- else
- outputChatBox("Inform the player here, that he is already participating", player, 255, 255, 255)
- end
- else
- outputChatBox("Tell the player here, that is money is not enough", player, 255, 255, 255)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement