• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

GlobalEvent [TFS 1.1] - Lottery

FLE

Member
Joined
Oct 5, 2008
Messages
422
Reaction score
24
Location
Vancouver Canada
Here is a simple lottery script, with configurable rewards chosen at random.

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:
Here is a simple lottery script, with configurable rewards chosen at random.

Tested this on tfs 1.1

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, h = math.random(1, #players), math.random(1, #rewards)
        local lucky = players[uid]
        local reward, count = rewards[h][1], rewards[h][2], rewards[h][3]
      
        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
nice one! Will probaly use this.
 
Yea thanks
but say u want a lottery every hour...
You have too add 24 lines into globalevents.xml ><'

If someone can make it better (idk how) that would be cool ^^

-Martin

You should make it require people buy tickets, more tickets = more chances to win ;)
 
Code:
local reward, count = rewards[n][1], rewards[n][2], rewards[n][3]

Correct:
Code:
local reward, count = rewards[n][1], rewards[n][2]
 
Code:
local reward, count = rewards[n][1], rewards[n][2], rewards[n][3]

Correct:
Code:
local reward, count = rewards[n][1], rewards[n][2]

Thanks bro got it,

You should make it require people buy tickets, more tickets = more chances to win ;)

Thats a cool Idea!

but I dont know how too do it, and this is just one of those automatic lotterys u may have seen before.
Very simple as you can see ><'

-Martin
 
@Luan Luciano
Wow, This script looks exactly like yours -.-'

I'm sorry if this is your script, a friend of mine from brazil gave me this and said he made it and I thought too share here~~

Sorry, I will add a credit for you in the post!!

-Martin
 
Is this script compatible for tfs 1.3? And which folder does the lottery lua go in?
 
Back
Top