mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-20 11:08:21 +00:00
Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e92635231 | ||
|
|
6923295cb6 | ||
|
|
e5f98077f3 | ||
|
|
3296055841 | ||
|
|
89de192c20 | ||
|
|
a1297b9cbe | ||
|
|
99af078b32 | ||
|
|
b0bef746cd | ||
|
|
117a95e99c | ||
|
|
a6d4108ca7 | ||
|
|
7b45169d8d | ||
|
|
42bd45c3f0 | ||
|
|
5262739c3d | ||
|
|
c82a0c0d26 | ||
|
|
9ad7f9fc83 | ||
|
|
9e2dac52e5 | ||
|
|
118931f44d | ||
|
|
843ae34e31 | ||
|
|
46a720ff83 | ||
|
|
63d059b607 | ||
|
|
005ef18338 | ||
|
|
c0c1fe2566 | ||
|
|
c4ad17a7ed | ||
|
|
99fde6ec52 | ||
|
|
ca2c3eb212 | ||
|
|
b5a4577af1 | ||
|
|
ba93e4a3aa | ||
|
|
7d435da9d1 | ||
|
|
50008cf74a | ||
|
|
4b9b169483 | ||
|
|
25d251deff | ||
|
|
d8f7798f9f | ||
|
|
fb023aff5b | ||
|
|
6c91e20a4d |
20
.github/workflows/build.yml
vendored
20
.github/workflows/build.yml
vendored
@@ -28,19 +28,37 @@ 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:
|
||||||
|
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 \
|
||||||
${{ env.OUTPUT_PATH }}/CounterStrikeSharp.API.dll \
|
${{ env.OUTPUT_PATH }}/CounterStrikeSharp.API.dll \
|
||||||
${{ env.OUTPUT_PATH }}/McMaster.NETCore.Plugins.dll \
|
${{ env.OUTPUT_PATH }}/McMaster.NETCore.Plugins.dll \
|
||||||
${{ env.OUTPUT_PATH }}/Microsoft.DotNet.PlatformAbstractions.dll \
|
${{ env.OUTPUT_PATH }}/Microsoft.DotNet.PlatformAbstractions.dll \
|
||||||
${{ env.OUTPUT_PATH }}/Microsoft.Extensions.DependencyModel.dll
|
${{ env.OUTPUT_PATH }}/Microsoft.Extensions.DependencyModel.dll \
|
||||||
- name: Zip
|
- name: Zip
|
||||||
uses: thedoctor0/zip-release@0.7.5
|
uses: thedoctor0/zip-release@0.7.5
|
||||||
with:
|
with:
|
||||||
type: 'zip'
|
type: 'zip'
|
||||||
filename: '${{ env.PROJECT_NAME }}.zip'
|
filename: '${{ env.PROJECT_NAME }}.zip'
|
||||||
path: ${{ env.OUTPUT_PATH }}
|
path: ${{ env.OUTPUT_PATH }}
|
||||||
|
- name: Clean files Website
|
||||||
|
run: |
|
||||||
|
rm -rf website/img/
|
||||||
- name: Zip
|
- name: Zip
|
||||||
uses: thedoctor0/zip-release@0.7.5
|
uses: thedoctor0/zip-release@0.7.5
|
||||||
with:
|
with:
|
||||||
|
|||||||
40
Config.cs
40
Config.cs
@@ -17,13 +17,48 @@ namespace WeaponPaints
|
|||||||
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")]
|
||||||
|
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
|
||||||
|
{
|
||||||
|
[JsonPropertyName("SkinVisibilityFix")]
|
||||||
|
public bool SkinVisibilityFix { get; set; } = true;
|
||||||
|
|
||||||
|
[JsonPropertyName("KnifeEnabled")]
|
||||||
|
public bool KnifeEnabled { get; set; } = true;
|
||||||
|
|
||||||
|
[JsonPropertyName("SkinEnabled")]
|
||||||
|
public bool SkinEnabled { get; set; } = true;
|
||||||
|
|
||||||
|
[JsonPropertyName("CommandWpEnabled")]
|
||||||
|
public bool CommandWpEnabled { get; set; } = true;
|
||||||
|
|
||||||
|
[JsonPropertyName("CommandKillEnabled")]
|
||||||
|
public bool CommandKillEnabled { get; set; } = true;
|
||||||
|
|
||||||
|
[JsonPropertyName("CommandKnife")]
|
||||||
|
public string CommandKnife { get; set; } = "knife";
|
||||||
|
|
||||||
|
[JsonPropertyName("CommandSkin")]
|
||||||
|
public string CommandSkin { get; set; } = "ws";
|
||||||
|
|
||||||
|
[JsonPropertyName("CommandRefresh")]
|
||||||
|
public string CommandRefresh { get; set; } = "wp";
|
||||||
|
|
||||||
|
[JsonPropertyName("CommandKill")]
|
||||||
|
public string CommandKill { get; set; } = "kill";
|
||||||
|
|
||||||
|
[JsonPropertyName("GiveRandomKnife")]
|
||||||
|
public bool GiveRandomKnife { get; set; } = false;
|
||||||
|
}
|
||||||
|
|
||||||
public class WeaponPaintsConfig : BasePluginConfig
|
public class WeaponPaintsConfig : BasePluginConfig
|
||||||
{
|
{
|
||||||
public override int Version { get; set; } = 2;
|
public override int Version { get; set; } = 4;
|
||||||
|
|
||||||
[JsonPropertyName("DatabaseHost")]
|
[JsonPropertyName("DatabaseHost")]
|
||||||
public string DatabaseHost { get; set; } = "";
|
public string DatabaseHost { get; set; } = "";
|
||||||
@@ -51,6 +86,9 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
[JsonPropertyName("Messages")]
|
[JsonPropertyName("Messages")]
|
||||||
public Messages Messages { get; set; } = new Messages();
|
public Messages Messages { get; set; } = new Messages();
|
||||||
|
|
||||||
|
[JsonPropertyName("Additional")]
|
||||||
|
public Additional Additional { get; set; } = new Additional();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
16
README.md
16
README.md
@@ -1,13 +1,13 @@
|
|||||||
# cs2-WeaponPaints
|
# cs2-WeaponPaints
|
||||||
|
|
||||||
[](https://ko-fi.com/E1E2G0P2O) or [Donate on Steam](https://steamcommunity.com/tradeoffer/new/?partner=41515647&token=gW2W-nXE)
|
|
||||||
|
|
||||||
### 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/)
|
|
||||||
|
|
||||||
### Description
|
### Description
|
||||||
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!
|
||||||
|
|
||||||
### Created [Discord server](https://discord.gg/mwEQppJ5AT) where you can discus about plugin.
|
## Created [Discord server](https://discord.gg/mwEQppJ5AT) where you can discus about plugin.
|
||||||
|
|
||||||
|
### Consider to donate instead of buying from unknown sources.
|
||||||
|
[](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
|
||||||
@@ -24,12 +24,14 @@ 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**
|
||||||
|
|
||||||
### Web install:
|
### Web install:
|
||||||
- requires PHP (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
|
- copy website to web server (img folder not needed)
|
||||||
- import `database.sql` to mysql
|
- import `database.sql` to mysql
|
||||||
- get steam api key [https://steamcommunity.com/dev/apikey](https://steamcommunity.com/dev/apikey)
|
- get steam api key [https://steamcommunity.com/dev/apikey](https://steamcommunity.com/dev/apikey)
|
||||||
- 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
|
||||||
|
|
||||||
|
### 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
|
||||||

|

|
||||||
|
|||||||
460
WeaponPaints.cs
460
WeaponPaints.cs
@@ -1,28 +1,30 @@
|
|||||||
using CounterStrikeSharp.API;
|
using CounterStrikeSharp.API;
|
||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
|
using CounterStrikeSharp.API.Core.Attributes;
|
||||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||||
using CounterStrikeSharp.API.Modules.Commands;
|
using CounterStrikeSharp.API.Modules.Commands;
|
||||||
using CounterStrikeSharp.API.Modules.Entities;
|
using CounterStrikeSharp.API.Modules.Entities;
|
||||||
using CounterStrikeSharp.API.Modules.Memory;
|
using CounterStrikeSharp.API.Modules.Memory;
|
||||||
using CounterStrikeSharp.API.Modules.Menu;
|
using CounterStrikeSharp.API.Modules.Menu;
|
||||||
using CounterStrikeSharp.API.Modules.Utils;
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
using Nexd.MySQL;
|
using MySqlConnector;
|
||||||
|
using Dapper;
|
||||||
using System.Runtime.ExceptionServices;
|
using System.Runtime.ExceptionServices;
|
||||||
using static CounterStrikeSharp.API.Core.Listeners;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
|
|
||||||
namespace WeaponPaints;
|
namespace WeaponPaints;
|
||||||
|
[MinimumApiVersion(54)]
|
||||||
public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
||||||
{
|
{
|
||||||
public override string ModuleName => "WeaponPaints";
|
public override string ModuleName => "WeaponPaints";
|
||||||
public override string ModuleDescription => "Connector for web-based player chosen wepaon paints.";
|
public override string ModuleDescription => "Connector for web-based player chosen wepaon paints, and standalone for knife.";
|
||||||
public override string ModuleAuthor => "Nereziel";
|
public override string ModuleAuthor => "Nereziel";
|
||||||
public override string ModuleVersion => "0.8";
|
public override string ModuleVersion => "0.9";
|
||||||
|
|
||||||
public WeaponPaintsConfig Config { get; set; } = new();
|
public WeaponPaintsConfig Config { get; set; } = new();
|
||||||
|
|
||||||
MySqlDb? MySql = null;
|
private string DatabaseConnectionString = string.Empty;
|
||||||
private DateTime[] commandCooldown = new DateTime[Server.MaxPlayers];
|
private DateTime[] commandCooldown = new DateTime[Server.MaxPlayers];
|
||||||
private Dictionary<ulong, Dictionary<nint, int>> gPlayerWeaponPaints = new();
|
private Dictionary<ulong, Dictionary<nint, int>> gPlayerWeaponPaints = new();
|
||||||
private Dictionary<ulong, Dictionary<nint, int>> gPlayerWeaponSeed = new();
|
private Dictionary<ulong, Dictionary<nint, int>> gPlayerWeaponSeed = new();
|
||||||
@@ -30,26 +32,16 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
private Dictionary<int, string> g_playersKnife = new();
|
private Dictionary<int, string> g_playersKnife = new();
|
||||||
private static readonly Dictionary<string, string> knifeTypes = new()
|
private static readonly Dictionary<string, string> knifeTypes = new()
|
||||||
{
|
{
|
||||||
{ "m9", "weapon_knife_m9_bayonet" },
|
{ "m9", "weapon_knife_m9_bayonet" }, { "karambit", "weapon_knife_karambit" },
|
||||||
{ "karambit", "weapon_knife_karambit" },
|
{ "bayonet", "weapon_bayonet" }, { "bowie", "weapon_knife_survival_bowie" },
|
||||||
{ "bayonet", "weapon_bayonet" },
|
{ "butterfly", "weapon_knife_butterfly" }, { "falchion", "weapon_knife_falchion" },
|
||||||
{ "bowie", "weapon_knife_survival_bowie" },
|
{ "flip", "weapon_knife_flip" }, { "gut", "weapon_knife_gut" },
|
||||||
{ "butterfly", "weapon_knife_butterfly" },
|
{ "tactical", "weapon_knife_tactical" }, { "shadow", "weapon_knife_push" },
|
||||||
{ "falchion", "weapon_knife_falchion" },
|
{ "navaja", "weapon_knife_gypsy_jackknife" }, { "stiletto", "weapon_knife_stiletto" },
|
||||||
{ "flip", "weapon_knife_flip" },
|
{ "talon", "weapon_knife_widowmaker" }, { "ursus", "weapon_knife_ursus" },
|
||||||
{ "gut", "weapon_knife_gut" },
|
{ "css", "weapon_knife_css" }, { "paracord", "weapon_knife_cord" },
|
||||||
{ "tactical", "weapon_knife_tactical" },
|
{ "survival", "weapon_knife_canis" }, { "nomad", "weapon_knife_outdoor" },
|
||||||
{ "shadow", "weapon_knife_push" },
|
{ "skeleton", "weapon_knife_skeleton" }, { "default", "weapon_knife" }
|
||||||
{ "navaja", "weapon_knife_gypsy_jackknife" },
|
|
||||||
{ "stiletto", "weapon_knife_stiletto" },
|
|
||||||
{ "talon", "weapon_knife_widowmaker" },
|
|
||||||
{ "ursus", "weapon_knife_ursus" },
|
|
||||||
{ "css", "weapon_knife_css" },
|
|
||||||
{ "paracord", "weapon_knife_cord" },
|
|
||||||
{ "survival", "weapon_knife_canis" },
|
|
||||||
{ "nomad", "weapon_knife_outdoor" },
|
|
||||||
{ "skeleton", "weapon_knife_skeleton" },
|
|
||||||
{ "default", "weapon_knife" }
|
|
||||||
};
|
};
|
||||||
private static readonly List<string> weaponList = new()
|
private static readonly List<string> weaponList = new()
|
||||||
{
|
{
|
||||||
@@ -65,16 +57,32 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
};
|
};
|
||||||
public override void Load(bool hotReload)
|
public override void Load(bool hotReload)
|
||||||
{
|
{
|
||||||
base.Load(hotReload);
|
BuildDatabaseConnectionString();
|
||||||
|
TestDatabaseConnection();
|
||||||
SetGlobalExceptionHandler();
|
SetGlobalExceptionHandler();
|
||||||
MySql = new MySqlDb(Config.DatabaseHost, Config.DatabaseUser, Config.DatabasePassword, Config.DatabaseName!, Config.DatabasePort);
|
//MySql = new MySqlDb(Config.DatabaseHost, Config.DatabaseUser, Config.DatabasePassword, Config.DatabaseName!, Config.DatabasePort);
|
||||||
RegisterListener<Listeners.OnEntitySpawned>(OnEntitySpawned);
|
RegisterListener<Listeners.OnEntitySpawned>(OnEntitySpawned);
|
||||||
RegisterListener<Listeners.OnClientPutInServer>(OnClientPutInServer);
|
RegisterListener<Listeners.OnClientPutInServer>(OnClientPutInServer);
|
||||||
RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnect);
|
RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnect);
|
||||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||||
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
||||||
//RegisterEventHandler<EventRoundPrestart>(OnRoundPreStart);
|
if (Config.Additional.KnifeEnabled)
|
||||||
SetupMenus();
|
SetupMenus();
|
||||||
|
|
||||||
|
RegisterCommands();
|
||||||
|
if (hotReload)
|
||||||
|
{
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= Server.MaxPlayers; i++)
|
||||||
|
{
|
||||||
|
if (Config.Additional.KnifeEnabled)
|
||||||
|
await GetKnifeFromDatabase(i);
|
||||||
|
if (Config.Additional.SkinEnabled)
|
||||||
|
await GetWeaponPaintsFromDatabase(i);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void OnConfigParsed(WeaponPaintsConfig config)
|
public void OnConfigParsed(WeaponPaintsConfig config)
|
||||||
{
|
{
|
||||||
@@ -85,15 +93,80 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
|
|
||||||
Config = config;
|
Config = config;
|
||||||
}
|
}
|
||||||
// TODO: fix for map which change mp_t_default_melee
|
|
||||||
/*private HookResult OnRoundPreStart(EventRoundPrestart @event, GameEventInfo info)
|
private void BuildDatabaseConnectionString()
|
||||||
{
|
{
|
||||||
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
var builder = new MySqlConnectionStringBuilder
|
||||||
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
{
|
||||||
return HookResult.Continue;
|
Server = Config.DatabaseHost,
|
||||||
|
UserID = Config.DatabaseUser,
|
||||||
|
Password = Config.DatabasePassword,
|
||||||
|
Database = Config.DatabaseName,
|
||||||
|
Port = (uint)Config.DatabasePort,
|
||||||
|
};
|
||||||
|
|
||||||
|
DatabaseConnectionString = builder.ConnectionString;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
public override void Unload(bool hotReload)
|
private void TestDatabaseConnection()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new MySqlConnection(DatabaseConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
if (connection.State != System.Data.ConnectionState.Open)
|
||||||
|
{
|
||||||
|
throw new Exception("Unable connect to database!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception("Unknown mysql exception! " + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckDatabaseTables();
|
||||||
|
}
|
||||||
|
|
||||||
|
async private void CheckDatabaseTables()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new MySqlConnection(DatabaseConnectionString);
|
||||||
|
await connection.OpenAsync();
|
||||||
|
|
||||||
|
using var transaction = await connection.BeginTransactionAsync();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string createTable1 = "CREATE TABLE IF NOT EXISTS `wp_player_skins` (`steamid` varchar(64) NOT NULL, `weapon_defindex` int(6) NOT NULL, `weapon_paint_id` int(6) NOT NULL, `weapon_wear` float NOT NULL DEFAULT 0.0001, `weapon_seed` int(16) NOT NULL DEFAULT 0) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci";
|
||||||
|
string createTable2 = "CREATE TABLE IF NOT EXISTS `wp_player_knife` (`steamid` varchar(64) NOT NULL, `knife` varchar(64) NOT NULL, UNIQUE (`steamid`)) ENGINE = InnoDB";
|
||||||
|
|
||||||
|
await connection.ExecuteAsync(createTable1, transaction: transaction);
|
||||||
|
await connection.ExecuteAsync(createTable2, transaction: transaction);
|
||||||
|
|
||||||
|
await transaction.CommitAsync();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
await transaction.RollbackAsync();
|
||||||
|
throw new Exception("Unable to create tables!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception("Unknown mysql exception! " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO: fix for map which change mp_t_default_melee
|
||||||
|
/*private HookResult OnRoundPreStart(EventRoundPrestart @event, GameEventInfo info)
|
||||||
|
{
|
||||||
|
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
||||||
|
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
||||||
|
return HookResult.Continue;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
public override void Unload(bool hotReload)
|
||||||
{
|
{
|
||||||
RemoveGlobalExceptionHandler();
|
RemoveGlobalExceptionHandler();
|
||||||
base.Unload(hotReload);
|
base.Unload(hotReload);
|
||||||
@@ -110,8 +183,22 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
{
|
{
|
||||||
AppDomain.CurrentDomain.FirstChanceException -= this.GlobalExceptionHandler;
|
AppDomain.CurrentDomain.FirstChanceException -= this.GlobalExceptionHandler;
|
||||||
}
|
}
|
||||||
|
public void RegisterCommands()
|
||||||
|
{
|
||||||
|
AddCommand($"css_{Config.Additional.CommandSkin}", "Skins info", (player, info) => { if (player == null) return; OnCommandWS(player, info); });
|
||||||
|
AddCommand($"css_{Config.Additional.CommandRefresh}", "Skins refresh", (player, info) => { if (player == null) return; OnCommandRefresh(player, info); });
|
||||||
|
if (Config.Additional.CommandKillEnabled) {
|
||||||
|
AddCommand($"css_{Config.Additional.CommandKill}", "kill yourself", (player, info) => {
|
||||||
|
if(player == null || !player.IsValid || !player.PlayerPawn.IsValid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
player.PlayerPawn.Value.CommitSuicide(true, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
private void OnMapStart(string mapName)
|
private void OnMapStart(string mapName)
|
||||||
{
|
{
|
||||||
|
if (!Config.Additional.KnifeEnabled) return;
|
||||||
// TODO
|
// TODO
|
||||||
// needed for now
|
// needed for now
|
||||||
base.AddTimer(2.0f, () => {
|
base.AddTimer(2.0f, () => {
|
||||||
@@ -124,18 +211,25 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
{
|
{
|
||||||
int playerIndex = playerSlot + 1;
|
int playerIndex = playerSlot + 1;
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await GetKnifeFromDatabase(playerIndex);
|
if (Config.Additional.KnifeEnabled)
|
||||||
|
await GetKnifeFromDatabase(playerIndex);
|
||||||
|
if (Config.Additional.SkinEnabled)
|
||||||
await GetWeaponPaintsFromDatabase(playerIndex);
|
await GetWeaponPaintsFromDatabase(playerIndex);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private void OnClientDisconnect(int playerSlot)
|
private void OnClientDisconnect(int playerSlot)
|
||||||
{
|
{
|
||||||
// TODO: Clean up after player
|
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||||
g_playersKnife.Remove(playerSlot+1);
|
if (!player.IsValid || player.IsBot) return;
|
||||||
}
|
|
||||||
|
if (Config.Additional.KnifeEnabled)
|
||||||
|
g_playersKnife.Remove(playerSlot+1);
|
||||||
|
if (Config.Additional.SkinEnabled)
|
||||||
|
gPlayerWeaponPaints.Remove(new SteamID(player.SteamID).SteamId64);
|
||||||
|
}
|
||||||
|
|
||||||
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
var player = @event.Userid;
|
var player = @event.Userid;
|
||||||
if (!player.IsValid || !player.PlayerPawn.IsValid)
|
if (!player.IsValid || !player.PlayerPawn.IsValid)
|
||||||
@@ -143,17 +237,22 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
GiveKnifeToPlayer(player);
|
if (Config.Additional.KnifeEnabled) {
|
||||||
|
GiveKnifeToPlayer(player);
|
||||||
|
|
||||||
// Check the best slot and set it. Weird solution but works xD
|
AddTimer(0.1f, () => RefreshPlayerKnife(player));
|
||||||
AddTimer(0.1f, () => NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot3"));
|
}
|
||||||
AddTimer(0.25f, () => NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot2"));
|
|
||||||
AddTimer(0.35f, () => NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot1"));
|
if (Config.Additional.SkinVisibilityFix)
|
||||||
|
{
|
||||||
|
// Check the best slot and set it. Weird solution but works xD
|
||||||
|
}
|
||||||
|
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
private void OnEntitySpawned(CEntityInstance entity)
|
private void OnEntitySpawned(CEntityInstance entity)
|
||||||
{
|
{
|
||||||
|
if (!Config.Additional.SkinEnabled) return;
|
||||||
var designerName = entity.DesignerName;
|
var designerName = entity.DesignerName;
|
||||||
if (!weaponList.Contains(designerName)) return;
|
if (!weaponList.Contains(designerName)) return;
|
||||||
bool isKnife = false;
|
bool isKnife = false;
|
||||||
@@ -165,51 +264,55 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
}
|
}
|
||||||
Server.NextFrame(() =>
|
Server.NextFrame(() =>
|
||||||
{
|
{
|
||||||
if (!weapon.IsValid) return;
|
try {
|
||||||
if (weapon.OwnerEntity.Value == null) return;
|
if (!weapon.IsValid) return;
|
||||||
if (!weapon.OwnerEntity.Value.EntityIndex.HasValue) return;
|
if (weapon.OwnerEntity.Value == null) return;
|
||||||
int weaponOwner = (int)weapon.OwnerEntity.Value.EntityIndex.Value.Value;
|
if (!weapon.OwnerEntity.Value.EntityIndex.HasValue) return;
|
||||||
var pawn = new CBasePlayerPawn(NativeAPI.GetEntityFromIndex(weaponOwner));
|
int weaponOwner = (int)weapon.OwnerEntity.Value.EntityIndex.Value.Value;
|
||||||
if (!pawn.IsValid) return;
|
var pawn = new CBasePlayerPawn(NativeAPI.GetEntityFromIndex(weaponOwner));
|
||||||
var playerIndex = (int)pawn.Controller.Value.EntityIndex!.Value.Value;
|
if (!pawn.IsValid) return;
|
||||||
var player = Utilities.GetPlayerFromIndex(playerIndex);
|
var playerIndex = (int)pawn.Controller.Value.EntityIndex!.Value.Value;
|
||||||
if (player == null || !player.IsValid || player.IsBot) return;
|
var player = Utilities.GetPlayerFromIndex(playerIndex);
|
||||||
// TODO: Remove knife crashes here, needs another solution
|
if (player == null || !player.IsValid || player.IsBot) return;
|
||||||
/*if (isKnife && g_playersKnife[(int)player.EntityIndex!.Value.Value] != "weapon_knife" && (weapon.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.AttributeManager.Item.ItemDefinitionIndex == 59))
|
// TODO: Remove knife crashes here, needs another solution
|
||||||
{
|
/*if (isKnife && g_playersKnife[(int)player.EntityIndex!.Value.Value] != "weapon_knife" && (weapon.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.AttributeManager.Item.ItemDefinitionIndex == 59))
|
||||||
RemoveKnifeFromPlayer(player);
|
{
|
||||||
return;
|
RemoveKnifeFromPlayer(player);
|
||||||
}*/
|
return;
|
||||||
var steamId = new SteamID(player.SteamID);
|
}*/
|
||||||
if (!gPlayerWeaponPaints.ContainsKey(steamId.SteamId64)) return;
|
var steamId = new SteamID(player.SteamID);
|
||||||
if (!gPlayerWeaponPaints[steamId.SteamId64].ContainsKey(weapon.AttributeManager.Item.ItemDefinitionIndex)) return;
|
if (!gPlayerWeaponPaints.ContainsKey(steamId.SteamId64)) return;
|
||||||
//Log($"Apply on {weapon.DesignerName}({weapon.AttributeManager.Item.ItemDefinitionIndex}) paint {gPlayerWeaponPaints[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} seed {gPlayerWeaponSeed[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} wear {gPlayerWeaponWear[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]}");
|
if (!gPlayerWeaponPaints[steamId.SteamId64].ContainsKey(weapon.AttributeManager.Item.ItemDefinitionIndex)) return;
|
||||||
weapon.AttributeManager.Item.ItemID = 16384;
|
//Log($"Apply on {weapon.DesignerName}({weapon.AttributeManager.Item.ItemDefinitionIndex}) paint {gPlayerWeaponPaints[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} seed {gPlayerWeaponSeed[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} wear {gPlayerWeaponWear[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]}");
|
||||||
weapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
weapon.AttributeManager.Item.ItemID = 16384;
|
||||||
weapon.AttributeManager.Item.ItemIDHigh = weapon.AttributeManager.Item.ItemIDLow >> 32;
|
weapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||||
weapon.FallbackPaintKit = gPlayerWeaponPaints[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex];
|
weapon.AttributeManager.Item.ItemIDHigh = weapon.AttributeManager.Item.ItemIDLow >> 32;
|
||||||
weapon.FallbackSeed = gPlayerWeaponSeed[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex];
|
weapon.FallbackPaintKit = gPlayerWeaponPaints[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex];
|
||||||
weapon.FallbackWear = gPlayerWeaponWear[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex];
|
weapon.FallbackSeed = gPlayerWeaponSeed[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex];
|
||||||
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
weapon.FallbackWear = gPlayerWeaponWear[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex];
|
||||||
{
|
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||||
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
{
|
||||||
skeleton.ModelState.MeshGroupMask = 2;
|
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
||||||
}
|
skeleton.ModelState.MeshGroupMask = 2;
|
||||||
});
|
}
|
||||||
|
} catch(Exception) {}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
public void GiveKnifeToPlayer(CCSPlayerController player)
|
public void GiveKnifeToPlayer(CCSPlayerController player)
|
||||||
{
|
{
|
||||||
if (player.IsBot)
|
if (!Config.Additional.KnifeEnabled) return;
|
||||||
{
|
|
||||||
player.GiveNamedItem((CsTeam)player.TeamNum == CsTeam.Terrorist ? "weapon_knife_t" : "weapon_knife");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!PlayerHasKnife(player))
|
if (g_playersKnife.TryGetValue((int)player.EntityIndex!.Value.Value, out var knife))
|
||||||
{
|
{
|
||||||
if (g_playersKnife.TryGetValue((int)player.EntityIndex!.Value.Value, out var knife))
|
player.GiveNamedItem(knife);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Config.Additional.GiveRandomKnife)
|
||||||
{
|
{
|
||||||
player.GiveNamedItem(knife);
|
Random random = new Random();
|
||||||
|
int index = random.Next(knifeTypes.Count);
|
||||||
|
player.GiveNamedItem(knifeTypes.Values.ElementAt(index));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -219,7 +322,6 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
}
|
}
|
||||||
public void RemoveKnifeFromPlayer(CCSPlayerController player)
|
public void RemoveKnifeFromPlayer(CCSPlayerController player)
|
||||||
{
|
{
|
||||||
if (!g_playersKnife.ContainsKey((int)player.EntityIndex!.Value.Value)) return;
|
|
||||||
var weapons = player.PlayerPawn.Value.WeaponServices!.MyWeapons;
|
var weapons = player.PlayerPawn.Value.WeaponServices!.MyWeapons;
|
||||||
foreach (var weapon in weapons)
|
foreach (var weapon in weapons)
|
||||||
{
|
{
|
||||||
@@ -229,14 +331,80 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
if (weapon.Value.DesignerName.Contains("knife"))
|
if (weapon.Value.DesignerName.Contains("knife"))
|
||||||
{
|
{
|
||||||
weapon.Value.Remove();
|
weapon.Value.Remove();
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static bool PlayerHasKnife(CCSPlayerController player)
|
public void RefreshPlayerKnife(CCSPlayerController player)
|
||||||
{
|
{
|
||||||
|
if (!player.IsValid || !player.PawnIsAlive) return;
|
||||||
|
if (!PlayerHasKnife(player))
|
||||||
|
GiveKnifeToPlayer(player);
|
||||||
|
|
||||||
|
AddTimer(0.2f, () => NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot3"));
|
||||||
|
AddTimer(0.32f, () => NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot2"));
|
||||||
|
AddTimer(0.42f, () => NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot1"));
|
||||||
|
}
|
||||||
|
// Unused method, only for testing
|
||||||
|
// public void RefreshPlayerKnife(CCSPlayerController player)
|
||||||
|
// {
|
||||||
|
// if (!Config.Additional.KnifeEnabled) return;
|
||||||
|
// // if (!g_playersKnife.ContainsKey((int)player.EntityIndex!.Value.Value)) return;
|
||||||
|
|
||||||
|
// // if (!PlayerHasKnife(player))
|
||||||
|
// // player.GiveNamedItem((CsTeam)player.TeamNum == CsTeam.Terrorist ? "weapon_knife_t" : "weapon_knife");
|
||||||
|
|
||||||
|
// var weapons = player.PlayerPawn.Value.WeaponServices!.MyWeapons;
|
||||||
|
// foreach (var weapon in weapons)
|
||||||
|
// {
|
||||||
|
// if (weapon.IsValid && weapon.Value.IsValid)
|
||||||
|
// {
|
||||||
|
// //if (weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 59)
|
||||||
|
// if (weapon.Value.DesignerName.Contains("knife"))
|
||||||
|
// {
|
||||||
|
// weapon.Value.Remove();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// weapons = player.PlayerPawn.Value.WeaponServices!.MyWeapons;
|
||||||
|
// foreach (var weapon in weapons)
|
||||||
|
// {
|
||||||
|
// if (weapon.IsValid && weapon.Value.IsValid)
|
||||||
|
// {
|
||||||
|
// //if (weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 59)
|
||||||
|
// if (weapon.Value.DesignerName.Contains("knife"))
|
||||||
|
// {
|
||||||
|
// var temp = weapon.Value;
|
||||||
|
// var steamId = new SteamID(player.SteamID);
|
||||||
|
// if (!gPlayerWeaponPaints.ContainsKey(steamId.SteamId64)) return;
|
||||||
|
// if (!gPlayerWeaponPaints[steamId.SteamId64].ContainsKey(temp.AttributeManager.Item.ItemDefinitionIndex)) return;
|
||||||
|
// //Log($"Apply on {weapon.DesignerName}({weapon.AttributeManager.Item.ItemDefinitionIndex}) paint {gPlayerWeaponPaints[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} seed {gPlayerWeaponSeed[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} wear {gPlayerWeaponWear[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]}");
|
||||||
|
// temp.AttributeManager.Item.ItemID = 16384;
|
||||||
|
// temp.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||||
|
// temp.AttributeManager.Item.ItemIDHigh = temp.AttributeManager.Item.ItemIDLow >> 32;
|
||||||
|
// temp.FallbackPaintKit = gPlayerWeaponPaints[steamId.SteamId64][temp.AttributeManager.Item.ItemDefinitionIndex];
|
||||||
|
// temp.FallbackSeed = gPlayerWeaponSeed[steamId.SteamId64][temp.AttributeManager.Item.ItemDefinitionIndex];
|
||||||
|
// temp.FallbackWear = gPlayerWeaponWear[steamId.SteamId64][temp.AttributeManager.Item.ItemDefinitionIndex];
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
public bool PlayerHasKnife(CCSPlayerController player)
|
||||||
|
{
|
||||||
|
if (!Config.Additional.KnifeEnabled) return false;
|
||||||
|
|
||||||
|
if (!player.IsValid || !player.PawnIsAlive)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var weapons = player.PlayerPawn.Value.WeaponServices!.MyWeapons;
|
var weapons = player.PlayerPawn.Value.WeaponServices!.MyWeapons;
|
||||||
|
if (weapons == null) return false;
|
||||||
foreach (var weapon in weapons)
|
foreach (var weapon in weapons)
|
||||||
{
|
{
|
||||||
if (weapon.IsValid && weapon.Value.IsValid)
|
if (weapon.IsValid && weapon.Value.IsValid)
|
||||||
@@ -251,30 +419,37 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
}
|
}
|
||||||
private void SetupMenus()
|
private void SetupMenus()
|
||||||
{
|
{
|
||||||
|
if (!Config.Additional.KnifeEnabled) return;
|
||||||
var giveItemMenu = new ChatMenu(ReplaceTags(Config.Messages.KnifeMenuTitle));
|
var giveItemMenu = new ChatMenu(ReplaceTags(Config.Messages.KnifeMenuTitle));
|
||||||
var handleGive = (CCSPlayerController player, ChatMenuOption option) =>
|
var handleGive = (CCSPlayerController player, ChatMenuOption option) =>
|
||||||
{
|
{
|
||||||
|
string temp = "";
|
||||||
if (knifeTypes.TryGetValue(option.Text, out var knife))
|
if (knifeTypes.TryGetValue(option.Text, out var knife))
|
||||||
{
|
{
|
||||||
Task.Run(() => SyncKnifeToDatabase((int)player.EntityIndex!.Value.Value, knife));
|
|
||||||
g_playersKnife[(int)player.EntityIndex!.Value.Value] = knifeTypes[option.Text];
|
g_playersKnife[(int)player.EntityIndex!.Value.Value] = knifeTypes[option.Text];
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.ChosenKnifeMenu)) {
|
if (!string.IsNullOrEmpty(Config.Messages.ChosenKnifeMenu)) {
|
||||||
string temp = $"{Config.Prefix} {Config.Messages.ChosenKnifeMenu}".Replace("{KNIFE}", option.Text);
|
temp = $"{Config.Prefix} {Config.Messages.ChosenKnifeMenu}".Replace("{KNIFE}", option.Text);
|
||||||
player.PrintToChat(ReplaceTags(temp));
|
player.PrintToChat(ReplaceTags(temp));
|
||||||
}
|
}
|
||||||
|
if (!string.IsNullOrEmpty(Config.Messages.ChosenKnifeMenuKill) && Config.Additional.CommandKillEnabled) {
|
||||||
|
temp = $"{Config.Prefix} {Config.Messages.ChosenKnifeMenuKill}";
|
||||||
|
player.PrintToChat(ReplaceTags(temp));
|
||||||
|
}
|
||||||
|
Task.Run(() => SyncKnifeToDatabase((int)player.EntityIndex!.Value.Value, knife));
|
||||||
RemoveKnifeFromPlayer(player);
|
RemoveKnifeFromPlayer(player);
|
||||||
GiveKnifeToPlayer(player);
|
AddTimer(0.1f, () => GiveKnifeToPlayer(player));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
foreach (var knife in knifeTypes)
|
foreach (var knife in knifeTypes)
|
||||||
{
|
{
|
||||||
giveItemMenu.AddMenuOption(knife.Key, handleGive);
|
giveItemMenu.AddMenuOption(knife.Key, handleGive);
|
||||||
}
|
}
|
||||||
AddCommand("css_knife", "Knife Menu", (player, info) => { if (player == null) return; ChatMenus.OpenMenu(player, giveItemMenu); });
|
AddCommand($"css_{Config.Additional.CommandKnife}", "Knife Menu", (player, info) => { if (player == null) return; ChatMenus.OpenMenu(player, giveItemMenu); });
|
||||||
}
|
}
|
||||||
[ConsoleCommand("css_wp", "refreshskins")]
|
// [ConsoleCommand($"css_{Config.Additional.CommandRefresh}", "refreshskins")]
|
||||||
public void OnCommandRefresh(CCSPlayerController? player, CommandInfo command)
|
public void OnCommandRefresh(CCSPlayerController? player, CommandInfo command)
|
||||||
{
|
{
|
||||||
|
if (!Config.Additional.CommandWpEnabled || !Config.Additional.SkinEnabled) return;
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
string temp = "";
|
string temp = "";
|
||||||
int playerIndex = (int)player.EntityIndex!.Value.Value;
|
int playerIndex = (int)player.EntityIndex!.Value.Value;
|
||||||
@@ -282,6 +457,8 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
{
|
{
|
||||||
commandCooldown[playerIndex] = DateTime.UtcNow;
|
commandCooldown[playerIndex] = DateTime.UtcNow;
|
||||||
Task.Run(async () => await GetWeaponPaintsFromDatabase(playerIndex));
|
Task.Run(async () => await GetWeaponPaintsFromDatabase(playerIndex));
|
||||||
|
if (Config.Additional.KnifeEnabled)
|
||||||
|
Task.Run(async () => await GetKnifeFromDatabase(playerIndex));
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.SuccessRefreshCommand)) {
|
if (!string.IsNullOrEmpty(Config.Messages.SuccessRefreshCommand)) {
|
||||||
temp = $"{Config.Prefix} {Config.Messages.SuccessRefreshCommand}";
|
temp = $"{Config.Prefix} {Config.Messages.SuccessRefreshCommand}";
|
||||||
player.PrintToChat(ReplaceTags(temp));
|
player.PrintToChat(ReplaceTags(temp));
|
||||||
@@ -293,9 +470,10 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
player.PrintToChat(ReplaceTags(temp));
|
player.PrintToChat(ReplaceTags(temp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[ConsoleCommand("css_ws", "weaponskins")]
|
// [ConsoleCommand($"css_{Config.Additional.CommandSkin}", "weaponskins")]
|
||||||
public void OnCommandWS(CCSPlayerController? player, CommandInfo command)
|
public void OnCommandWS(CCSPlayerController? player, CommandInfo command)
|
||||||
{
|
{
|
||||||
|
if (!Config.Additional.SkinEnabled) return;
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
string temp = "";
|
string temp = "";
|
||||||
@@ -308,6 +486,7 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
temp = $"{Config.Prefix} {Config.Messages.SynchronizeMessageCommand}";
|
temp = $"{Config.Prefix} {Config.Messages.SynchronizeMessageCommand}";
|
||||||
player.PrintToChat(ReplaceTags(temp));
|
player.PrintToChat(ReplaceTags(temp));
|
||||||
}
|
}
|
||||||
|
if (!Config.Additional.KnifeEnabled) return;
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.KnifeMessageCommand)) {
|
if (!string.IsNullOrEmpty(Config.Messages.KnifeMessageCommand)) {
|
||||||
temp = $"{Config.Prefix} {Config.Messages.KnifeMessageCommand}";
|
temp = $"{Config.Prefix} {Config.Messages.KnifeMessageCommand}";
|
||||||
player.PrintToChat(ReplaceTags(temp));
|
player.PrintToChat(ReplaceTags(temp));
|
||||||
@@ -320,41 +499,44 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
}
|
}
|
||||||
private async Task GetWeaponPaintsFromDatabase(int playerIndex)
|
private async Task GetWeaponPaintsFromDatabase(int playerIndex)
|
||||||
{
|
{
|
||||||
|
if (!Config.Additional.SkinEnabled) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CCSPlayerController player = Utilities.GetPlayerFromIndex(playerIndex);
|
CCSPlayerController player = Utilities.GetPlayerFromIndex(playerIndex);
|
||||||
if (player == null || !player.IsValid) return;
|
if (player == null || !player.IsValid || player.IsBot) return;
|
||||||
var steamId = new SteamID(player.SteamID);
|
var steamId = new SteamID(player.SteamID);
|
||||||
|
|
||||||
MySqlQueryCondition conditions = new MySqlQueryCondition()
|
using (var connection = new MySqlConnection(DatabaseConnectionString))
|
||||||
.Add("steamid", "=", steamId.SteamId64.ToString());
|
|
||||||
|
|
||||||
MySqlQueryResult result = await MySql!.Table("wp_player_skins").Where(conditions).SelectAsync();
|
|
||||||
if (result.Rows < 1) return;
|
|
||||||
result.ToList().ForEach(pair =>
|
|
||||||
{
|
{
|
||||||
int WeaponDefIndex = result.Get<int>(pair.Key, "weapon_defindex");
|
await connection.OpenAsync();
|
||||||
int PaintId = result.Get<int>(pair.Key, "weapon_paint_id");
|
|
||||||
float Wear = result.Get<float>(pair.Key, "weapon_wear");
|
|
||||||
int Seed = result.Get<int>(pair.Key, "weapon_seed");
|
|
||||||
|
|
||||||
if (!gPlayerWeaponPaints.ContainsKey(steamId.SteamId64))
|
string query = "SELECT * FROM `wp_player_skins` WHERE `steamid` = @steamid";
|
||||||
{
|
|
||||||
gPlayerWeaponPaints[steamId.SteamId64] = new Dictionary<nint, int>();
|
|
||||||
}
|
|
||||||
if (!gPlayerWeaponWear.ContainsKey(steamId.SteamId64))
|
|
||||||
{
|
|
||||||
gPlayerWeaponWear[steamId.SteamId64] = new Dictionary<nint, float>();
|
|
||||||
}
|
|
||||||
if (!gPlayerWeaponSeed.ContainsKey(steamId.SteamId64))
|
|
||||||
{
|
|
||||||
gPlayerWeaponSeed[steamId.SteamId64] = new Dictionary<nint, int>();
|
|
||||||
}
|
|
||||||
|
|
||||||
gPlayerWeaponPaints[steamId.SteamId64][WeaponDefIndex] = PaintId;
|
IEnumerable<dynamic> PlayerSkins = await connection.QueryAsync<dynamic>(query, new { steamid = steamId.SteamId64.ToString() });
|
||||||
gPlayerWeaponWear[steamId.SteamId64][WeaponDefIndex] = Wear;
|
|
||||||
gPlayerWeaponSeed[steamId.SteamId64][WeaponDefIndex] = Seed;
|
if (PlayerSkins != null && PlayerSkins.AsList().Count > 0)
|
||||||
});
|
{
|
||||||
|
gPlayerWeaponPaints[steamId.SteamId64] = new Dictionary<nint, int>();
|
||||||
|
gPlayerWeaponWear[steamId.SteamId64] = new Dictionary<nint, float>();
|
||||||
|
gPlayerWeaponSeed[steamId.SteamId64] = new Dictionary<nint, int>();
|
||||||
|
|
||||||
|
PlayerSkins.ToList().ForEach(row =>
|
||||||
|
{
|
||||||
|
int weaponDefIndex = row.weapon_defindex ?? default(int);
|
||||||
|
int weaponPaintId = row.weapon_paint_id ?? default(int);
|
||||||
|
float weaponWear = row.weapon_wear ?? default(float);
|
||||||
|
int weaponSeed = row.weapon_seed ?? default(int);
|
||||||
|
|
||||||
|
gPlayerWeaponPaints[steamId.SteamId64][weaponDefIndex] = weaponPaintId;
|
||||||
|
gPlayerWeaponWear[steamId.SteamId64][weaponDefIndex] = weaponWear;
|
||||||
|
gPlayerWeaponSeed[steamId.SteamId64][weaponDefIndex] = weaponSeed;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -364,26 +546,27 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
}
|
}
|
||||||
private async Task GetKnifeFromDatabase(int playerIndex)
|
private async Task GetKnifeFromDatabase(int playerIndex)
|
||||||
{
|
{
|
||||||
|
if (!Config.Additional.KnifeEnabled) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CCSPlayerController player = Utilities.GetPlayerFromIndex(playerIndex);
|
CCSPlayerController player = Utilities.GetPlayerFromIndex(playerIndex);
|
||||||
if (player == null || !player.IsValid) return;
|
if (player == null || !player.IsValid || player.IsBot) return;
|
||||||
var steamId = new SteamID(player.SteamID);
|
var steamId = new SteamID(player.SteamID);
|
||||||
MySqlQueryCondition conditions = new MySqlQueryCondition()
|
|
||||||
.Add("steamid", "=", steamId.SteamId64.ToString());
|
|
||||||
|
|
||||||
MySqlQueryResult result = await MySql!.Table("wp_player_knife").Where(conditions).SelectAsync();
|
using (var connection = new MySqlConnection(DatabaseConnectionString))
|
||||||
|
|
||||||
if (result.Rows < 1)
|
|
||||||
{
|
{
|
||||||
//g_playersKnife[playerIndex] = "weapon_knife";
|
await connection.OpenAsync();
|
||||||
return;
|
string query = "SELECT `knife` FROM `wp_player_knife` WHERE `steamid` = @steamid";
|
||||||
}
|
string? PlayerKnife = await connection.QueryFirstOrDefaultAsync<string>(query, new { steamid = steamId.SteamId64.ToString() });
|
||||||
|
|
||||||
string knife = result.Get<string>(0, "knife");
|
if (PlayerKnife != null)
|
||||||
if (knife != null)
|
{
|
||||||
{
|
g_playersKnife[playerIndex] = PlayerKnife;
|
||||||
g_playersKnife[playerIndex] = knife;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//Log($"{player.PlayerName} has this knife -> {g_playersKnife[playerIndex]}");
|
//Log($"{player.PlayerName} has this knife -> {g_playersKnife[playerIndex]}");
|
||||||
}
|
}
|
||||||
@@ -395,12 +578,17 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
}
|
}
|
||||||
private async Task SyncKnifeToDatabase(int playerIndex, string knife)
|
private async Task SyncKnifeToDatabase(int playerIndex, string knife)
|
||||||
{
|
{
|
||||||
|
if (!Config.Additional.KnifeEnabled) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CCSPlayerController player = Utilities.GetPlayerFromIndex(playerIndex);
|
CCSPlayerController player = Utilities.GetPlayerFromIndex(playerIndex);
|
||||||
if (player == null || !player.IsValid) return;
|
if (player == null || !player.IsValid) return;
|
||||||
var steamId = new SteamID(player.SteamID);
|
var steamId = new SteamID(player.SteamID);
|
||||||
await MySql!.ExecuteNonQueryAsync($"INSERT INTO `wp_player_knife` (`steamid`, `knife`) VALUES('{steamId.SteamId64}', '{knife}') ON DUPLICATE KEY UPDATE `knife` = '{knife}';");
|
|
||||||
|
using var connection = new MySqlConnection(DatabaseConnectionString);
|
||||||
|
await connection.OpenAsync();
|
||||||
|
string query = "INSERT INTO `wp_player_knife` (`steamid`, `knife`) VALUES(@steamid, @newKnife) ON DUPLICATE KEY UPDATE `knife` = @newKnife";
|
||||||
|
await connection.ExecuteAsync(query, new { steamid = steamId.SteamId64.ToString(), newKnife = knife });
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CounterStrikeSharp.API" Version="*" />
|
<PackageReference Include="CounterStrikeSharp.API" Version="*" />
|
||||||
<PackageReference Include="Nexd.MySQL" Version="1.0.1" />
|
<PackageReference Include="Dapper" Version="2.1.21" />
|
||||||
|
<PackageReference Include="MySqlConnector" Version="2.3.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
96
website/class/utils.php
Normal file
96
website/class/utils.php
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
class UtilsClass
|
||||||
|
{
|
||||||
|
public static function skinsFromJson(): array
|
||||||
|
{
|
||||||
|
$skins = [];
|
||||||
|
$json = json_decode(file_get_contents(__DIR__ . "/../data/skins.json"), true);
|
||||||
|
|
||||||
|
foreach ($json as $skin) {
|
||||||
|
$skins[(int) $skin['weapon_defindex']][(int) $skin['paint']] = [
|
||||||
|
'weapon_name' => $skin['weapon_name'],
|
||||||
|
'paint_name' => $skin['paint_name'],
|
||||||
|
'image_url' => $skin['image'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $skins;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getWeaponsFromArray()
|
||||||
|
{
|
||||||
|
$weapons = [];
|
||||||
|
$temp = self::skinsFromJson();
|
||||||
|
|
||||||
|
foreach ($temp as $key => $value) {
|
||||||
|
if (key_exists($key, $weapons))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$weapons[$key] = [
|
||||||
|
'weapon_name' => $value[0]['weapon_name'],
|
||||||
|
'paint_name' => $value[0]['paint_name'],
|
||||||
|
'image_url' => $value[0]['image_url'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $weapons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getKnifeTypes()
|
||||||
|
{
|
||||||
|
$knifes = [];
|
||||||
|
$temp = self::getWeaponsFromArray();
|
||||||
|
|
||||||
|
foreach ($temp as $key => $weapon) {
|
||||||
|
if (
|
||||||
|
!in_array($key, [
|
||||||
|
500,
|
||||||
|
503,
|
||||||
|
505,
|
||||||
|
506,
|
||||||
|
507,
|
||||||
|
508,
|
||||||
|
509,
|
||||||
|
512,
|
||||||
|
514,
|
||||||
|
515,
|
||||||
|
516,
|
||||||
|
517,
|
||||||
|
518,
|
||||||
|
519,
|
||||||
|
520,
|
||||||
|
521,
|
||||||
|
522,
|
||||||
|
523,
|
||||||
|
525
|
||||||
|
])
|
||||||
|
)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$knifes[$key] = [
|
||||||
|
'weapon_name' => $weapon['weapon_name'],
|
||||||
|
'paint_name' => rtrim(explode("|", $weapon['paint_name'])[0]),
|
||||||
|
'image_url' => $weapon['image_url'],
|
||||||
|
];
|
||||||
|
$knifes[0] = [
|
||||||
|
'weapon_name' => "weapon_knife",
|
||||||
|
'paint_name' => "Default knife",
|
||||||
|
'image_url' => "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/weapon_knife.png",
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
ksort($knifes);
|
||||||
|
return $knifes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getSelectedSkins(array $temp)
|
||||||
|
{
|
||||||
|
$selected = [];
|
||||||
|
|
||||||
|
foreach ($temp as $weapon) {
|
||||||
|
$selected[$weapon['weapon_defindex']] = $weapon['weapon_paint_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $selected;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
website/data/skins.json
Normal file
1
website/data/skins.json
Normal file
File diff suppressed because one or more lines are too long
1819
website/database.sql
1819
website/database.sql
File diff suppressed because it is too large
Load Diff
BIN
website/img/skins/weapon_knife.png
Normal file
BIN
website/img/skins/weapon_knife.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
@@ -2,97 +2,144 @@
|
|||||||
require_once 'class/config.php';
|
require_once 'class/config.php';
|
||||||
require_once 'class/database.php';
|
require_once 'class/database.php';
|
||||||
require_once 'steamauth/steamauth.php';
|
require_once 'steamauth/steamauth.php';
|
||||||
|
require_once 'class/utils.php';
|
||||||
|
|
||||||
|
|
||||||
$db = new DataBase();
|
$db = new DataBase();
|
||||||
|
if (isset($_SESSION['steamid'])) {
|
||||||
|
|
||||||
if(isset($_SESSION['steamid']))
|
include('steamauth/userInfo.php');
|
||||||
{
|
|
||||||
include ('steamauth/userInfo.php');
|
|
||||||
$steamid = $steamprofile['steamid'];
|
$steamid = $steamprofile['steamid'];
|
||||||
|
|
||||||
if(isset($_POST['forma'])) {
|
$weapons = UtilsClass::getWeaponsFromArray();
|
||||||
|
$skins = UtilsClass::skinsFromJson();
|
||||||
|
$querySelected = $query3 = $db->select("SELECT `weapon_defindex`, `weapon_paint_id` FROM `wp_player_skins` WHERE `wp_player_skins`.`steamid` = :steamid", ["steamid" => $steamid]);
|
||||||
|
$selectedSkins = UtilsClass::getSelectedSkins($querySelected);
|
||||||
|
$selectedKnife = $db->select("SELECT * FROM `wp_player_knife` WHERE `wp_player_knife`.`steamid` = :steamid", ["steamid" => $steamid])[0];
|
||||||
|
$knifes = UtilsClass::getKnifeTypes();
|
||||||
|
|
||||||
|
if (isset($_POST['forma'])) {
|
||||||
$ex = explode("-", $_POST['forma']);
|
$ex = explode("-", $_POST['forma']);
|
||||||
|
|
||||||
$query2 = $db->select("SELECT * FROM wp_weapons_paints WHERE weapon_defindex = :weapon_defindex AND paint = :paint", ["weapon_defindex" => $ex[0], "paint" => $ex[1]]);
|
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']]);
|
||||||
if($query2) {
|
} else {
|
||||||
$check = $db->select("SELECT * FROM wp_weapons_paints LEFT JOIN wp_player_skins ON wp_player_skins.weapon_paint_id = wp_weapons_paints.paint AND wp_player_skins.weapon_defindex = wp_weapons_paints.weapon_defindex WHERE wp_weapons_paints.weapon_defindex = :weapon_defindex AND wp_player_skins.steamid = :steamid", ["weapon_defindex" => $ex[0], "steamid" => $steamid]);
|
if (array_key_exists($ex[1], $skins[$ex[0]])) {
|
||||||
if($check) {
|
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" => $query2[0]['paint']]);
|
$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]]);
|
||||||
} else {
|
} else {
|
||||||
$db->query("INSERT INTO wp_player_skins (`steamid`, `weapon_defindex`, `weapon_paint_id`) VALUES (:steamid, :weapon_defindex, :weapon_paint_id)", ["steamid" => $steamid, "weapon_defindex" => $ex[0],"weapon_paint_id" => $query2[0]["paint"]]);
|
$db->query("INSERT INTO wp_player_skins (`steamid`, `weapon_defindex`, `weapon_paint_id`) VALUES (:steamid, :weapon_defindex, :weapon_paint_id)", ["steamid" => $steamid, "weapon_defindex" => $ex[0], "weapon_paint_id" => $ex[1]]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
header("Location: index.php");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
<head>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
<meta charset="utf-8">
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||||
|
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
|
||||||
|
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="style.css">
|
||||||
<title>CS2 Simple Weapon Paints</title>
|
<title>CS2 Simple Weapon Paints</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if(!isset($_SESSION['steamid']))
|
if (!isset($_SESSION['steamid'])) {
|
||||||
{
|
echo "<div class='bg-primary'><h2>To choose weapon paints loadout, you need to ";
|
||||||
echo "<div class='bg-primary'><h2>To choose weapon paints loadout, you need to ";
|
loginbutton("rectangle");
|
||||||
loginbutton("rectangle");
|
echo "</h2></div>";
|
||||||
echo "</h2></div>";
|
} else {
|
||||||
}
|
echo "<div class='bg-primary'>Your current weapon skin loadout<form action='' method='get'><button class='btn btn-secondary' name='logout' type='submit'>Logout</button></form></div>";
|
||||||
else
|
echo "<div class='card-group mt-2'>";
|
||||||
{
|
?>
|
||||||
echo "<div class='bg-primary'>Your current weapon skin loadout<form action='' method='get'><button class='btn btn-secondary' name='logout' type='submit'>Logout</button></form></div>";
|
|
||||||
echo "<div class='card-group'>";
|
<div class="col-sm-2">
|
||||||
$query = $db->select("SELECT * FROM wp_weapons_paints GROUP BY weapon_defindex ORDER BY weapon_defindex");
|
<div class="card text-center mb-3 border border-primary">
|
||||||
foreach($query as $key) { ?>
|
<div class="card-body">
|
||||||
<div class="col-sm-2">
|
|
||||||
<div class="card text-center mb-3">
|
|
||||||
<div class="card-body">
|
|
||||||
<?php
|
|
||||||
if($query3 = $db->select("SELECT * FROM wp_weapons_paints LEFT JOIN wp_player_skins ON wp_player_skins.weapon_paint_id = wp_weapons_paints.paint AND wp_player_skins.weapon_defindex = wp_weapons_paints.weapon_defindex WHERE wp_player_skins.steamid = :steamid AND wp_weapons_paints.weapon_defindex = :weapon_defindex", ["steamid" => $steamid, "weapon_defindex" => $key['weapon_defindex']]))
|
|
||||||
{
|
|
||||||
echo "<div class='card-header'>";
|
|
||||||
echo"<h5 class='card-title item-name'>{$query3[0]["paint_name"]}</h5>";
|
|
||||||
echo "</div>";
|
|
||||||
echo "<img src='{$query3[0]["image"]}' class='skin-image' >";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
echo "<div class='card-header'>";
|
|
||||||
echo"<h5 class='card-title item-name'>{$key["paint_name"]}</h5>";
|
|
||||||
echo "</div>";
|
|
||||||
echo"<img src='{$key["image"]}' class='skin-image'>";
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
<div class="card-footer">
|
|
||||||
<form action="" method="POST">
|
|
||||||
<select name="forma" class="form-control select" onchange="this.form.submit()" class="SelectWeapon">
|
|
||||||
<option>Select skin</option>
|
|
||||||
<?php
|
<?php
|
||||||
$list = $db->select("SELECT * FROM wp_weapons_paints WHERE weapon_defindex = \"{$key["weapon_defindex"]}\"");
|
$actualKnife = $knifes[0];
|
||||||
foreach ($list as $list) {
|
foreach ($knifes as $knife) {
|
||||||
if ($list['paint_name'] == $query3[0]["paint_name"])
|
if ($selectedKnife['knife'] == $knife['weapon_name']) {
|
||||||
echo "<option selected value=\"{$list['weapon_defindex']}-{$list['paint']}\">{$list['paint_name']}</option>";
|
$actualKnife = $knife;
|
||||||
else
|
break;
|
||||||
echo "<option value=\"{$list['weapon_defindex']}-{$list['paint']}\">{$list['paint_name']}</option>";
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "<div class='card-header'>";
|
||||||
|
echo "<h6 class='card-title item-name'>Knife type</h6>";
|
||||||
|
echo "<h5 class='card-title item-name'>{$actualKnife["paint_name"]}</h5>";
|
||||||
|
echo "</div>";
|
||||||
|
echo "<img src='{$actualKnife["image_url"]}' class='skin-image'>";
|
||||||
?>
|
?>
|
||||||
</select>
|
</div>
|
||||||
</form>
|
<div class="card-footer">
|
||||||
|
<form action="" method="POST">
|
||||||
|
<select name="forma" class="form-control select" onchange="this.form.submit()" class="SelectWeapon">
|
||||||
|
<option>Select knife</option>
|
||||||
|
<?php
|
||||||
|
foreach ($knifes as $knifeKey => $knife) {
|
||||||
|
if ($selectedKnife['knife'] == $knife['weapon_name'])
|
||||||
|
echo "<option selected value=\"knife-{$knifeKey}\">{$knife['paint_name']}</option>";
|
||||||
|
else
|
||||||
|
echo "<option value=\"knife-{$knifeKey}\">{$knife['paint_name']}</option>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
<?php
|
||||||
|
foreach ($weapons as $defindex => $default) { ?>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<div class="card text-center mb-3">
|
||||||
|
<div class="card-body">
|
||||||
|
<?php
|
||||||
|
if (array_key_exists($defindex, $selectedSkins)) {
|
||||||
|
echo "<div class='card-header'>";
|
||||||
|
echo "<h5 class='card-title item-name'>{$skins[$defindex][$selectedSkins[$defindex]]["paint_name"]}</h5>";
|
||||||
|
echo "</div>";
|
||||||
|
echo "<img src='{$skins[$defindex][$selectedSkins[$defindex]]['image_url']}' class='skin-image'>";
|
||||||
|
} else {
|
||||||
|
echo "<div class='card-header'>";
|
||||||
|
echo "<h5 class='card-title item-name'>{$default["paint_name"]}</h5>";
|
||||||
|
echo "</div>";
|
||||||
|
echo "<img src='{$default["image_url"]}' class='skin-image'>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer">
|
||||||
|
<form action="" method="POST">
|
||||||
|
<select name="forma" class="form-control select" onchange="this.form.submit()" class="SelectWeapon">
|
||||||
|
<option>Select skin</option>
|
||||||
|
<?php
|
||||||
|
foreach ($skins[$defindex] as $paintKey => $paint) {
|
||||||
|
if (array_key_exists($defindex, $selectedSkins) && $selectedSkins[$defindex] == $paintKey)
|
||||||
|
echo "<option selected value=\"{$defindex}-{$paintKey}\">{$paint['paint_name']}</option>";
|
||||||
|
else
|
||||||
|
echo "<option value=\"{$defindex}-{$paintKey}\">{$paint['paint_name']}</option>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
113707
website/skins.json
113707
website/skins.json
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user