• Editing TTT : Error using a variable as a function argument
    2 replies, posted
I'm working on editing some of the TTT files and I've come to a stop. More specifically, an error I'm pretty much baffled by. Here's my code: [lua] ... CODE ... if roundtype == ROUND_DM then local live = {} local p2 = {} for _, ply in pairs( player.GetAll() ) do if ply:Alive() then table.insert( live, ply ) end end if #live == 2 then p2[1] = live[1] p2[2] = live[2] elseif #live == 1 then for _, pl in pairs( p2 ) do if pl == live[_] then winner = pl if _ == 1 then loser = p2[2] else loser = p2[1] end end end if not p2[1] or not p2[2] then winner = live[1] end if #player.GetAll() == 1 then EndRound( WIN_TIMELIMIT, winner ) else EndRound( WIN_TRAITOR, winner, loser ) end elseif #live == 0 then EndRound( WIN_NONE ) end elseif roundtype == ROUND_TIME then ... CODE ... function EndRound(type, ply, kill) //PrintResultMessage(type) if type == WIN_TRAITOR then LANG.Msg( "win_innocent", {ply = ply:Nick(), kills = kill:Nick()} ) elseif type == WIN_INNOCENT then LANG.Msg( "win_time", {ply = ply:Nick(), kills = kill} ) elseif type == WIN_NONE then LANG.Msg( "win_traitor" ) elseif type == WIN_TIMELIMIT then LANG.Msg( "win_timelimit", {ply = ply:Nick()} ) end ... CODE ... [/lua] [lua] LANG.Msg( "win_innocent", {ply = ply:Nick(), kills = kill:Nick()} ) [/lua] This line is what gives me errors, saying that [lua] kill isn't valid [/lua]. I am not sure why it would do that, since the script gets the last two players and retrieves them when there is only one left alive. Why would kill be nil, considering I'm passing that argument via the function?
bump
As usual, try printing it in the console first. Put "print( type, ply, kill )" at 1st line of the function.
Sorry, you need to Log In to post a reply to this thread.