Skip to content

PlayerCanJoinTeam called as a hook #2236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions garrysmod/gamemodes/base/gamemode/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -623,18 +623,16 @@ end
-----------------------------------------------------------]]
function GM:PlayerRequestTeam( ply, teamid )

-- No changing teams if not teambased!
if ( !GAMEMODE.TeamBased ) then return end

-- This team isn't joinable
if ( !team.Joinable( teamid ) ) then
ply:ChatPrint( "You can't join that team" )
return end
return
end

-- This team isn't joinable
if ( !GAMEMODE:PlayerCanJoinTeam( ply, teamid ) ) then
-- Messages here should be outputted by this function
return end
if ( !hook.Call( "PlayerCanJoinTeam", self, ply, teamid ) ) then
return
end

GAMEMODE:PlayerJoinTeam( ply, teamid )

Expand Down Expand Up @@ -820,7 +818,15 @@ end
function GM:PlayerButtonDown( ply, btn ) end
function GM:PlayerButtonUp( ply, btn ) end

concommand.Add( "changeteam", function( pl, cmd, args ) hook.Call( "PlayerRequestTeam", GAMEMODE, pl, tonumber( args[ 1 ] ) ) end )
concommand.Add( "changeteam", function( pl, cmd, args )
local teamid = tonumber( args[ 1 ] )

if ( teamid == nil ) then
return
end

hook.Call( "PlayerRequestTeam", GAMEMODE, pl, teamid )
end )

--[[---------------------------------------------------------
Name: gamemode:HandlePlayerArmorReduction()
Expand Down