CounterStrikeSharpTemplates is a thoughtfully designed template set for kick-starting your plugin development for the great CounterStrikeSharp. The templates offer foundational structures and useful functions, along with pre-configured GitHub workflows, making the initiation of plugin development a breeze. With adaptable templates and an automated version control system, it caters to both beginners and experienced developers alike.
- Install the .NET 8.0 SDK.
- Install the templates package:
dotnet new install CounterStrikeSharpTemplates
Currently available templates:
default
: сreates a basic plugin template.config
: сreates a plugin template that includes a configuration.lang
: сreates a plugin template that includes a language.configlang
: сreates a plugin template that includes both a configuration and a language.datamysql
: сreates a plugin template that includes a database (MySQL), language, configuration, and commands.
You can also add your own templates.
To specify a template type, use --t
:
dotnet new cssharp -n MyPlugin --t config
To create a new basic project (using the default
template), just:
dotnet new cssharp -n MyPlugin
For GitHub integration (which provides GitHub workflows, .gitignore, etc.), add --g
:
dotnet new cssharp -n MyPlugin --g
Customize with --np
(plugin name) and --ap
(author):
dotnet new cssharp -n MyPlugin --t datamysql --g --np "My Plugin" --ap "Author Name"
For local compilation in Visual Studio Code, you can use the hotkey Ctrl + Shift + B
. This will trigger the build task defined in the tasks.json
file.
To have the plugin compiled directly into your server folder, replace the line in the .vscode/tasks.json
file:
"compiled/CSSharpTemplates"
with your own path, for example:
"D:/cs2-server/game/csgo/addons/counterstrikesharp/plugins/CSSharpTemplates"
Push commit messages with #major
, #minor
, or #patch
to update the plugin's version (when --g
is used):
git commit -m "add new feature #minor"
For manual version specification, use the workflow_dispatch
option in the GitHub Actions tab.
In dotnet.yml
, modify these variables as needed:
PLUGIN_NAME
: your plugin's name (please do not use spaces).DOTNET_VERSION
: .NET version (default is8.0.x
).PATH_PLUGIN
: plugin path (default isaddons/counterstrikesharp/plugins/
).START_VERSION
: starting version (default is1.0.0
).USE_V_VERSION
: prefix the version number with a 'v' (default istrue
).
To add your own template, follow these steps:
-
Clone the repository:
git clone https://github.com/Delfram99/CounterStrikeSharpTemplates.git
-
In the
content/templates
directory, create a new directory for your template. For example, if your template is named "example", create a directory namedexample
and place all the necessary template files in it. -
In the
content/.template.config/template.json
file, find the"choices"
section under"t"
. Add a new choice for your template. For example:{ "choice": "example", "description": "example description." }
-
In the
"sources"
section, add a new source with a condition for your template. For example:{ "source": "templates/example", "target": "./", "condition": "(t == 'example')" }
-
Before installing the new template, you need to uninstall the existing one to avoid conflicts:
dotnet new uninstall CounterStrikeSharpTemplates
-
Install the new template:
dotnet new install . --force
In the future, additional templates will be added as needed. If you have any ideas on how to improve or modify these templates to make plugin development even easier, please let me know.
Feel free to open an issue or submit a pull request if you have any suggestions or find any problems. Your feedback is always welcome!
If you have any questions or suggestions, feel free to contact me on Discord: delfram
.
This project was inspired by CounterStrikeSharp. A big thank you to the creators of this project for their contribution to the community and for providing the foundation for the development of these templates. ❤️