Compare commits

...

18 Commits

Author SHA1 Message Date
Nereziel
118931f44d Merge pull request #34 from daffyyyy/enhancement/website-knife-choosing
Choosing knife on website
2023-11-16 00:39:19 +01:00
Nereziel
843ae34e31 Merge pull request #33 from daffyyyy/enhancement/config-expansion
Added an additional section to the config
2023-11-16 00:38:33 +01:00
Dawid Bepierszcz
46a720ff83 default knife image 2023-11-16 00:10:26 +01:00
Dawid Bepierszcz
63d059b607 Update utils.php 2023-11-16 00:07:27 +01:00
Dawid Bepierszcz
005ef18338 Update index.php 2023-11-16 00:06:16 +01:00
Dawid Bepierszcz
c0c1fe2566 Update WeaponPaints.cs 2023-11-16 00:05:34 +01:00
Dawid Bepierszcz
c4ad17a7ed MinimumApiVersion 2023-11-15 22:46:42 +01:00
Dawid Bepierszcz
99fde6ec52 Update Config.cs 2023-11-15 22:35:57 +01:00
Dawid Bepierszcz
ca2c3eb212 Update WeaponPaints.cs 2023-11-15 22:35:19 +01:00
Nereziel
b5a4577af1 Update README.md 2023-11-15 22:15:38 +01:00
Nereziel
ba93e4a3aa Update build.yml 2023-11-15 21:22:24 +01:00
Nereziel
7d435da9d1 Update build.yml 2023-11-15 21:19:48 +01:00
Nereziel
50008cf74a Merge pull request #32 from daffyyyy/enhancement/website-skins
Website now use json file to load skins
2023-11-15 20:52:20 +01:00
Dawid Bepierszcz
4b9b169483 Update database.sql, remove weapon_paints 2023-11-15 20:47:16 +01:00
Dawid Bepierszcz
25d251deff Skins in json format 2023-11-15 20:45:55 +01:00
Dawid Bepierszcz
d8f7798f9f New utils class 2023-11-15 20:44:46 +01:00
Dawid Bepierszcz
fb023aff5b Update index.php to base on json 2023-11-15 20:44:18 +01:00
Dawid Bepierszcz
6c91e20a4d Delete website/skins.json
Not needed
2023-11-15 20:43:28 +01:00
10 changed files with 277 additions and 115567 deletions

View File

@@ -34,13 +34,16 @@ jobs:
${{ 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:
@@ -54,4 +57,4 @@ jobs:
name: "Build ${{ env.BUILD_NUMBER }}" name: "Build ${{ env.BUILD_NUMBER }}"
tag: "build-${{ env.BUILD_NUMBER }}" tag: "build-${{ env.BUILD_NUMBER }}"
body: | body: |
Place the plugin in game/csgo/addons/counterstrikesharp/plugins/WeaponPaints Place the plugin in game/csgo/addons/counterstrikesharp/plugins/WeaponPaints

View File

@@ -21,9 +21,24 @@ namespace WeaponPaints
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;
}
public class WeaponPaintsConfig : BasePluginConfig public class WeaponPaintsConfig : BasePluginConfig
{ {
public override int Version { get; set; } = 2; public override int Version { get; set; } = 3;
[JsonPropertyName("DatabaseHost")] [JsonPropertyName("DatabaseHost")]
public string DatabaseHost { get; set; } = ""; public string DatabaseHost { get; set; } = "";
@@ -51,6 +66,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();
} }
} }

View File

@@ -1,13 +1,13 @@
# cs2-WeaponPaints # cs2-WeaponPaints
[![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)
### 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.
[![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
@@ -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
![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,5 +1,6 @@
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;
@@ -13,6 +14,7 @@ using System.Reflection;
namespace WeaponPaints; namespace WeaponPaints;
[MinimumApiVersion(52)]
public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig> public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
{ {
public override string ModuleName => "WeaponPaints"; public override string ModuleName => "WeaponPaints";
@@ -74,7 +76,8 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
RegisterListener<Listeners.OnMapStart>(OnMapStart); RegisterListener<Listeners.OnMapStart>(OnMapStart);
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn); RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
//RegisterEventHandler<EventRoundPrestart>(OnRoundPreStart); //RegisterEventHandler<EventRoundPrestart>(OnRoundPreStart);
SetupMenus(); if (Config.Additional.KnifeEnabled)
SetupMenus();
} }
public void OnConfigParsed(WeaponPaintsConfig config) public void OnConfigParsed(WeaponPaintsConfig config)
{ {
@@ -112,6 +115,7 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
} }
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,15 +128,17 @@ 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);
await GetWeaponPaintsFromDatabase(playerIndex); await GetWeaponPaintsFromDatabase(playerIndex);
}); });
} }
private void OnClientDisconnect(int playerSlot) private void OnClientDisconnect(int playerSlot)
{ {
// TODO: Clean up after player // TODO: Clean up after player
g_playersKnife.Remove(playerSlot+1); if (Config.Additional.KnifeEnabled)
g_playersKnife.Remove(playerSlot+1);
} }
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info) private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
@@ -143,17 +149,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 if (Config.Additional.SkinVisibilityFix)
AddTimer(0.1f, () => NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot3")); {
AddTimer(0.25f, () => NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot2")); // Check the best slot and set it. Weird solution but works xD
AddTimer(0.35f, () => NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot1")); 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"));
}
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;
@@ -199,6 +210,7 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
} }
public void GiveKnifeToPlayer(CCSPlayerController player) public void GiveKnifeToPlayer(CCSPlayerController player)
{ {
if (!Config.Additional.KnifeEnabled) return;
if (player.IsBot) if (player.IsBot)
{ {
player.GiveNamedItem((CsTeam)player.TeamNum == CsTeam.Terrorist ? "weapon_knife_t" : "weapon_knife"); player.GiveNamedItem((CsTeam)player.TeamNum == CsTeam.Terrorist ? "weapon_knife_t" : "weapon_knife");
@@ -219,6 +231,7 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
} }
public void RemoveKnifeFromPlayer(CCSPlayerController player) public void RemoveKnifeFromPlayer(CCSPlayerController player)
{ {
if (!Config.Additional.KnifeEnabled) return;
if (!g_playersKnife.ContainsKey((int)player.EntityIndex!.Value.Value)) return; 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)
@@ -234,8 +247,9 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
} }
} }
} }
public static bool PlayerHasKnife(CCSPlayerController player) public bool PlayerHasKnife(CCSPlayerController player)
{ {
if (!Config.Additional.KnifeEnabled) return true;
var weapons = player.PlayerPawn.Value.WeaponServices!.MyWeapons; var weapons = player.PlayerPawn.Value.WeaponServices!.MyWeapons;
foreach (var weapon in weapons) foreach (var weapon in weapons)
{ {
@@ -251,6 +265,7 @@ 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) =>
{ {
@@ -275,6 +290,7 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
[ConsoleCommand("css_wp", "refreshskins")] [ConsoleCommand("css_wp", "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 +298,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));
@@ -296,6 +314,7 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
[ConsoleCommand("css_ws", "weaponskins")] [ConsoleCommand("css_ws", "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 +327,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,6 +340,7 @@ 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);
@@ -364,6 +385,7 @@ 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);
@@ -395,6 +417,7 @@ 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);

96
website/class/utils.php Normal file
View 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

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -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>

File diff suppressed because it is too large Load Diff