• New To Lua, A Function Question
    2 replies, posted
I am making a gamemode and in my init.lua file I have: [CODE]function plymodels( ply ) if ply:Team() == 1 then ply:SetModel( "models/player/combine_soldier.mdl" ) end end[/CODE] I am very newbie and I was wondering how I would add models for the other teams. I have two other teams. Would I use an else statement inside the if statement for the other teams or would I use another if statement inside the function? Maybe both of those are wrong? Thanks.
[QUOTE=Swirlyman;21207313]I am making a gamemode and in my init.lua file I have: [CODE]function plymodels( ply ) if ply:Team() == 1 then ply:SetModel( "models/player/combine_soldier.mdl" ) end end[/CODE] I am very newbie and I was wondering how I would add models for the other teams. I have two other teams. Would I use an else statement inside the if statement for the other teams or would I use another if statement inside the function? Maybe both of those are wrong? Thanks.[/QUOTE] You would replace the end with an elseif: [CODE]function plymodels( ply ) if ply:Team() == 1 then ply:SetModel( "models/player/combine_soldier.mdl" ) elseif ply:Team() == 2 then ply:SetModel( "models/player/someothermodel.mdl" ) end end[/CODE] and you can add as many elseifs as you want, as long as it has an end at the end.
Okay, thanks. I actually just figured out the elseif from another snippet of the code.
Sorry, you need to Log In to post a reply to this thread.