Compare commits

..

5 Commits

Author SHA1 Message Date
Oneycs
e48308f8af Created a Czech language 2024-10-24 16:33:07 +02:00
Oneycs
2fcf5d7caa Update README.md 2024-10-24 16:32:12 +02:00
Dawid Bepierszcz
ea9963b920 Merge pull request #342 from daffyyyy/main
3.1a
2024-10-24 14:16:22 +02:00
Dawid Bepierszcz
4a5a08aca9 Merge branch 'Nereziel:main' into main 2024-10-24 14:14:32 +02:00
Dawid Bepierszcz
573604a9d9 3.1a
- Possibility to change menu type by config

`MenuType:`
- selectable (each player can change menu type by command css_menus)
- dynamic (center + keys)
- center (center + chat)
- chat
- console
2024-10-24 14:14:10 +02:00
8 changed files with 161 additions and 59 deletions

View File

@@ -181,7 +181,7 @@ public partial class WeaponPaints
.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet")) .Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet"))
.ToDictionary(pair => pair.Key, pair => pair.Value); .ToDictionary(pair => pair.Key, pair => pair.Value);
var giveItemMenu = MenuApi?.NewMenu(Localizer["wp_knife_menu_title"]); var giveItemMenu = Utility.CreateMenu(Localizer["wp_knife_menu_title"]);
var handleGive = (CCSPlayerController player, ChatMenuOption option) => var handleGive = (CCSPlayerController player, ChatMenuOption option) =>
{ {
@@ -265,7 +265,7 @@ public partial class WeaponPaints
.Except([new KeyValuePair<string, string>("weapon_knife", "Default Knife")]) .Except([new KeyValuePair<string, string>("weapon_knife", "Default Knife")])
.ToDictionary(kvp => kvp.Value, kvp => kvp.Key); .ToDictionary(kvp => kvp.Value, kvp => kvp.Key);
var weaponSelectionMenu = MenuApi?.NewMenu(Localizer["wp_skin_menu_weapon_title"]); var weaponSelectionMenu = Utility.CreateMenu(Localizer["wp_skin_menu_weapon_title"]);
// Function to handle skin selection for a specific weapon // Function to handle skin selection for a specific weapon
var handleWeaponSelection = (CCSPlayerController? player, ChatMenuOption option) => var handleWeaponSelection = (CCSPlayerController? player, ChatMenuOption option) =>
@@ -280,7 +280,7 @@ public partial class WeaponPaints
weaponName?.ToString() == selectedWeaponClassname weaponName?.ToString() == selectedWeaponClassname
)?.ToList(); )?.ToList();
var skinSubMenu = MenuApi?.NewMenu(Localizer["wp_skin_menu_skin_title", selectedWeapon]); var skinSubMenu = Utility.CreateMenu(Localizer["wp_skin_menu_skin_title", selectedWeapon]);
// Function to handle skin selection for the chosen weapon // Function to handle skin selection for the chosen weapon
var handleSkinSelection = (CCSPlayerController p, ChatMenuOption opt) => var handleSkinSelection = (CCSPlayerController p, ChatMenuOption opt) =>
@@ -416,7 +416,7 @@ public partial class WeaponPaints
private void SetupGlovesMenu() private void SetupGlovesMenu()
{ {
var glovesSelectionMenu = MenuApi?.NewMenu(Localizer["wp_glove_menu_title"]); var glovesSelectionMenu = Utility.CreateMenu(Localizer["wp_glove_menu_title"]);
if (glovesSelectionMenu == null) return; if (glovesSelectionMenu == null) return;
glovesSelectionMenu.PostSelectAction = PostSelectAction.Close; glovesSelectionMenu.PostSelectAction = PostSelectAction.Close;
@@ -625,7 +625,7 @@ public partial class WeaponPaints
if (!CommandsCooldown.TryGetValue(player.Slot, out DateTime cooldownEndTime) || if (!CommandsCooldown.TryGetValue(player.Slot, out DateTime cooldownEndTime) ||
DateTime.UtcNow >= (CommandsCooldown.TryGetValue(player.Slot, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow)) DateTime.UtcNow >= (CommandsCooldown.TryGetValue(player.Slot, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
{ {
var agentsSelectionMenu = MenuApi?.NewMenu(Localizer["wp_agent_menu_title"]); var agentsSelectionMenu = Utility.CreateMenu(Localizer["wp_agent_menu_title"]);
if (agentsSelectionMenu == null) return; if (agentsSelectionMenu == null) return;
agentsSelectionMenu.PostSelectAction = PostSelectAction.Close; agentsSelectionMenu.PostSelectAction = PostSelectAction.Close;
@@ -665,7 +665,7 @@ public partial class WeaponPaints
private void SetupMusicMenu() private void SetupMusicMenu()
{ {
var musicSelectionMenu = MenuApi?.NewMenu(Localizer["wp_music_menu_title"]); var musicSelectionMenu = Utility.CreateMenu(Localizer["wp_music_menu_title"]);
if (musicSelectionMenu == null) return; if (musicSelectionMenu == null) return;
musicSelectionMenu.PostSelectAction = PostSelectAction.Close; musicSelectionMenu.PostSelectAction = PostSelectAction.Close;
@@ -800,7 +800,7 @@ public partial class WeaponPaints
private void SetupPinsMenu() private void SetupPinsMenu()
{ {
var pinsSelectionMenu = MenuApi?.NewMenu(Localizer["wp_pins_menu_title"]); var pinsSelectionMenu = Utility.CreateMenu(Localizer["wp_pins_menu_title"]);
if (pinsSelectionMenu == null) return; if (pinsSelectionMenu == null) return;
pinsSelectionMenu.PostSelectAction = PostSelectAction.Close; pinsSelectionMenu.PostSelectAction = PostSelectAction.Close;

View File

@@ -99,5 +99,8 @@ namespace WeaponPaints
[JsonPropertyName("Additional")] [JsonPropertyName("Additional")]
public Additional Additional { get; set; } = new(); public Additional Additional { get; set; } = new();
[JsonPropertyName("MenuType")]
public string MenuType { get; set; } = "selectable";
} }
} }

138
README.md
View File

@@ -1,20 +1,36 @@
# CS2 Weapon Paints ```
## Description __ __ ___ _ _
/ / /\ \ \___ __ _ _ __ ___ _ __ / _ \__ _(_)_ __ | |_ ___
\ \/ \/ / _ \/ _` | '_ \ / _ \| '_ \ / /_)/ _` | | '_ \| __/ __|
\ /\ / __/ (_| | |_) | (_) | | | / ___/ (_| | | | | | |_\__ \
\/ \/ \___|\__,_| .__/ \___/|_| |_\/ \__,_|_|_| |_|\__|___/
|_|
```
<p align="center">
<a href="https://github.com/Nereziel/cs2-WeaponPaints/releases">📖 Releases</a> •
<a href="https://discord.gg/d9CvaYPSFe">💬 Discord</a>
<br /><br />
</p>
<hr />
## 📝 Description
Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin for **[CSSharp](https://docs.cssharp.dev/docs/guides/getting-started.html)**. Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin for **[CSSharp](https://docs.cssharp.dev/docs/guides/getting-started.html)**.
## Created [Discord server](https://discord.gg/d9CvaYPSFe) where you can discuss about plugin.
### Consider to donate instead of buying from unknown sources. ### 💸 Consider to donate instead of buying from unknown sources.
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/E1E2G0P2O) or [![Donate on Steam](https://github.com/Nereziel/cs2-WeaponPaints/assets/32937653/a0d53822-4ca7-4caf-83b4-e1a9b5f8c94e)](https://steamcommunity.com/tradeoffer/new/?partner=41515647&token=gW2W-nXE) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/E1E2G0P2O) or [![Donate on Steam](https://github.com/Nereziel/cs2-WeaponPaints/assets/32937653/a0d53822-4ca7-4caf-83b4-e1a9b5f8c94e)](https://steamcommunity.com/tradeoffer/new/?partner=41515647&token=gW2W-nXE)
## Features ## Features
- Changes only paint, seed and wear on weapons, knives, gloves and agents - Changes only paint, seed and wear on weapons, knives, gloves and agents
- MySQL based - MySQL based
- Data syncs on player connect - Data syncs on player connect
- Added command **`!wp`** to refresh skins ***(with cooldown in seconds can be configured)*** - Added command **`!wp`** to refresh skins ***(with cooldown in seconds can be configured)***
- Added command **`!ws`** to show website - Added command **`!ws`** to show website
- Added command **`!knife`** to show menu with knives - Added command **`!knife`** to show menu with knives
- Added command **`!stattrak`** to enable stattrak on weapon
- Added command **`!gloves`** to show menu with gloves - Added command **`!gloves`** to show menu with gloves
- Added command **`!agents`** to show menu with agents - Added command **`!agents`** to show menu with agents
- Added command **`!pins`** to show menu with pins - Added command **`!pins`** to show menu with pins
@@ -29,7 +45,7 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
- [MenuManagerCS2](https://github.com/NickFox007/MenuManagerCS2) - [MenuManagerCS2](https://github.com/NickFox007/MenuManagerCS2)
- MySQL database - MySQL database
## CS2 Server ## 🗄️ CS2 Server
- Have working CounterStrikeSharp (**with RUNTIME!**) - Have working CounterStrikeSharp (**with RUNTIME!**)
- Download from Release and copy plugin to plugins - Download from Release and copy plugin to plugins
- Run server with plugin, **it will generate config if installed correctly!** - Run server with plugin, **it will generate config if installed correctly!**
@@ -37,49 +53,72 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
- In `addons/counterstrikesharp/configs/`**`core.json`** set **FollowCS2ServerGuidelines** to **`false`** - In `addons/counterstrikesharp/configs/`**`core.json`** set **FollowCS2ServerGuidelines** to **`false`**
- Copy from plugins folder gamedata file **`weaponpaints.json`** to folder **`addons/counterstrikesharp/gamedata/`** - Copy from plugins folder gamedata file **`weaponpaints.json`** to folder **`addons/counterstrikesharp/gamedata/`**
## Plugin Configuration ## 🛠️ Plugin Configuration
<details> <details>
<summary>Click to expand</summary> <summary>Click to expand</summary>
<code><pre>{ <code><pre>{
"Version": 4, // Don't touch "ConfigVersion": 10, // Don't touch
"DatabaseHost": "", // MySQL host "SkinsLanguage": "en", // Language
"DatabasePort": 3306, // MySQL port "DatabaseHost": "", // MySQL host
"DatabaseUser": "", // MySQL username "DatabasePort": 3306, // MySQL Port
"DatabasePassword": "", // MySQL user password "DatabaseUser": "", // MySQL Username
"DatabaseName": "", // MySQL database name "DatabasePassword": "", // MySQL User password
"CmdRefreshCooldownSeconds": 60, // Cooldown time in refreshing skins (!wp command) "DatabaseName": "", // MySQL Database name
"Prefix": "[WeaponPaints]", // Prefix every chat message "CmdRefreshCooldownSeconds": 3, // Cooldown time in refreshing skins (!wp command)
"Website": "example.com/skins", // Website used in WebsiteMessageCommand (!ws command) "Website": "example.com/skins", // Website used in WebsiteMessageCommand (!ws command)
"Messages": { "Additional": {
"WebsiteMessageCommand": "Visit {WEBSITE} where you can change skins.", // Information about website where player can change skins (!ws command) Set to empty to disable "KnifeEnabled": true, // If knives are enabled
"SynchronizeMessageCommand": "Type !wp to synchronize chosen skins.", // Information about skins refreshing (!ws command) Set to empty to disable "GloveEnabled": true, // If gloves are enabled
"KnifeMessageCommand": "Type !knife to open knife menu.", // Information about knife menu (!ws command) Set to empty to disable "MusicEnabled": true, // If music kits are enabled
"CooldownRefreshCommand": "You can\u0027t refresh weapon paints right now.", // Cooldown information (!wp command) Set to empty to disable "AgentEnabled": true, // If agents are enabled
"SuccessRefreshCommand": "Refreshing weapon paints.", // Information about refreshing skins (!wp command) Set to empty to disable "SkinEnabled": true, // If skins are enabled
"ChosenKnifeMenu": "You have chosen {KNIFE} as your knife.", // Information about choosen knife (!knife command) Set to empty to disable "PinsEnabled": true, // If pins are enabled
"ChosenSkinMenu": "You have chosen {SKIN} as your skin.", // Information about choosen skin (!skins command) Set to empty to disable "CommandWpEnabled": true, // If command !wp is enabled
"ChosenKnifeMenuKill": "To correctly apply skin for knife, you need to type !kill.", // Information about suicide after knife selection (!knife command) Set to empty to disable "CommandKillEnabled": true, // If command !kill is enabled
"KnifeMenuTitle": "Knife Menu.", // Menu title (!knife menu) "CommandKnife": [ // Command for knives
"WeaponMenuTitle": "Weapon Menu.", // Menu title (!skins menu) "knife"
"SkinMenuTitle": "Select skin for {WEAPON}" // Menu title (!skins menu, after weapon select) ],
}, "CommandMusic": [ // Command for music kits
"Additional": { "music"
"KnifeEnabled": true, // Enable or disable knife feature ],
"SkinEnabled": true, // Enable or disable skin feature "CommandPin": [ // Command for pins
"CommandWpEnabled": true, // Enable or disable refreshing command "pin",
"CommandKillEnabled": true, // Enable or disable kill command "pins",
"CommandKnife": "knife", // Name of knife menu command, u can change to for e.g, knives "coin",
"CommandSkin": "ws", // Name of skin information command, u can change to for e.g, skins "coins"
"CommandSkinSelection": "skins", // Name of skins menu command, u can change to for e.g, weapons ],
"CommandRefresh": "wp", // Name of skin refreshing command, u can change to for e.g, refreshskins "CommandGlove": [ // Command for gloves
"CommandKill": "kill", // Name of kill command, u can change to for e.g, suicide "gloves"
"GiveRandomKnife": false, // Give random knife to players if they didn't choose ],
"GiveRandomSkins": false // Give random skins to players if they didn't choose "CommandAgent": [ // Command for agents
}, "agents"
],
"CommandStattrak": [ // Command for stattrak
"stattrak",
"st"
],
"CommandSkin": [ // Command for skins
"ws"
],
"CommandSkinSelection": [ // Command for skin selection
"skins"
],
"CommandRefresh": [ // Command for refreshing your skins
"wp"
],
"CommandKill": [ // Command for death
"kill"
],
"GiveRandomKnife": false, // If it should give you Random Knife
"GiveRandomSkin": false, // If it should give you Random Skin
"ShowSkinImage": true // When you select a skin if it should show skins image
},
"MenuType": "selectable" // Menu type commands. Can be: selectable, dynamic, center, chat, console
}
</pre></code> </pre></code>
</details> </details>
## Web install ## 🖥️ Web install
- Requires PHP >= 7.4 with curl and pdo_mysql ***(Tested on php ver **`8.2.3`** and nginx webserver)*** - Requires PHP >= 7.4 with curl and pdo_mysql ***(Tested on php ver **`8.2.3`** and nginx webserver)***
- **Before using website, make sure the plugin is correctly loaded in cs2 server!** Mysql tables are created by plugin not by website. - **Before using website, make sure the plugin is correctly loaded in cs2 server!** Mysql tables are created by plugin not by website.
- Copy website to web server ***(Folder `img` not needed)*** - Copy website to web server ***(Folder `img` not needed)***
@@ -87,12 +126,19 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
- Fill in database credentials and api key in `class/config.php` - Fill in database credentials and api key in `class/config.php`
- Visit website and login via steam - Visit website and login via steam
## Web Features ## 🧩 Web Features
> [!WARNING]
> We recommend you to use any third-party website for WeaponPaints. Website by us doesn't get updated!
- Basic website - Basic website
- Steam login/logout - Steam login/logout
- Change knife, paint, seed and wear - Change knife, paint, seed and wear
## Troubleshooting ## 🌐 Third-party websites
- **[CSS-Bans](https://github.com/counterstrikesharp-panel/css-bans)**
- **[CS2-WeaponPaints-Website](https://github.com/LielXD/CS2-WeaponPaints-Website)**
- **[cs2-WeaponPaints-website](https://github.com/L1teD/cs2-WeaponPaints-website)** > This webiste is different from the one above!
- **[CS2-WeaponPaints-Web](https://github.com/rogeraabbccdd/CS2-WeaponPaints-Web)**
## 🤔 Troubleshooting
<details> <details>
**Skins are not changing:** **Skins are not changing:**
Set FollowCSGOGuidelines to false in cssharps core.jcon config Set FollowCSGOGuidelines to false in cssharps core.jcon config
@@ -104,5 +150,5 @@ Plugin is not loaded or configured with mysql credentials. Tables are auto-creat
### Use this plugin at your own risk! Using this may lead to GSLT ban or something else Valve come with. [Valve Server guidelines](https://blog.counter-strike.net/index.php/server_guidelines/) ### Use this plugin at your own risk! Using this may lead to GSLT ban or something else Valve come with. [Valve Server guidelines](https://blog.counter-strike.net/index.php/server_guidelines/)
## Preview ## Website Preview
![preview](https://github.com/Nereziel/cs2-WeaponPaints/blob/main/website/preview.png?raw=true) ![preview](https://github.com/Nereziel/cs2-WeaponPaints/blob/main/website/preview.png?raw=true)

View File

@@ -1,6 +1,8 @@
using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Translations; using CounterStrikeSharp.API.Core.Translations;
using CounterStrikeSharp.API.Modules.Menu;
using Dapper; using Dapper;
using MenuManager;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
@@ -188,10 +190,32 @@ namespace WeaponPaints
Console.WriteLine("[WeaponPaints] " + message); Console.WriteLine("[WeaponPaints] " + message);
Console.ResetColor(); Console.ResetColor();
} }
internal static string ReplaceTags(string message) internal static IMenu? CreateMenu(string title)
{ {
return message.ReplaceColorTags(); var menuType = WeaponPaints.Instance.Config.MenuType.ToLower();
var menu = menuType switch
{
_ when menuType.Equals("selectable", StringComparison.CurrentCultureIgnoreCase) =>
WeaponPaints.MenuApi?.NewMenu(title),
_ when menuType.Equals("dynamic", StringComparison.CurrentCultureIgnoreCase) =>
WeaponPaints.MenuApi?.NewMenuForcetype(title, MenuType.ButtonMenu),
_ when menuType.Equals("center", StringComparison.CurrentCultureIgnoreCase) =>
WeaponPaints.MenuApi?.NewMenuForcetype(title, MenuType.CenterMenu),
_ when menuType.Equals("chat", StringComparison.CurrentCultureIgnoreCase) =>
WeaponPaints.MenuApi?.NewMenuForcetype(title, MenuType.ChatMenu),
_ when menuType.Equals("console", StringComparison.CurrentCultureIgnoreCase) =>
WeaponPaints.MenuApi?.NewMenuForcetype(title, MenuType.ConsoleMenu),
_ => WeaponPaints.MenuApi?.NewMenu(title)
};
return menu;
} }
internal static async Task CheckVersion(string version, ILogger logger) internal static async Task CheckVersion(string version, ILogger logger)

View File

@@ -1 +1 @@
3.0c 3.1a

View File

@@ -542,7 +542,6 @@ namespace WeaponPaints
var weapon = handle.Value; var weapon = handle.Value;
if (weapon == null || !weapon.IsValid) continue; if (weapon == null || !weapon.IsValid) continue;
if (myWeapons.Count == 1) if (myWeapons.Count == 1)
{ {
var newWeapon = new CBasePlayerWeapon(player.GiveNamedItem(CsItem.USP)); var newWeapon = new CBasePlayerWeapon(player.GiveNamedItem(CsItem.USP));

View File

@@ -17,7 +17,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
public override string ModuleAuthor => "Nereziel & daffyy"; public override string ModuleAuthor => "Nereziel & daffyy";
public override string ModuleDescription => "Skin, gloves, agents and knife selector, standalone and web-based"; public override string ModuleDescription => "Skin, gloves, agents and knife selector, standalone and web-based";
public override string ModuleName => "WeaponPaints"; public override string ModuleName => "WeaponPaints";
public override string ModuleVersion => "3.0c"; public override string ModuleVersion => "3.1a";
public override void Load(bool hotReload) public override void Load(bool hotReload)
{ {

30
lang/cs.json Normal file
View File

@@ -0,0 +1,30 @@
{
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
"wp_info_website": "Navštiv {lime}{0}{default} kde si můžeš změnit skiny",
"wp_info_refresh": "Napiš {lime}!wp{default} pro synchronizaci vybraných skinů",
"wp_info_knife": "Napiš {lime}!knife{default} pro otevření menu nožů",
"wp_info_glove": "Napiš {lime}!gloves{default} pro otevření menu rukavic",
"wp_info_agent": "Napiš {lime}!agents{default} pro otevření menu agentů",
"wp_info_music": "Napiš {lime}!music{default} pro otevření menu MVP hudeb",
"wp_info_pin": "Napiš {lime}!pins{default} pro otevření menu odznaků",
"wp_command_cooldown": "{lightred}Skiny nelze nýni obnovit!",
"wp_command_refresh_done": "{lime}Obnovuji skiny",
"wp_knife_menu_select": "Vybral jsi si {lime}{0}{default} jako tvůj nůž",
"wp_knife_menu_kill": "",
"wp_knife_menu_title": "Menu nožů",
"wp_glove_menu_select": "Vybral jsi si {lime}{0}{default} jako tvoje rukavice",
"wp_glove_menu_title": "Menu rukavic",
"wp_agent_menu_select": "Vybral jsi si {lime}{0}{default} jako tvůj agent",
"wp_agent_menu_title": "Menu agentů",
"wp_music_menu_title": "Menu MVP hudeb",
"wp_music_menu_select": "Vybral jsi si {lime}{0}{default} jako tvojí MVP hudbu",
"wp_pins_menu_title": "Menu odznaků",
"wp_pins_menu_select": "Vybral jsi si {lime}{0}{default} jako tvůj odznak",
"wp_skin_menu_weapon_title": "Menu zbraní",
"wp_skin_menu_skin_title": "Vyběr skinů pro {lime}{0}{default}",
"wp_skin_menu_select": "Vybral jsi si {lime}{0}{default} jako tvůj skin",
"wp_stattrak_action": "Úspěšně jste změnil nastavení stattraku",
"None": "Žádné"
}