Skip to content

Commit d9c60a4

Browse files
author
Max
committed
PlayerCanJoinTeam called as a hooks intead of a function
1 parent 7324e6e commit d9c60a4

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

garrysmod/gamemodes/base/gamemode/player.lua

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -623,18 +623,16 @@ end
623623
-----------------------------------------------------------]]
624624
function GM:PlayerRequestTeam( ply, teamid )
625625

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

629-
-- This team isn't joinable
630628
if ( !team.Joinable( teamid ) ) then
631629
ply:ChatPrint( "You can't join that team" )
632-
return end
630+
return
631+
end
633632

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

639637
GAMEMODE:PlayerJoinTeam( ply, teamid )
640638

@@ -820,7 +818,15 @@ end
820818
function GM:PlayerButtonDown( ply, btn ) end
821819
function GM:PlayerButtonUp( ply, btn ) end
822820

823-
concommand.Add( "changeteam", function( pl, cmd, args ) hook.Call( "PlayerRequestTeam", GAMEMODE, pl, tonumber( args[ 1 ] ) ) end )
821+
concommand.Add( "changeteam", function( pl, cmd, args )
822+
local teamid = tonumber( args[ 1 ] )
823+
824+
if ( teamid == nil ) then
825+
return
826+
end
827+
828+
hook.Call( "PlayerRequestTeam", GAMEMODE, pl, teamid )
829+
end )
824830

825831
--[[---------------------------------------------------------
826832
Name: gamemode:HandlePlayerArmorReduction()

0 commit comments

Comments
 (0)