Skip to content

Commit

Permalink
Add connection check in next frame
Browse files Browse the repository at this point in the history
  • Loading branch information
MSWS authored Feb 8, 2024
1 parent 3897845 commit 5d91648
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions src/NoBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private HookResult Event_PlayerSpawn(EventPlayerSpawn @event, GameEventInfo info
// This is called upon just after the player spawns
private void PlayerSpawnNextFrame(CCSPlayerController player, CHandle<CCSPlayerPawn> pawn)
{
if (!player.IsValid || !pawn.IsValid)
if (!player.IsValid || !pawn.IsValid || player.Connected != PlayerConnectedState.PlayerConnected)
return;
// Changes the player's collision to 16, allowing the player to pass through other players while still take damage from bullets and knife attacks
pawn.Value.Collision.CollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_DISSOLVING;
Expand All @@ -116,31 +116,6 @@ private void PlayerSpawnNextFrame(CCSPlayerController player, CHandle<CCSPlayerP
}



// The IsValid class is used for validating entities
internal static class IsValid
{
// Returns true if the player's index is valid
public static bool PlayerIndex(uint playerIndex)
{
// If the player's index is 0 then execute this section
if(playerIndex == 0)
{
return false;
}

// If the client's index value is not within the range it should be then execute this section
if(!(1 <= playerIndex && playerIndex <= Server.MaxPlayers))
{
return false;
}

return true;
}
}



// NOTE:
// This class was made by KillStr3aK / Bober repository and allows you to perform actions depending on whether the server is running a linux or windows operating system
// - https://github.com/KillStr3aK/CSSharpTests/blob/master/Models/WIN_LINUX.cs
Expand Down

0 comments on commit 5d91648

Please sign in to comment.