Skip to content

Commit

Permalink
Publish NuGet package for ZombieSharpAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
oylsister committed Nov 12, 2024
1 parent 9b7f633 commit 55a6dd7
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ZombieSharpAPI/IZombieSharpAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,25 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<PublishDir>./</PublishDir>
<Title>ZombieSharpAPI</Title>
<Description>API project for CounterStrikeSharp plugin ZombieSharp</Description>
<PackageProjectUrl>https://github.com/oylsister/ZombieSharp</PackageProjectUrl>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<FileVersion>1.2.7.1</FileVersion>
<Version>1.2.7.1</Version>
<Authors>Oylsister</Authors>
<AssemblyVersion>1.2.7.1</AssemblyVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\LICENSE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.282">
<PrivateAssets>none</PrivateAssets>
Expand All @@ -17,4 +34,11 @@
</PackageReference>
</ItemGroup>

<ItemGroup>
<None Update="README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

</Project>
58 changes: 58 additions & 0 deletions ZombieSharpAPI/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# ZombieSharpAPI

This API is provided for using with [ZombieSharp](https://github.com/oylsister/ZombieSharp)

### API Example
Check out [ZombieTest](https://github.com/oylsister/ZombieSharp/blob/main/ZombieTest/ZombieTest.cs) for other API usages example.
```cs
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Capabilities;
using ZombieSharpAPI;

namespace ZombieTest
{
public class ZombieTest : BasePlugin
{
public override string ModuleName => "Zombie Test";
public override string ModuleVersion => "1.0";

// Declare Capability First.
public static PluginCapability<IZombieSharpAPI> ZombieCapability { get; } = new("zombiesharp");

// Declare API class
IZombieSharpAPI? API;

public override void OnAllPluginsLoaded(bool hotReload)
{
// Get Capability.
API = ZombieCapability.Get()!;

// Excute Hook function
API.Hook_OnInfectClient(ZS_OnInfectClient);
}

// Hook function is here.
public HookResult ZS_OnInfectClient(ref CCSPlayerController client, ref CCSPlayerController attacker, ref bool motherzombie, ref bool force, ref bool respawn)
{
// check which client is infect.
Server.PrintToChatAll($"{client.PlayerName} is infected");

// if client name is Oylsister
if (client.PlayerName == "Oylsister")
{
Server.PrintToChatAll("Oylsister is immunity");

// Blocking infected
return HookResult.Handled;
}

if (force)
Server.PrintToChatAll($"by forcing.");

// Always use HookResult.Continue to allowing other player get infect as usual.
return HookResult.Continue;
}
}
}
```

0 comments on commit 55a6dd7

Please sign in to comment.