• 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!

Auto broadcast TFS 1.0

Raggaer

Godly Member
Joined
Jul 25, 2012
Messages
1,557
Solutions
8
Reaction score
957
Location
Spain
Hello, was wondering if someone could share the autobroadcast X message each X seconds for the new TFS distro!
Thanks
 
Code:
local t, i = {"test", "testing", "test123"}, 1

function onThink(interval)
    broadcastMessage(t[i], MESSAGE_STATUS_WARNING)
    i = i == #t and 1 or i + 1
    return true
end
 
Code:
local t, i = {"test", "testing", "test123"}, 1

function onThink(interval)
    broadcastMessage(t[i], MESSAGE_STATUS_WARNING)
    i = i == #t and 1 or i + 1
    return true
end
Mind showing me how the globalevents.lua line should be for this one because mine just keeps saying failed to execute event Broadcast Im wondering if it has to have a certain name, This is what I have it as and the broadcast.lua is your code exactly ^ (running tfs 1.1)

Heres my globalevents.lua line
<globalevent name="Broadcast" interval="1000000" script="broadcast.lua"/>
 
PHP:
-- [( Script created by gboxx )] --
function onThink(interval, lastExecution)
MENSAGE = {
"[Event Mensaje]xxxx",
"[Event Mensaje]xxxx",
}
broadcastMessage(MENSAGE[math.random(1,#MENSAGE)],20)
return TRUE
end
 
seems like common thing running around here. people like to return true everywhere xD (i used to do it too)
but infact, you dont need it most cases.
 
PHP:
-- [( Script created by gboxx )] --
function onThink(interval, lastExecution)
MENSAGE = {
"[Event Mensaje]xxxx",
"[Event Mensaje]xxxx",
}
broadcastMessage(MENSAGE[math.random(1,#MENSAGE)],20)
return TRUE
end

Indentation, MESSAGE is global, it should be local, TRUE should be true, if you are using math.random you need a seed for it, otherwise it will always return the same value.
 
Try it yourself, you need a seed for random values, thats the point of the seed function. Google it :p
i don't understand you what is seed and too tired to read google wall of text about it.
Without testing i say: his code is working perfectly.
 
Last edited:
umm... you are using totally different math.ranom, ofc you get 1 value..
he is taking random string from table.

EDIT: i did test the lua.org thing you have there, its kinda broken..
print(math.random(100))
should give random value between 1 and 100 if i remember correctly
 
Last edited:
umm... you are using totally different math.ranom, ofc you get 1 value..
he is taking random string from table.

EDIT: i did test the lua.org thing you have there, its kinda broken..
print(math.random(100))
should give random value between 1 and 100 if i remember correctly

It is actually not broken.
Now try this:
Code:
math.randomseed(os.time())
print(math.random(100))

As you can see all I did was add the seed function.
 
It is actually not broken.
Now try this:
Code:
math.randomseed(os.time())
print(math.random(100))

As you can see all I did was add the seed function.
no need, it should already work by just printing 1 line without seeding
 
no need, it should already work by just printing 1 line without seeding

So you checked the demo once again?
As you can see with the demo, if you don't use the seed you will get the same value, but if you use the seed you will get a random value.
A seed is required.
If you don't then you most likely have it somewhere else.
 
So you checked the demo once again?
As you can see with the demo, if you don't use the seed you will get the same value, but if you use the seed you will get a random value.
A seed is required.
If you don't then you most likely have it somewhere else.
i dont have the seed somewhere else and it works just fine for me in TFS.
 
i dont have the seed somewhere else and it works just fine for me in TFS.

Dude.. you have a seed somewhere, might be in the source code or in a lua file.
If we are talking about raw lua, then the demo is raw.
And atleast with older versions of tfs it was required to use the seed.
Just as the demo code showed.
 
Dude.. you have a seed somewhere, might be in the source code or in a lua file.
If we are talking about raw lua, then the demo is raw.
And atleast with older versions of tfs it was required to use the seed.
Just as the demo code showed.
math.random() generates pseudo-random numbers uniformly distributed. Supplying argument alters its behaviour:
  • math.random() with no arguments generates a real number between 0 and 1.
  • math.random(upper) generates integer numbers between 1 and upper.
  • math.random(lower, upper) generates integer numbers between lower and upper.
i found this from LUA manual
 
math.random() generates pseudo-random numbers uniformly distributed. Supplying argument alters its behaviour:
  • math.random() with no arguments generates a real number between 0 and 1.
  • math.random(upper) generates integer numbers between 1 and upper.
  • math.random(lower, upper) generates integer numbers between lower and upper.
i found this from LUA manual

Since you still don't want to listen, http://giderosmobile.com/forum/disc...-produce-equal-sequences-of-numbers-on-ios/p1
If you want to continue this we can do it in a pm, no reason to keep bumping the thread.
 
Back
Top