Basically, the Prop Hunt gamemode that I’m running on a server doesn’t indicate in chat when a player switches teams. As you can imagine, that is an issue, and so I’ve spent the past few hours digging in all of the source code to find where the actual team switch line was, and lo’ and behold, I found it within Fretta;
local func = function() RunConsoleCommand( "changeteam", ID ) end
The issue I face is that I’m not seeing anyway to turn this local function into something that can record the username of the switching player and display it in chat everytime the function is called. While getting the actual message to print is simple, I’m struggling to figure out how to record and insert the username of each player who switches within the gamemode into this chat message. The local function is apart of this larger function within the cl_selectscreen.lua file:
function GM:ShowTeam() if ( !IsValid( TeamPanel ) ) then TeamPanel = vgui.CreateFromTable( vgui_Splash ) TeamPanel:SetHeaderText( "Choose Team" ) local AllTeams = team.GetAllTeams() for ID, TeamInfo in SortedPairs ( AllTeams ) do if ( ID != TEAM_CONNECTING && ID != TEAM_UNASSIGNED && ( ID != TEAM_SPECTATOR || GAMEMODE.AllowSpectating ) && team.Joinable(ID) ) then if ( ID == TEAM_SPECTATOR ) then TeamPanel:AddSpacer( 10 ) end local strName = TeamInfo.Name local func = function() RunConsoleCommand( "changeteam", ID ) ChatPrint( " have been swapped!") end local btn = TeamPanel:AddSelectButton( strName, func ) btn.m_colBackground = TeamInfo.Color btn.Think = function( self ) self:SetText( Format( "%s (%i)", strName, team.NumPlayers( ID ) )) self:SetDisabled( GAMEMODE:TeamHasEnoughPlayers( ID ) ) end if ( IsValid( LocalPlayer() ) && LocalPlayer():Team() == ID ) then btn:SetDisabled( true ) end end end
Does anyone have any experience with this particular issue, or something similar? Any assistance would be incredible.