Custom Gamemode Help

Hello,

So I am trying to create my own Garry’s Mod Gamemode.

Its a RP gamemode, and what I’m trying to do is make couple of jobs with team.SetUp.


function GM:PlayerInitialSpawn( ply ) --"When the player first joins the server and spawns" function
 
    ply:SetTeam( 1 ) --Add the player to team 1
 
end --End the "when player first joins server and spawns" function

function GM:PlayerInitialSpawn( ply ) --"When the player first joins the server and spawns" function
 
    ply:ConCommand( "team_menu" ) --Run the console command when the player first spawns
 
end --End the "when player first joins server and spawn" function
 
 
function GM:PlayerLoadout( ply ) --Weapon/ammo/item function
 
    if ply:Team() == 1 then --If player team equals 1
 
        ply:Give( "weapon_physcannon" ) --Give them the Gravity Gun
		ply:Give( "weapon_physgun" ) --Give them the Physics Gun
		ply:Give( "gmod_camera" ) -- Gives the camera
		
	elseif ply:Team() == 2 then -- If the player is a Gun Dealer then
	    ply:Give( "weapon_physcannon" ) --Give them the Gravity Gun
		ply:Give( "weapon_physgun" ) --Give them the Physics Gun
		ply:Give( "gmod_camera" ) -- Gives the camera
		
	elseif ply:Team() == 3 then -- If the player is a Gun Dealer then
	    ply:Give( "weapon_physcannon" ) --Give them the Gravity Gun
		ply:Give( "weapon_physgun" ) --Give them the Physics Gun
		ply:Give( "weapon_medkit" ) -- Gives the medkit to the paramedic
		ply:Give( "gmod_camera" ) -- Gives the camera
		ply:SetModel( "models/player/kleiner.mdl" ) --Set the players model
 
 	elseif ply:Team() == 4 then -- If the player is a Gun Dealer then
	    ply:Give( "weapon_physcannon" ) --Give them the Gravity Gun
		ply:Give( "weapon_physgun" ) --Give them the Physics Gun
		ply:Give( "weapon_usp45" ) --Give them a USP .45
		ply:Give( "gmod_camera" ) -- Gives the camera
		
	elseif ply:Team() == 5 then -- If the player is a Gun Dealer then
	    ply:Give( "weapon_physcannon" ) --Give them the Gravity Gun
		ply:Give( "weapon_physgun" ) --Give them the Physics Gun
		ply:Give( "gmod_camera" ) -- Gives the camera
		ply:Give( "weapon_usp45" ) --Give them a USP .45
		ply:Give( "weapon_mp5" ) --Give them a MP5
		
    end --Here we end the if condition
 
end --Here we end the Loadout function

-- team Commands

function team_1( ply )
 
    ply:SetTeam( 1 )
    ply:Spawn()
end
 
function team_2( ply )
 
    ply:SetTeam( 2 )
	ply:Spawn()
end

function team_3( ply )
 
    ply:SetTeam( 3 )
	ply:Spawn()
end

function team_4( ply )
 
    ply:SetTeam( 4 )
	ply:Spawn()
end

function team_5( ply )
 
    ply:SetTeam( 5 )
	ply:Spawn()
end
 
concommand.Add( "citizen", team_1 ) // Made this command to become a fckn Citzen (Starter team)
concommand.Add( "gundealer", team_2 ) // Add the command to become  a gun dealer mate.
concommand.Add( "paramedic", team_3 ) // Add the command to become  a gun dealer mate.
concommand.Add( "policeofficer", team_4 ) // Add the command to become  a gun dealer mate.
concommand.Add( "policesergeant", team_5 ) // Add the command to become  a gun dealer mate.

I believe this code is correct, but its not apparently.
What the problem is:

  • Not opening the command on spawn.
  • Not spawning u with Team 1.
  • Doesnt reconize the commands.

If someone can help me,
Thanks.

  • Hassan

To start off, you defined PlayerInitialSpawn twice

Merge their content instead
[lua]

function GM:PlayerInitialSpawn( ply ) --“When the player first joins the server and spawns” function

ply:SetTeam( 1 ) --Add the player to team 1
ply:ConCommand( "team_menu" ) --Run the console command when the player first spawns

end --End the “when player first joins server and spawns” function
[/lua]