FLE
Member
Here is a simple lottery script, with configurable rewards chosen at random.
Tested this on tfs 1.1
Credits - @Luan Luciano
Installation -
globalevents.xml
(too add more, just add more lines with different time ^)
(there probably is a better way but I am a noob)
lottery.lua
Tested this on tfs 1.1
Credits - @Luan Luciano
Installation -
globalevents.xml
Code:
<globalevent name="Lotto" time="01:00:00" script="Events/lottery.lua" />
(too add more, just add more lines with different time ^)
(there probably is a better way but I am a noob)
lottery.lua
Code:
local rewards = {
{2160, 15},
{2160, 25},
{2195, 1},
}
function onTime(interval)
local players = Game.getPlayers()
if #players > 0 and #rewards > 0 then
local uid, n = math.random(1, #players), math.random(1, #rewards)
local lucky = players[uid]
local reward, count = rewards[n][1], rewards[n][2]
if lucky and reward and count then
lucky:addItem(reward, count)
Game.broadcastMessage('[LOTTERY] - '.. lucky:getName()..' recieved '.. count .. ' '..ItemType(reward):getName()..' Congratulations.', MESSAGE_STATUS_WARNING)
end
end
return true
end
Last edited: