Skip to content

Commit

Permalink
update dotnet, cs#, null check compat update
Browse files Browse the repository at this point in the history
  • Loading branch information
jithatsonei committed May 18, 2024
1 parent 3897845 commit 368d185
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 16 deletions.
4 changes: 2 additions & 2 deletions NoBlock.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.141" />
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.233" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions NoBlock.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoBlock", "NoBlock.csproj", "{5650B4BF-32CD-444D-9B4B-FB8B965D41A5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5650B4BF-32CD-444D-9B4B-FB8B965D41A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5650B4BF-32CD-444D-9B4B-FB8B965D41A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5650B4BF-32CD-444D-9B4B-FB8B965D41A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5650B4BF-32CD-444D-9B4B-FB8B965D41A5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F3DE5C84-A87D-4AE6-9C85-A8F9901A7AD4}
EndGlobalSection
EndGlobal
30 changes: 16 additions & 14 deletions src/NoBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
namespace NoBlock;

// Defines the minimum version of CounterStrikeSharp required in order to run this plugin on the server
[MinimumApiVersion(96)]
[MinimumApiVersion(233)]

// Specifies our main class, this should match the name of the namespace
public class NoBlock : BasePlugin
{
// The retrievable information about the plugin itself
public override string ModuleName => "[Custom] No Block";
public override string ModuleAuthor => "Manifest @Road To Glory & WD-";
public override string ModuleAuthor => "Manifest @Road To Glory & WD- & Forked by EdgeGamers Organization";
public override string ModuleDescription => "Allows for players to walk through each other without being stopped due to colliding.";
public override string ModuleVersion => "V. 1.0.1 [Beta]";
public override string ModuleVersion => "1.0.2";

// Sets the correct offset data for our collision rules change in accordance with the server's operating system
private readonly WIN_LINUX<int> OnCollisionRulesChangedOffset = new WIN_LINUX<int>(173, 172);
Expand All @@ -66,7 +66,7 @@ public override void Load(bool hotReload)
private HookResult Event_PlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
{
// Finds and validates the CCSPlayerController, despite it being referenced as "Userid" it is in fact the CCSPlayerController
if (!@event.Userid.IsValid)
if (@event.Userid == null)
{
return HookResult.Continue;
}
Expand Down Expand Up @@ -99,19 +99,21 @@ 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)
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;
if (pawn.Value is not null)
{
// 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;

// Changes the player's CollisionAttribute to the collision type used for dissolving objects
pawn.Value.Collision.CollisionAttribute.CollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_DISSOLVING;
// Changes the player's CollisionAttribute to the collision type used for dissolving objects
pawn.Value.Collision.CollisionAttribute.CollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_DISSOLVING;

// Updates the CollisionRulesChanged for the specific player
VirtualFunctionVoid<nint> collisionRulesChanged = new VirtualFunctionVoid<nint>(pawn.Value.Handle, OnCollisionRulesChangedOffset.Get());
// Updates the CollisionRulesChanged for the specific player
VirtualFunctionVoid<nint> collisionRulesChanged = new VirtualFunctionVoid<nint>(pawn.Value.Handle, OnCollisionRulesChangedOffset.Get());

// Invokes the updated CollisionRulesChanged information to ensure the player's collision is correctly set
collisionRulesChanged.Invoke(pawn.Value.Handle);
// Invokes the updated CollisionRulesChanged information to ensure the player's collision is correctly set
collisionRulesChanged.Invoke(pawn.Value.Handle);
}
return;
}
}

Expand Down

0 comments on commit 368d185

Please sign in to comment.