PlayerButtonEvents.Api
1.3.0-alpha
This is a prerelease version of PlayerButtonEvents.Api.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package PlayerButtonEvents.Api --version 1.3.0-alpha
NuGet\Install-Package PlayerButtonEvents.Api -Version 1.3.0-alpha
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PlayerButtonEvents.Api" Version="1.3.0-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PlayerButtonEvents.Api --version 1.3.0-alpha
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PlayerButtonEvents.Api, 1.3.0-alpha"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PlayerButtonEvents.Api as a Cake Addin #addin nuget:?package=PlayerButtonEvents.Api&version=1.3.0-alpha&prerelease // Install PlayerButtonEvents.Api as a Cake Tool #tool nuget:?package=PlayerButtonEvents.Api&version=1.3.0-alpha&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
PlayerButtonEvents
PlayerButtonEvents is a library that provides events for handling button presses in CS2. It allows developers to easily subscribe to and handle events triggered when a player presses or releases buttons.
Features
- Exposes events for button presses
Installation
Usage
-or-
public class PlayerButtonEventsTestPlugin(ButtonEventBehavior buttonEventBehavior, ButtonEvents buttonEvents)
: BasePlugin
{
public override void Load(bool hotReload)
{
buttonEventBehavior.OnLoad(this);
buttonEvents.ButtonPressed += OnButtonPressed;
buttonEvents.ButtonReleased += OnButtonReleased;
}
public override void Unload(bool hotReload)
{
buttonEvents.ButtonPressed -= OnButtonPressed;
buttonEvents.ButtonReleased -= OnButtonReleased;
buttonEventBehavior.OnUnload(this);
}
/*
ButtonEventArgs contains
Slot => The <slot> the player takes up in the server, get the controller with `Utilities.GetPlayerFromSlot`
Button => The *single* button this event is for, if the player pressed D, it will be PlayerButtons.Moveright
IsPressed => Whether the button has been pressed or released, only really useful if you're doing a ButtonStateChanged hook
*/
private void OnButtonPressed(object? sender, ButtonEventArgs e)
{
var controller = Utilities.GetPlayerFromSlot(e.Slot);
Server.PrintToChatAll($"Button pressed: {e.Button} by {controller.PlayerName}");
}
private void OnButtonReleased(object? sender, ButtonEventArgs e)
{
var controller = Utilities.GetPlayerFromSlot(e.Slot);
Server.PrintToChatAll($"Button released: {e.Button} by {controller.PlayerName}");
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- CounterStrikeSharp.API (>= 1.0.255)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.2.0 | 127 | 9/1/2024 |
2.2.0-alpha | 84 | 9/1/2024 |
2.0.0 | 131 | 8/15/2024 |
1.3.0-alpha | 103 | 8/15/2024 |
1.2.0-alpha | 96 | 8/15/2024 |
1.1.0-alpha-gc14124b463 | 101 | 8/15/2024 |
1.1.0-alpha-g96e896edf3 | 101 | 8/15/2024 |