Settings teams for custom gamemode, and also giving weapons to certain teams.

I’m currently making a custom gamemode named “Dark Realm.” The game involves 2 teams; Humans and Ghosts. I need help by having the gamemode choose the teams randomly for the players. I also need help on assigning certain weapons to certain teams. How could I do this?

Here’s the shared.lua code:


GM.Name = "Dark Realm"
GM.Author = "<redacted>"
GM.Email = "N/A"
GM.Website = "N/A"

team.SetUp( 1, 'Humans', Color( 0, 109, 163 ) )
team.SetUp( 2, 'Ghosts', Color( 163, 0, 0 ) )

local class = {}
	class.WalkSpeed = 150
	class.RunSpeed = 300
	class.MaxHealth = 100
	class.StartHealth = 100
	class.TeammateNoCollide = true
	class.JumpPower = 200
	class.WeaponLoadout = function( info )
		
			info.Player:Give( "weapon_crowbar" )
			info.Player:Give( "weapon_357" )
		
	end
	
player_manager.RegisterClass( "humans", class, "player_default" )

If you need the init.lua code, let me know.

You should know how to use this:

team.BestAutoJoinTeam

Sometimes it not knowing about how to use something but knowing that, that something exist.

Back when i made my first gmod gamemode I made my own custom AutoJoin team function only to find out later it already existed in the game.

:p, I wanted to use MrCosmicSeagull’s way, but then I saw that one too :wink: