-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish NuGet package for ZombieSharpAPI
- Loading branch information
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
``` |