Compare commits

...

21 Commits

Author SHA1 Message Date
Nereziel
29a6041d7a fixed discord link 2023-11-21 19:35:52 +01:00
Nereziel
50777661c5 Merge pull request #55 from daffyyyy/patch-1
Fix when player select "Select skin" as skin
2023-11-19 22:52:08 +01:00
Dawid Bepierszcz
31fd014f55 Fix when player select "Select skin" as skin 2023-11-19 22:42:32 +01:00
Nereziel
760429e644 Merge pull request #54 from daffyyyy/update-readme-1
Update README.md
2023-11-19 22:36:28 +01:00
Dawid Bepierszcz
304d8501cc Update README.md 2023-11-19 22:25:38 +01:00
Nereziel
e9f7db5171 Merge pull request #51 from daffyyyy/website-fix-1
Fixed blank page
2023-11-19 21:14:15 +01:00
Dawid Bepierszcz
648b928b4e Update index.php 2023-11-19 21:10:55 +01:00
Nereziel
530a7d64c7 Update README.md 2023-11-19 20:45:12 +01:00
Nereziel
3453f4c505 Merge pull request #47 from daffyyyy/feature/global-share
EXPERIMENTAL (GlobalShare) - Website for all servers
2023-11-19 19:03:05 +01:00
Nereziel
25b466422b Update build.yml 2023-11-19 19:02:26 +01:00
daffyyyy
6baa59dd9b Update WeaponPaints.cs
New version
2023-11-19 12:30:47 +01:00
daffyyyy
10afe7ce1e Update WeaponPaints.cs 2023-11-19 12:24:57 +01:00
daffyyyy
5eeb0c5fec Initial 2023-11-19 02:07:29 +01:00
Nereziel
e53ee27b39 Merge pull request #44 from daffyyyy/fix-knives_finally
Finally fixed knife problem?
2023-11-18 19:26:37 +01:00
Dawid Bepierszcz
75112b02fe Update WeaponPaints.cs 2023-11-18 19:21:28 +01:00
Nereziel
8e92635231 sync paints on plugin reload 2023-11-18 15:20:26 +01:00
Nereziel
6923295cb6 Update build.yml 2023-11-18 15:14:40 +01:00
Nereziel
e5f98077f3 Update build.yml 2023-11-18 15:12:57 +01:00
Nereziel
3296055841 Merge pull request #42 from daffyyyy/enhancement/mysql-wrapper
Creating tables fix
2023-11-18 11:18:15 +01:00
Dawid Bepierszcz
89de192c20 Update WeaponPaints.cs
Additional check
2023-11-18 09:15:20 +01:00
Dawid Bepierszcz
a1297b9cbe Update WeaponPaints.cs
Creating tables fix
2023-11-18 08:54:33 +01:00
6 changed files with 831 additions and 613 deletions

View File

@@ -28,6 +28,22 @@ jobs:
run: dotnet restore run: dotnet restore
- name: Build - name: Build
run: dotnet build ${{ env.PROJECT_PATH }} -c WeaponPaints -o ${{ env.OUTPUT_PATH }} run: dotnet build ${{ env.PROJECT_PATH }} -c WeaponPaints -o ${{ env.OUTPUT_PATH }}
publish:
if: github.event_name == 'push'
permissions: write-all
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build ${{ env.PROJECT_PATH }} -c WeaponPaints -o ${{ env.OUTPUT_PATH }}
- name: Clean files - name: Clean files
run: | run: |
rm -f \ rm -f \

139
Config.cs
View File

@@ -3,92 +3,95 @@ using System.Text.Json.Serialization;
namespace WeaponPaints namespace WeaponPaints
{ {
public class Messages public class Messages
{ {
[JsonPropertyName("WebsiteMessageCommand")] [JsonPropertyName("WebsiteMessageCommand")]
public string WebsiteMessageCommand { get; set; } = "Visit {WEBSITE} where you can change skins."; public string WebsiteMessageCommand { get; set; } = "Visit {WEBSITE} where you can change skins.";
[JsonPropertyName("SynchronizeMessageCommand")] [JsonPropertyName("SynchronizeMessageCommand")]
public string SynchronizeMessageCommand { get; set; } = "Type !wp to synchronize chosen skins."; public string SynchronizeMessageCommand { get; set; } = "Type !wp to synchronize chosen skins.";
[JsonPropertyName("KnifeMessageCommand")] [JsonPropertyName("KnifeMessageCommand")]
public string KnifeMessageCommand { get; set; } = "Type !knife to open knife menu."; public string KnifeMessageCommand { get; set; } = "Type !knife to open knife menu.";
[JsonPropertyName("CooldownRefreshCommand")] [JsonPropertyName("CooldownRefreshCommand")]
public string CooldownRefreshCommand { get; set; } = "You can't refresh weapon paints right now."; public string CooldownRefreshCommand { get; set; } = "You can't refresh weapon paints right now.";
[JsonPropertyName("SuccessRefreshCommand")] [JsonPropertyName("SuccessRefreshCommand")]
public string SuccessRefreshCommand { get; set; } = "Refreshing weapon paints."; public string SuccessRefreshCommand { get; set; } = "Refreshing weapon paints.";
[JsonPropertyName("ChosenKnifeMenu")] [JsonPropertyName("ChosenKnifeMenu")]
public string ChosenKnifeMenu { get; set; } = "You have chosen {KNIFE} as your knife."; public string ChosenKnifeMenu { get; set; } = "You have chosen {KNIFE} as your knife.";
[JsonPropertyName("ChosenKnifeMenuKill")] [JsonPropertyName("ChosenKnifeMenuKill")]
public string ChosenKnifeMenuKill { get; set; } = "To correctly apply skin for knife, you need to type !kill."; public string ChosenKnifeMenuKill { get; set; } = "To correctly apply skin for knife, you need to type !kill.";
[JsonPropertyName("KnifeMenuTitle")] [JsonPropertyName("KnifeMenuTitle")]
public string KnifeMenuTitle { get; set; } = "Knife Menu."; public string KnifeMenuTitle { get; set; } = "Knife Menu.";
} }
public class Additional public class Additional
{ {
[JsonPropertyName("SkinVisibilityFix")] [JsonPropertyName("SkinVisibilityFix")]
public bool SkinVisibilityFix { get; set; } = true; public bool SkinVisibilityFix { get; set; } = true;
[JsonPropertyName("KnifeEnabled")] [JsonPropertyName("KnifeEnabled")]
public bool KnifeEnabled { get; set; } = true; public bool KnifeEnabled { get; set; } = true;
[JsonPropertyName("SkinEnabled")] [JsonPropertyName("SkinEnabled")]
public bool SkinEnabled { get; set; } = true; public bool SkinEnabled { get; set; } = true;
[JsonPropertyName("CommandWpEnabled")] [JsonPropertyName("CommandWpEnabled")]
public bool CommandWpEnabled { get; set; } = true; public bool CommandWpEnabled { get; set; } = true;
[JsonPropertyName("CommandKillEnabled")] [JsonPropertyName("CommandKillEnabled")]
public bool CommandKillEnabled { get; set; } = true; public bool CommandKillEnabled { get; set; } = true;
[JsonPropertyName("CommandKnife")]
public string CommandKnife { get; set; } = "knife";
[JsonPropertyName("CommandSkin")] [JsonPropertyName("CommandKnife")]
public string CommandSkin { get; set; } = "ws"; public string CommandKnife { get; set; } = "knife";
[JsonPropertyName("CommandRefresh")] [JsonPropertyName("CommandSkin")]
public string CommandRefresh { get; set; } = "wp"; public string CommandSkin { get; set; } = "ws";
[JsonPropertyName("CommandKill")] [JsonPropertyName("CommandRefresh")]
public string CommandKill { get; set; } = "kill"; public string CommandRefresh { get; set; } = "wp";
[JsonPropertyName("GiveRandomKnife")] [JsonPropertyName("CommandKill")]
public bool GiveRandomKnife { get; set; } = false; public string CommandKill { get; set; } = "kill";
}
public class WeaponPaintsConfig : BasePluginConfig [JsonPropertyName("GiveRandomKnife")]
{ public bool GiveRandomKnife { get; set; } = false;
public override int Version { get; set; } = 4; }
[JsonPropertyName("DatabaseHost")] public class WeaponPaintsConfig : BasePluginConfig
public string DatabaseHost { get; set; } = ""; {
public override int Version { get; set; } = 4;
[JsonPropertyName("DatabasePort")] [JsonPropertyName("DatabaseHost")]
public int DatabasePort { get; set; } = 3306; public string DatabaseHost { get; set; } = "";
[JsonPropertyName("DatabaseUser")] [JsonPropertyName("DatabasePort")]
public string DatabaseUser { get; set; } = ""; public int DatabasePort { get; set; } = 3306;
[JsonPropertyName("DatabasePassword")] [JsonPropertyName("DatabaseUser")]
public string DatabasePassword { get; set; } = ""; public string DatabaseUser { get; set; } = "";
[JsonPropertyName("DatabaseName")] [JsonPropertyName("DatabasePassword")]
public string DatabaseName { get; set; } = ""; public string DatabasePassword { get; set; } = "";
[JsonPropertyName("CmdRefreshCooldownSeconds")] [JsonPropertyName("DatabaseName")]
public int CmdRefreshCooldownSeconds { get; set; } = 60; public string DatabaseName { get; set; } = "";
[JsonPropertyName("Prefix")] [JsonPropertyName("GlobalShare")]
public string Prefix { get; set; } = "[WeaponPaints]"; public bool GlobalShare { get; set; } = false;
[JsonPropertyName("Website")] [JsonPropertyName("CmdRefreshCooldownSeconds")]
public string Website { get; set; } = "example.com/skins"; public int CmdRefreshCooldownSeconds { get; set; } = 60;
[JsonPropertyName("Messages")] [JsonPropertyName("Prefix")]
public Messages Messages { get; set; } = new Messages(); public string Prefix { get; set; } = "[WeaponPaints]";
[JsonPropertyName("Website")]
public string Website { get; set; } = "example.com/skins";
[JsonPropertyName("Messages")]
public Messages Messages { get; set; } = new Messages();
[JsonPropertyName("Additional")]
public Additional Additional { get; set; } = new Additional();
}
[JsonPropertyName("Additional")]
public Additional Additional { get; set; } = new Additional();
}
} }

View File

@@ -4,14 +4,14 @@
Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin for [CSSharp](https://docs.cssharp.dev/). Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin for [CSSharp](https://docs.cssharp.dev/).
There will be a lot of frequent changes which may break functionality or compatibility. You have been warned! There will be a lot of frequent changes which may break functionality or compatibility. You have been warned!
## Created [Discord server](https://discord.gg/mwEQppJ5AT) where you can discus about plugin. ## Created [Discord server](https://discord.gg/EEg6qtNScq) where you can discus 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://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://steamcommunity.com/tradeoffer/new/?partner=41515647&token=gW2W-nXE)
### Features ### Features
- changes only paint, seed and wear on weapons and knives - changes only paint, seed and wear on weapons and knives
- mysql based - mysql based or global website at [weaponpaints.fun](https://weaponpaints.fun/), so you dont need mysql/website
- data sync on player connect - data sync on player connect
- Added command `!wp` to refresh skins (with cooldown in second can be configured) - Added command `!wp` to refresh skins (with cooldown in second can be configured)
- Added command `!ws` to show website - Added command `!ws` to show website
@@ -20,10 +20,53 @@ There will be a lot of frequent changes which may break functionality or compati
### CS2 server: ### CS2 server:
- compile and copy plugin to plugins. Info here [https://docs.cssharp.dev/guides/hello-world-plugin/](https://docs.cssharp.dev/guides/hello-world-plugin/) - compile and copy plugin to plugins. Info here [https://docs.cssharp.dev/guides/hello-world-plugin/](https://docs.cssharp.dev/guides/hello-world-plugin/)
- setup `addons/counterstrikesharp/configs/plugins/WeaponPaints/WeaponPaints.json` with database credentials - setup `addons/counterstrikesharp/configs/plugins/WeaponPaints/WeaponPaints.json`
set `GlobalShare` to true for global, or include database credentials
- in `addons/counterstrikesharp/configs/core.json` set **FollowCS2ServerGuidelines** to **false** - in `addons/counterstrikesharp/configs/core.json` set **FollowCS2ServerGuidelines** to **false**
### Plugin configuration:
<details>
<summary>Spoiler warning</summary>
<code><pre>{
"Version": 4, // Don't touch
"DatabaseHost": "", // MySQL host (required if GlobalShare = false)
"DatabasePort": 3306, // MySQL port (required if GlobalShare = false)
"DatabaseUser": "", // MySQL username (required if GlobalShare = false)
"DatabasePassword": "", // MySQL user password (required if GlobalShare = false)
"DatabaseName": "", // MySQL database name (required if GlobalShare = false)
"GlobalShare": false, // Enable or disable GlobalShare, plugin can work without mysql credentials but with shared website at weaponpaints.fun
"CmdRefreshCooldownSeconds": 60, // Cooldown time in refreshing skins (!wp command)
"Prefix": "[WeaponPaints]", // Prefix every chat message
"Website": "example.com/skins", // Website used in WebsiteMessageCommand (!ws command)
"Messages": {
"WebsiteMessageCommand": "Visit {WEBSITE} where you can change skins.", // Information about website where player can change skins (!ws command) Set to empty to disable
"SynchronizeMessageCommand": "Type !wp to synchronize chosen skins.", // Information about skins refreshing (!ws command) Set to empty to disable
"KnifeMessageCommand": "Type !knife to open knife menu.", // Information about knife menu (!ws command) Set to empty to disable
"CooldownRefreshCommand": "You can\u0027t refresh weapon paints right now.", // Cooldown information (!wp command) Set to empty to disable
"SuccessRefreshCommand": "Refreshing weapon paints.", // Information about refreshing skins (!wp command) Set to empty to disable
"ChosenKnifeMenu": "You have chosen {KNIFE} as your knife.", // Information about choosen knife (!knife command) Set to empty to disable
"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
"KnifeMenuTitle": "Knife Menu." // Menu title (!knife menu)
},
"Additional": {
"SkinVisibilityFix": true, // Enable or disable fix for skin visibility
"KnifeEnabled": true, // Enable or disable knife feature
"SkinEnabled": true, // Enable or disable skin feature
"CommandWpEnabled": true, // Enable or disable refreshing command
"CommandKillEnabled": true, // Enable or disable kill command
"CommandKnife": "knife", // Name of knife menu command, u can change to for e.g, knives
"CommandSkin": "ws", // Name of skin information command, u can change to for e.g, skins
"CommandRefresh": "wp", // Name of skin refreshing command, u can change to for e.g, refreshskins
"CommandKill": "kill", // Name of kill command, u can change to for e.g, suicide
"GiveRandomKnife": false // Give random knife to players if they didn't choose
},
"ConfigVersion": 4 // Don't touch
}</pre></code>
</details>
### Web install: ### Web install:
- not needed if config `GlobalShare = true`
- requires PHP min v7.3 (tested on php ver `8.2.3` and nginx webserver) - requires PHP min v7.3 (tested on php ver `8.2.3` and nginx webserver)
- copy website to web server (img folder not needed) - copy website to web server (img folder not needed)
- import `database.sql` to mysql - import `database.sql` to mysql
@@ -31,6 +74,9 @@ There will be a lot of frequent changes which may break functionality or compati
- 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
### Known issues
- Issue on Windows servers, no knives are given.
### 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 ### Preview

File diff suppressed because it is too large Load Diff

View File

@@ -11,6 +11,7 @@
<PackageReference Include="CounterStrikeSharp.API" Version="*" /> <PackageReference Include="CounterStrikeSharp.API" Version="*" />
<PackageReference Include="Dapper" Version="2.1.21" /> <PackageReference Include="Dapper" Version="2.1.21" />
<PackageReference Include="MySqlConnector" Version="2.3.1" /> <PackageReference Include="MySqlConnector" Version="2.3.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -7,9 +7,7 @@ require_once 'class/utils.php';
$db = new DataBase(); $db = new DataBase();
if (isset($_SESSION['steamid'])) { if (isset($_SESSION['steamid'])) {
$steamid = $_SESSION['steamid'];
include('steamauth/userInfo.php');
$steamid = $steamprofile['steamid'];
$weapons = UtilsClass::getWeaponsFromArray(); $weapons = UtilsClass::getWeaponsFromArray();
$skins = UtilsClass::skinsFromJson(); $skins = UtilsClass::skinsFromJson();
@@ -24,6 +22,8 @@ if (isset($_SESSION['steamid'])) {
if ($ex[0] == "knife") { if ($ex[0] == "knife") {
$db->query("INSERT INTO `wp_player_knife` (`steamid`, `knife`) VALUES(:steamid, :knife) ON DUPLICATE KEY UPDATE `knife` = :knife", ["steamid" => $steamid, "knife" => $knifes[$ex[1]]['weapon_name']]); $db->query("INSERT INTO `wp_player_knife` (`steamid`, `knife`) VALUES(:steamid, :knife) ON DUPLICATE KEY UPDATE `knife` = :knife", ["steamid" => $steamid, "knife" => $knifes[$ex[1]]['weapon_name']]);
} else { } else {
if (!is_int($ex[1]))
header("Location: index.php");
if (array_key_exists($ex[1], $skins[$ex[0]])) { if (array_key_exists($ex[1], $skins[$ex[0]])) {
if (array_key_exists($ex[0], $selectedSkins)) { if (array_key_exists($ex[0], $selectedSkins)) {
$db->query("UPDATE wp_player_skins SET weapon_paint_id = :weapon_paint_id WHERE steamid = :steamid AND weapon_defindex = :weapon_defindex", ["steamid" => $steamid, "weapon_defindex" => $ex[0], "weapon_paint_id" => $ex[1]]); $db->query("UPDATE wp_player_skins SET weapon_paint_id = :weapon_paint_id WHERE steamid = :steamid AND weapon_defindex = :weapon_defindex", ["steamid" => $steamid, "weapon_defindex" => $ex[0], "weapon_paint_id" => $ex[1]]);
@@ -85,7 +85,7 @@ if (isset($_SESSION['steamid'])) {
<div class="card-footer"> <div class="card-footer">
<form action="" method="POST"> <form action="" method="POST">
<select name="forma" class="form-control select" onchange="this.form.submit()" class="SelectWeapon"> <select name="forma" class="form-control select" onchange="this.form.submit()" class="SelectWeapon">
<option>Select knife</option> <option disabled>Select knife</option>
<?php <?php
foreach ($knifes as $knifeKey => $knife) { foreach ($knifes as $knifeKey => $knife) {
if ($selectedKnife['knife'] == $knife['weapon_name']) if ($selectedKnife['knife'] == $knife['weapon_name'])
@@ -122,7 +122,7 @@ if (isset($_SESSION['steamid'])) {
<div class="card-footer"> <div class="card-footer">
<form action="" method="POST"> <form action="" method="POST">
<select name="forma" class="form-control select" onchange="this.form.submit()" class="SelectWeapon"> <select name="forma" class="form-control select" onchange="this.form.submit()" class="SelectWeapon">
<option>Select skin</option> <option disabled>Select skin</option>
<?php <?php
foreach ($skins[$defindex] as $paintKey => $paint) { foreach ($skins[$defindex] as $paintKey => $paint) {
if (array_key_exists($defindex, $selectedSkins) && $selectedSkins[$defindex] == $paintKey) if (array_key_exists($defindex, $selectedSkins) && $selectedSkins[$defindex] == $paintKey)