NativeVoteAPI-CS2
0.2.4
dotnet add package NativeVoteAPI-CS2 --version 0.2.4
NuGet\Install-Package NativeVoteAPI-CS2 -Version 0.2.4
<PackageReference Include="NativeVoteAPI-CS2" Version="0.2.4" />
<PackageVersion Include="NativeVoteAPI-CS2" Version="0.2.4" />
<PackageReference Include="NativeVoteAPI-CS2" />
paket add NativeVoteAPI-CS2 --version 0.2.4
#r "nuget: NativeVoteAPI-CS2, 0.2.4"
#addin nuget:?package=NativeVoteAPI-CS2&version=0.2.4
#tool nuget:?package=NativeVoteAPI-CS2&version=0.2.4
NativeVoteAPI CS2
CounterStrikeSharp implementation of API for Counter-Strike 2's native vote.
Caution
This is just an API for native vote!
This API does not provide standalone functionality. You need to create your own plugin to use it.
Features
- Basic vote management
- Panorama vote UI
- Event system (on vote fail, pass, cancel)
Setup
- Download NativeVoteAPI from latest Release
- Put into your
game/csgo/addons/counterstrikesharp/
directory - Ready to use this API
Development
Setup
- Create or go to your existing project
- run
dotnet add package NativeVoteAPI-CS2
- Ready to develop.
Full example is here: NativeVoteAPITest.cs
Using custom string in vote text
Since valve fixed a XSS exploit in html text, we can't use custom string in normal mean.
When we provide custom UI text in a platform_<language name>.txt
file (e.g. platform_english.txt) and place it in the game/csgo/resource/
directory on both server and client, we can use custom text from the plugin.
Note
We can use pictures using <img src='{s:s1}'>
, but it will display only once. after second one is not showing correctly.
Example
platform_english.txt
"lang"
{
"Language" "English"
"Tokens"
{
"SFUI_vote_custom_vote_default" "{s:s1}"
"SFUI_vote_custom_vote_green" "<font color='#00FF00'>{s:s1}</font>"
"SFUI_vote_custom_vote_red" "<font color='#FF0000'>{s:s1}</font>"
"SFUI_vote_custom_vote_blue" "<font color='#0000FF'>{s:s1}</font>"
"SFUI_vote_custom_vote_image" "<img src='{s:s1}'>"
}
}
Plugin code (edit from NativeVoteApiTest.cs)
var potentialClients = Utilities.GetPlayers().Where(p => p is { IsBot: false, IsHLTV: false }).ToList();
var potentialClientsIndex = potentialClients.Select(p => p.Index).ToList();
string displayString = "#SFUI_vote_custom_vote_default";
string detailsString = "Custom string that will displayed in vote";
string voteIdentifier = "TEST_VOTE!";
NativeVoteInfo nInfo = new NativeVoteInfo(voteIdentifier, displayString ,detailsString, potentialClientsIndex, VoteThresholdType.AbsoluteValue, 0.5F, 5.0F);
// When the vote is successfully initiated, it will return InitializeAccepted.
NativeVoteState state = _nativeVoteApi.InitiateVote(nInfo);
Special thanks
- CS2Fixes for the reference of UserMessage and Panorama UI
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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- CounterStrikeSharp.API (>= 1.0.305)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.