@@ -167,7 +167,6 @@ internal SummonedCustomRole(Player player, ICustomRole role, Triplet<string, str
167167
168168 if ( Role . Team is not null && Role . Team != Role . Role . GetTeam ( ) )
169169 {
170- DisguiseTeam . Set ( Player . PlayerId , ( Team ) Role . Team ) ;
171170 EvaluateRoleBase ( ) ;
172171 LogManager . Debug ( $ "EVALUATED ROLEBASE { _roleBase ? . GetType ( ) . FullName } with team { _roleBase ? . Team } ") ;
173172 }
@@ -190,6 +189,9 @@ internal SummonedCustomRole(Player player, ICustomRole role, Triplet<string, str
190189 {
191190 Timing . CallDelayed ( 0.75f , ( ) =>
192191 {
192+ if ( ! _internalValid || Player is null || ! Player . IsAlive )
193+ return ;
194+
193195 LogManager . Debug ( $ "Changing the appearance of the role { Role . Id } [{ Role . Name } ] to { Role . RoleAppearance } ") ;
194196
195197 if ( LabApiExtensions . IsAvailable )
@@ -203,7 +205,7 @@ internal SummonedCustomRole(Player player, ICustomRole role, Triplet<string, str
203205 }
204206
205207 /// <summary>
206- /// Try to set <see cref="_roleBase "/> in order to override the current Player.Role.Base to trick the server into thinking that the player is / is not an Human
208+ /// Try to set <see cref="RoleBase "/> in order to override the current Player.Role.Base to trick the server into thinking that the player is / is not an Human
207209 /// </summary>
208210 private void EvaluateRoleBase ( )
209211 {
@@ -257,15 +259,15 @@ private void EvaluateRoleBase()
257259 SpectatorModule = originalRole . SpectatorModule
258260 } ;
259261
260- DisguiseTeam . SetRoleBase ( Player . PlayerId , _roleBase ) ;
262+ DisguiseTeam . Set ( Player . PlayerId , Role . Team ?? Role . Role . GetTeam ( ) , _roleBase ) ;
261263
262264 Timing . CallDelayed ( 3.25f , delegate
263265 {
264266 if ( ! _internalValid || _roleBase is null )
265267 return ;
266268
267269 _roleBase . Pooled = false ;
268- DisguiseTeam . SetRoleBase ( Player . PlayerId , _roleBase ) ;
270+ DisguiseTeam . Set ( Player . PlayerId , Role . Team ?? Role . Role . GetTeam ( ) , _roleBase ) ;
269271 } ) ;
270272 }
271273 catch ( Exception e )
@@ -648,7 +650,7 @@ public static bool TryCheckForCustomTeam(ReferenceHub player, Team teamCheck, ou
648650 /// <param name="player"></param>
649651 /// <param name="def"></param>
650652 /// <returns></returns>
651- public static Team TryGetCusomTeam ( ReferenceHub player , Team ? def = null )
653+ public static Team TryGetCustomTeam ( ReferenceHub player , Team ? def = null )
652654 {
653655 if ( TryGet ( player , out SummonedCustomRole customRole ) && customRole . Role . Team is not null && customRole . Role . Team != customRole . Role . Role . GetTeam ( ) )
654656 return ( Team ) customRole . Role . Team ;
0 commit comments