Alright, so I know the command mp_autoteambalance "1" does not work. Right now I have an issue of teams being mostly props (team switching, etc.) I know the core of the commands are in the fretta gamemode, and I actually found where the autobalance is, but I have tried editing the fretta before and crashed my server. Here is the init.lua file with my GM settings:
[CODE]/*
init.lua - Server Component
-----------------------------------------------------
The entire server side bit of Fretta starts here.
*/
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( 'skin.lua' )
AddCSLuaFile( 'player_class.lua' )
AddCSLuaFile( 'class_default.lua' )
AddCSLuaFile( 'cl_splashscreen.lua' )
AddCSLuaFile( 'cl_selectscreen.lua' )
AddCSLuaFile( 'cl_gmchanger.lua' )
AddCSLuaFile( 'cl_help.lua' )
AddCSLuaFile( 'player_extension.lua' )
AddCSLuaFile( 'vgui/vgui_hudlayout.lua' )
AddCSLuaFile( 'vgui/vgui_hudelement.lua' )
AddCSLuaFile( 'vgui/vgui_hudbase.lua' )
AddCSLuaFile( 'vgui/vgui_hudcommon.lua' )
AddCSLuaFile( 'vgui/vgui_gamenotice.lua' )
AddCSLuaFile( 'vgui/vgui_scoreboard.lua' )
AddCSLuaFile( 'vgui/vgui_scoreboard_team.lua' )
AddCSLuaFile( 'vgui/vgui_scoreboard_small.lua' )
AddCSLuaFile( 'vgui/vgui_vote.lua' )
AddCSLuaFile( 'cl_hud.lua' )
AddCSLuaFile( 'cl_deathnotice.lua' )
AddCSLuaFile( 'cl_scores.lua' )
AddCSLuaFile( 'cl_notify.lua' )
AddCSLuaFile( 'player_colours.lua' )
include( "shared.lua" )
include( "sv_gmchanger.lua" )
include( "sv_spectator.lua" )
include( "round_controller.lua" )
include( "utility.lua" )
GM.ReconnectedPlayers = {}
function GM:Initialize()
util.AddNetworkString("PlayableGamemodes")
util.AddNetworkString("RoundAddedTime")
util.AddNetworkString("PlayableGamemodes")
util.AddNetworkString("fretta_teamchange")
-- If we're round based, wait 3 seconds before the first round starts
if ( GAMEMODE.RoundBased ) then
timer.Simple( 3, function() GAMEMODE:StartRoundBasedGame() end )
end
if ( GAMEMODE.AutomaticTeamBalance ) then
timer.Create( "CheckTeamBalance", 5, 0, function() GAMEMODE:CheckTeamBalance() end )
end
end
function GM:Think()
self.BaseClass:Think()
for k,v in pairs( player.GetAll() ) do
local Class = v:GetPlayerClass()
if ( !Class ) then return end
v:CallClassFunction( "Think" )
end
// Game time related
if( !GAMEMODE.IsEndOfGame && ( !GAMEMODE.RoundBased || ( GAMEMODE.RoundBased && GAMEMODE:CanEndRoundBasedGame() ) ) && CurTime() >= GAMEMODE.GetTimeLimit() ) then
GAMEMODE:EndOfGame( true )
end
end
/*---------------------------------------------------------
Name: gamemode:CanPlayerSuicide( Player ply )
Desc: Is the player allowed to commit suicide?
---------------------------------------------------------*/
function GM:CanPlayerSuicide( ply )
if( ply:Team() == TEAM_UNASSIGNED || ply:Team() == TEAM_SPECTATOR ) then
return false // no suicide in spectator mode
end
return !GAMEMODE.NoPlayerSuicide
end
/*---------------------------------------------------------
Name: gamemode:PlayerSwitchFlashlight( Player ply, Bool on )
Desc: Can we turn our flashlight on or off?
---------------------------------------------------------*/
function GM:PlayerSwitchFlashlight( ply, on )
if ( ply:Team() == TEAM_SPECTATOR || ply:Team() == TEAM_UNASSIGNED || ply:Team() == TEAM_CONNECTING ) then
return not on
end
return ply:CanUseFlashlight()
end
/*---------------------------------------------------------
Name: gamemode:PlayerInitialSpawn( Player ply )
Desc: Our very first spawn in the game.
---------------------------------------------------------*/
function GM:PlayerInitialSpawn( pl )
pl:SetTeam( TEAM_UNASSIGNED )
pl:SetPlayerClass( "Spectator" )
pl.m_bFirstSpawn = true
pl:UpdateNameColor()
GAMEMODE:CheckPlayerReconnected( pl )
end
function GM:CheckPlayerReconnected( pl )
if table.HasValue( GAMEMODE.ReconnectedPlayers, pl:UniqueID() ) then
GAMEMODE:PlayerReconnected( pl )
end
end
/*---------------------------------------------------------
Name: gamemode:PlayerReconnected( Player ply )
Desc: Called if the player has appeared to have reconnected.
---------------------------------------------------------*/
function GM:PlayerReconnected( pl )
// Use this hook to do stuff when a player rejoins and has been in the server previously
end
function GM:PlayerDisconnected( pl )
table.insert( GAMEMODE.ReconnectedPlayers, pl:UniqueID() )
self.BaseClass:PlayerDisconnected( pl )
end
function GM:ShowHelp( pl )
pl:SendLua( "GAMEMODE:ShowHelp()" )
end
function GM:PlayerSpawn( pl )
pl:UpdateNameColor()
// The player never spawns straight into the game in Fretta
// They spawn as a spectator first (during the splash screen and team picking screens)
if ( pl.m_bFirstSpawn ) then
pl.m_bFirstSpawn = nil
if ( pl:IsBot() ) then
GAMEMODE:AutoTeam( pl )
// The bot doesn't send back the 'seen splash' command, so fake it.
if ( !GAMEMODE.TeamBased && !GAMEMODE.NoAutomaticSpawning ) then
pl:Spawn()
end
else
pl:StripWeapons()
GAMEMODE:PlayerSpawnAsSpectator( pl )
// Follow a random player until we join a team
if ( #player.GetAll() > 1 ) then
pl:Spectate( OBS_MODE_CHASE )
pl:SpectateEntity( table.Random( player.GetAll() ) )
end
end
return
end
pl:CheckPlayerClassOnSpawn()
if ( GAMEMODE.TeamBased && ( pl:Team() == TEAM_SPECTATOR || pl:Team() == TEAM_UNASSIGNED ) ) then
GAMEMODE:PlayerSpawnAsSpectator( pl )
return
end
// Stop observer mode
pl:UnSpectate()
// Call item loadout function
hook.Call( "PlayerLoadout", GAMEMODE, pl )
// Set player model
hook.Call( "PlayerSetModel", GAMEMODE, pl )
// Call class function
pl:OnSpawn()
end
function GM:PlayerLoadout( pl )
pl:CheckPlayerClassOnSpawn()
pl:OnLoadout()
// Switch to prefered weapon if they have it
local cl_defaultweapon = pl:GetInfo( "cl_defaultweapon" )
if ( pl:HasWeapon( cl_defaultweapon ) ) then
pl:SelectWeapon( cl_defaultweapon )
end
end
function GM:PlayerSetModel( pl )
pl:OnPlayerModel()
end
function GM:AutoTeam( pl )
if ( !GAMEMODE.AllowAutoTeam ) then return end
if ( !GAMEMODE.TeamBased ) then return end
GAMEMODE:PlayerRequestTeam( pl, team.BestAutoJoinTeam() )
end
concommand.Add( "autoteam", function( pl, cmd, args ) hook.Call( "AutoTeam", GAMEMODE, pl ) end )
function GM:PlayerRequestClass( ply, class, disablemessage )
local Classes = team.GetClass( ply:Team() )
if (!Classes) then return end
local RequestedClass = Classes[ class ]
if (!RequestedClass) then return end
if ( ply:Alive() && SERVER ) then
if ( ply.m_SpawnAsClass && ply.m_SpawnAsClass == RequestedClass ) then return end
ply.m_SpawnAsClass = RequestedClass
if ( !disablemessage ) then
ply:ChatPrint( "Your class will change to '".. player_class.GetClassName( RequestedClass ) .. "' when you respawn" )
end
else
self:PlayerJoinClass( ply, RequestedClass )
ply.m_SpawnAsClass = nil
end
end
concommand.Add( "changeclass", function( pl, cmd, args ) hook.Call( "PlayerRequestClass", GAMEMODE, pl, tonumber(args[1]) ) end )
local function SeenSplash( ply )
if ( ply.m_bSeenSplashScreen ) then return end
ply.m_bSeenSplashScreen = true
if ( !GAMEMODE.TeamBased && !GAMEMODE.NoAutomaticSpawning ) then
ply:KillSilent()
end
end
concommand.Add( "seensplash", SeenSplash )
function GM:PlayerJoinTeam( ply, teamid )
local iOldTeam = ply:Team()
if ( ply:Alive() ) then
if ( iOldTeam == TEAM_SPECTATOR || (iOldTeam == TEAM_UNASSIGNED && GAMEMODE.TeamBased) ) then
ply:KillSilent()
else
ply:Kill()
end
end
ply:SetTeam( teamid )
ply.LastTeamSwitch = RealTime()
local Classes = team.GetClass( teamid )
// Needs to choose class
if ( Classes && #Classes > 1 ) then
if ( ply:IsBot() || !GAMEMODE.SelectClass
Oh dear, you've over complicated this. You don't need to modify fretta itself, but if you go into shared.lua, you'll find a bunch of variables. Inside it, you'll find some to do with auto balance. Make sure you've got it set to
[code]
GM.AutomaticTeamBalance = true
GM.ForceJoinBalancedTeams = true
[/code]
This should be all you need!
Oh wow, thanks lol. I never knew it was that easy......I feel a bit stupid now.
Sorry, you need to Log In to post a reply to this thread.