-
+ $selectedSkin) {
+ if (in_array($defindex, [500, 503, 505, 506, 507, 508, 509, 512, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 525, 526])) {
+ if (isset($skins[$defindex][$selectedSkin['weapon_paint_id']])) {
+ $displayKnifeSkin = $skins[$defindex][$selectedSkin['weapon_paint_id']];
+ $knifeSource = 'skin';
+ break; // Use the first knife skin found
}
}
- ?>
-
-
-
-
+ }
+
+ // If no knife skin, check for basic knife selection
+ if (!$displayKnifeSkin && $selectedKnife != null) {
+ foreach ($knifes as $knife) {
+ if ($selectedKnife[0]['knife'] == $knife['weapon_name']) {
+ $displayKnife = $knife;
+ $knifeSource = 'basic';
+ break;
+ }
+ }
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Knife
+
+
+
+
+
+
+
-
-
Knife
-
-
-
+
-
+
$selectedSkin): ?>
-
+
Date: Sun, 29 Jun 2025 23:40:56 +0200
Subject: [PATCH 14/27] Refactor weapon display logic in index.php to show all
weapons with custom skins or defaults, improving user interaction; update
HTML structure for better organization and clarity in skin selection.
---
website/index.php | 55 +++++++++++++++++++++++++++++------------------
1 file changed, 34 insertions(+), 21 deletions(-)
diff --git a/website/index.php b/website/index.php
index b4ed6fb9..a1bd45c9 100644
--- a/website/index.php
+++ b/website/index.php
@@ -236,35 +236,48 @@ if (isset($_SESSION['steamid'])) {
-
- $selectedSkin): ?>
-
-
+
+ $weapon): ?>
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
No weapons equipped
-
Browse weapons in the sidebar to equip skins
-
-
-
+
From 4f7af6986d96bbb327cd8c2c205b19d7da5f95fb Mon Sep 17 00:00:00 2001
From: Bram Suurd <78373894+BramSuurdje@users.noreply.github.com>
Date: Mon, 30 Jun 2025 00:02:01 +0200
Subject: [PATCH 15/27] Enhance knife selection logic in index.php to clear
existing knife skins and selections before updating, ensuring accurate
representation of equipped knives; improve user experience by prioritizing
basic knife options in the UI.
---
website/index.php | 78 +++++++++++++++++++++++++++++++----------------
1 file changed, 51 insertions(+), 27 deletions(-)
diff --git a/website/index.php b/website/index.php
index a1bd45c9..1b3f2e0e 100644
--- a/website/index.php
+++ b/website/index.php
@@ -28,12 +28,34 @@ if (isset($_SESSION['steamid'])) {
$ex = explode("-", $_POST['forma']);
if ($ex[0] == "knife") {
- $db->query("INSERT INTO `wp_player_knife` (`steamid`, `knife`, `weapon_team`) VALUES(:steamid, :knife, 2) ON DUPLICATE KEY UPDATE `knife` = :knife", ["steamid" => $steamid, "knife" => $knifes[$ex[1]]['weapon_name']]);
- $db->query("INSERT INTO `wp_player_knife` (`steamid`, `knife`, `weapon_team`) VALUES(:steamid, :knife, 3) ON DUPLICATE KEY UPDATE `knife` = :knife", ["steamid" => $steamid, "knife" => $knifes[$ex[1]]['weapon_name']]);
+ // Handle knife selection - use the knife key directly
+ if (isset($knifes[$ex[1]])) {
+ $knifeData = $knifes[$ex[1]];
+
+ // Clear any existing knife skins first
+ $db->query("DELETE FROM `wp_player_skins` WHERE `steamid` = :steamid AND `weapon_defindex` IN (500, 503, 505, 506, 507, 508, 509, 512, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 525, 526)", ["steamid" => $steamid]);
+
+ // Clear any existing basic knife selection first
+ $db->query("DELETE FROM `wp_player_knife` WHERE `steamid` = :steamid", ["steamid" => $steamid]);
+
+ // Set the new basic knife selection
+ $db->query("INSERT INTO `wp_player_knife` (`steamid`, `knife`, `weapon_team`) VALUES(:steamid, :knife, 2)", ["steamid" => $steamid, "knife" => $knifeData['weapon_name']]);
+ $db->query("INSERT INTO `wp_player_knife` (`steamid`, `knife`, `weapon_team`) VALUES(:steamid, :knife, 3)", ["steamid" => $steamid, "knife" => $knifeData['weapon_name']]);
+ }
} else {
if (array_key_exists($ex[1], $skins[$ex[0]]) && isset($_POST['wear']) && $_POST['wear'] >= 0.00 && $_POST['wear'] <= 1.00 && isset($_POST['seed'])) {
$wear = floatval($_POST['wear']);
$seed = intval($_POST['seed']);
+
+ // If this is a knife skin, clear basic knife selection AND other knife skins
+ if (in_array($ex[0], [500, 503, 505, 506, 507, 508, 509, 512, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 525, 526])) {
+ // Clear basic knife selection
+ $db->query("DELETE FROM `wp_player_knife` WHERE `steamid` = :steamid", ["steamid" => $steamid]);
+
+ // Clear ALL other knife skins (to handle switching between knife types)
+ $db->query("DELETE FROM `wp_player_skins` WHERE `steamid` = :steamid AND `weapon_defindex` IN (500, 503, 505, 506, 507, 508, 509, 512, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 525, 526) AND `weapon_defindex` != :current_defindex", ["steamid" => $steamid, "current_defindex" => $ex[0]]);
+ }
+
if (array_key_exists($ex[0], $selectedSkins)) {
$db->query("UPDATE wp_player_skins SET weapon_paint_id = :weapon_paint_id, weapon_wear = :weapon_wear, weapon_seed = :weapon_seed WHERE steamid = :steamid AND weapon_defindex = :weapon_defindex", ["steamid" => $steamid, "weapon_defindex" => $ex[0], "weapon_paint_id" => $ex[1], "weapon_wear" => $wear, "weapon_seed" => $seed]);
} else {
@@ -188,6 +210,9 @@ if (isset($_SESSION['steamid'])) {
$displayKnifeSkin = null;
$knifeSource = '';
+ // Debug: Show what's in selectedKnife
+ // echo "";
+
// Check if there's a knife skin equipped (from selectedSkins for knife defindexes)
foreach ($selectedSkins as $defindex => $selectedSkin) {
if (in_array($defindex, [500, 503, 505, 506, 507, 508, 509, 512, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 525, 526])) {
@@ -200,8 +225,8 @@ if (isset($_SESSION['steamid'])) {
}
// If no knife skin, check for basic knife selection
- if (!$displayKnifeSkin && $selectedKnife != null) {
- foreach ($knifes as $knife) {
+ if (!$displayKnifeSkin && $selectedKnife != null && !empty($selectedKnife)) {
+ foreach ($knifes as $knifeKey => $knife) {
if ($selectedKnife[0]['knife'] == $knife['weapon_name']) {
$displayKnife = $knife;
$knifeSource = 'basic';
@@ -276,17 +301,11 @@ if (isset($_SESSION['steamid'])) {
-
-
-
-
-
-
@@ -531,7 +550,28 @@ if (isset($_SESSION['steamid'])) {
// Clear previous content
skinGrid.innerHTML = '';
- // Check if this knife type has skins in the skins data
+ // ALWAYS show the basic knife option first
+ const knife = knivesData[knifeType];
+ if (knife) {
+ const basicKnifeOption = document.createElement('div');
+ basicKnifeOption.className = 'skin-option';
+
+ // Check if basic knife is currently selected (no knife skins equipped for this type)
+ if (!selectedSkinsData[knifeType]) {
+ basicKnifeOption.classList.add('active');
+ }
+
+ basicKnifeOption.onclick = () => equipKnife(knifeType);
+
+ basicKnifeOption.innerHTML = `
+
+
Default
+ `;
+
+ skinsContainer.appendChild(basicKnifeOption);
+ }
+
+ // Then show knife skins if available
if (skinsData[knifeType]) {
// This knife type has multiple skins
Object.entries(skinsData[knifeType]).forEach(([paintId, skin]) => {
@@ -552,22 +592,6 @@ if (isset($_SESSION['steamid'])) {
skinsContainer.appendChild(skinOption);
});
- } else {
- // This knife type has only one variant (the knife itself)
- const knife = knivesData[knifeType];
- if (knife) {
- const skinOption = document.createElement('div');
- skinOption.className = 'skin-option';
-
- skinOption.onclick = () => equipKnife(knifeType);
-
- skinOption.innerHTML = `
-
-
Default
- `;
-
- skinsContainer.appendChild(skinOption);
- }
}
skinGrid.appendChild(skinsContainer);
From b1d365ecb8abac75d006e4084f75ec36dea4c0db Mon Sep 17 00:00:00 2001
From: Bram Suurd <78373894+BramSuurdje@users.noreply.github.com>
Date: Mon, 30 Jun 2025 00:04:58 +0200
Subject: [PATCH 16/27] Implement default knife display logic in index.php to
ensure a knife is always shown, enhancing user experience by providing a
fallback option when no knife is selected. Update HTML comments for clarity.
---
website/index.php | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/website/index.php b/website/index.php
index 1b3f2e0e..61b703c9 100644
--- a/website/index.php
+++ b/website/index.php
@@ -234,9 +234,15 @@ if (isset($_SESSION['steamid'])) {
}
}
}
+
+ // If no knife selected at all, show default knife
+ if (!$displayKnifeSkin && !$displayKnife && isset($knifes[0])) {
+ $displayKnife = $knifes[0]; // Default knife
+ $knifeSource = 'default';
+ }
?>
-
+
@@ -259,7 +265,6 @@ if (isset($_SESSION['steamid'])) {
-
$weapon): ?>
From c1a96429611a70205331b7946e23eb88acbab3d4 Mon Sep 17 00:00:00 2001
From: Bram Suurd <78373894+BramSuurdje@users.noreply.github.com>
Date: Mon, 30 Jun 2025 00:18:04 +0200
Subject: [PATCH 17/27] Refactor knife exclusion logic in index.php to
comprehensively skip all knife-related weapons during display, enhancing
clarity in weapon selection. Update comments for better understanding of the
logic flow.
---
website/index.php | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/website/index.php b/website/index.php
index 61b703c9..4d310028 100644
--- a/website/index.php
+++ b/website/index.php
@@ -243,6 +243,7 @@ if (isset($_SESSION['steamid'])) {
?>
+
@@ -265,10 +266,22 @@ if (isset($_SESSION['steamid'])) {
+
$weapon): ?>
-
+
"
alt=""
class="item-image">
-
-
-
+
@@ -304,7 +315,6 @@ if (isset($_SESSION['steamid'])) {
-
@@ -580,6 +590,11 @@ if (isset($_SESSION['steamid'])) {
if (skinsData[knifeType]) {
// This knife type has multiple skins
Object.entries(skinsData[knifeType]).forEach(([paintId, skin]) => {
+ // Skip the default skin (paint ID 0) since we already show it as "Default" option above
+ if (paintId == '0') {
+ return;
+ }
+
const skinOption = document.createElement('div');
skinOption.className = 'skin-option';
From 6f02180dd48b51ad2ef598de6ea547f7d8670880 Mon Sep 17 00:00:00 2001
From: Bram Suurd <78373894+BramSuurdje@users.noreply.github.com>
Date: Mon, 30 Jun 2025 00:23:10 +0200
Subject: [PATCH 18/27] Add footer to index.php and style.css
---
website/index.php | 7 +++++++
website/style.css | 32 ++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/website/index.php b/website/index.php
index 4d310028..6544a50e 100644
--- a/website/index.php
+++ b/website/index.php
@@ -321,6 +321,13 @@ if (isset($_SESSION['steamid'])) {
+
+
+