Hello, I try to make a random vote via lua. It worked well at beginning but suddenly got broken (really don’t know why). I tested on my infected mod (based on etpub 1.0.0) with lua5.1.dll on a windows 7 x64 server.
I got the problem that it only counts on second vote, so it’s working, not, working, not, working,…
Also the maps seems to be in an order (tested without changing map, just text feedback).
The votes are:
/callvote poll random map
/callvote poll infect a random player
Infected a random player should put a random player to axis (called infected on my mod).
Random map should pick one map out of the table.
PerlO_oung?! scripted the following (just a part out of my lua):
EDIT Found the problem: Tested with etpro (it uses lua 5.0.2) and the lua file worked. It seems like the math.random function in the lua5.1.dll is bugged.
EDIT NEW PerlO_oung?! and I found out that table.getn is bugged in lua 5.1.* We use # instead and random votes work now.
samplerate = 1
math.randomseed( et.trap_Milliseconds() + samplerate )
randommaptable = {
{ mapname = “oasis” },
{ mapname = “radar” },
{ mapname = “railgun” },
{ mapname = “goldrush” },
{ mapname = “battery” },
{ mapname = “adlernest” },
{ mapname = “frostbite” },
{ mapname = “supply” },
}
function randommap()
local random1 = math.random(#randommaptable)
return string.lower(randommaptable[random1].mapname)
end