• playerlist
    6 replies, posted
In my gamemode, i need one player to be chosen at random. but i cant figure out how to select him. could someone help me?
[lua]local randomplayer = table.Random( player.GetAll( ) )[/lua]
function GM:think() if class.NumPlayers( class_juggernaut ) < 1 then local randomguy = table.Random( player.GetAll( ) ) randomguy:SetClass( class_juggernaut ) randomguy:Spawn() end end thats what i have written. shouldn't someone at random be chosen to become the juggernaut if there is less than 1 in the juggernaut class? or do a player need to die to switch?
[lua]if team.NumPlayers( class_juggernaut ) < 1 then local randomguy = table.Random( player.GetAll( ) ) randomguy:SetTeam( class_juggernaut ) randomguy:Spawn( ) end[/lua]
[QUOTE=MakeR;18767705][lua]if team.NumPlayers( class_juggernaut ) < 1 then local randomguy = table.Random( player.GetAll( ) ) randomguy:SetTeam( class_juggernaut ) randomguy:Spawn( ) end[/lua][/QUOTE] but juggernaut is a class, not a team will it still work?
[QUOTE=blackburnswe;18769498]but juggernaut is a class, not a team will it still work?[/QUOTE] No, I didn't think you could set classes like that.
[QUOTE=MakeR;18769538]No, I didn't think you could set classes like that.[/QUOTE] but does the player change team instantaneous or after that life/round?
Sorry, you need to Log In to post a reply to this thread.