Lua Errors

if this is in the wrong section… il get a ban :frowning: i hope not

OK i keep getting this error:
ERROR: GAMEMODE:‘PlayerSelectSpawn’ Failed: gamemodes\Faction Wars\gamemode\sv_player.lua:125: bad argument #2 to ‘random’ (interval is empty)

Section Of Line 2:
function GM:ChoosePlayerTeam()
local red = team.NumPlayers( self.Red )
local blue = team.NumPlayers( self.Blue )
if (red == blue) then return self:RandomTeam() end
if (red > blue) then return blue end
if (red < blue) then return red end
end

Please help :smiley:

Show the GM:RandomTeam() function.

function GM:RandomTeam()
math.randomseed( os.time() )
local teamcount = 2
local id = math.random( 1, teamcount )
return id
end

Ok, that seems find. What’s on line 125 then?

nothing :frowning:

Liar! the error is on line 125 of sv_player.lua so show it!

line 124. end
line 125.
line 126. function GM:PlayerShouldTakeDamage( ply, attacker )

Either you have edited it or you’ve copied from the wrong file. I am 100% sure that error is on line 125

Since the range of his math.random in the GM:RandomTeam() function is only 1, won’t it return a float? And Why are you using math.random in a range of one anyways if you’re not going to do something to make it consistently pick differently? You could just make up some conditional (with a 50% chance of being true) that assigns them to red else assign blue.

Does sv_player.lua have any multi-line comments? if so how many lines does it take up

Shouldn’t matter.

It does to me sometimes

Agreed, I’ve tried having it return a wrong line number too, and that was because I had a multi-line comment.