mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-03-10 16:34:38 +00:00
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.
This commit is contained in:
@@ -243,6 +243,7 @@ if (isset($_SESSION['steamid'])) {
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<!-- Always show a knife (either selected or default) -->
|
<!-- Always show a knife (either selected or default) -->
|
||||||
|
<?php if ($displayKnifeSkin || $displayKnife): ?>
|
||||||
<div class="loadout-item" data-weapon-type="knife">
|
<div class="loadout-item" data-weapon-type="knife">
|
||||||
<div class="item-image-container">
|
<div class="item-image-container">
|
||||||
<?php if ($knifeSource == 'skin'): ?>
|
<?php if ($knifeSource == 'skin'): ?>
|
||||||
@@ -265,10 +266,22 @@ if (isset($_SESSION['steamid'])) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<!-- Show all weapons (exclude knives) - either with custom skin or default -->
|
<!-- Show all weapons (exclude knives) - either with custom skin or default -->
|
||||||
<?php foreach ($weapons as $defindex => $weapon): ?>
|
<?php foreach ($weapons as $defindex => $weapon): ?>
|
||||||
<?php if (!in_array($defindex, [500, 503, 505, 506, 507, 508, 509, 512, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 525, 526])): ?>
|
<?php
|
||||||
|
// Skip ALL knives - comprehensive check
|
||||||
|
$isKnifeWeapon = in_array($defindex, [500, 503, 505, 506, 507, 508, 509, 512, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 525, 526]);
|
||||||
|
$isDefaultKnife = ($weapon['weapon_name'] == 'weapon_knife');
|
||||||
|
$isKnifeVariant = (strpos($weapon['weapon_name'], 'knife') !== false);
|
||||||
|
$isKnifePaint = (strpos($weapon['paint_name'], '★') !== false); // Knife skins have ★ in name
|
||||||
|
|
||||||
|
// Skip ANY knife-related weapon
|
||||||
|
if ($isKnifeWeapon || $isDefaultKnife || $isKnifeVariant || $isKnifePaint) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
?>
|
||||||
<?php
|
<?php
|
||||||
$hasCustomSkin = array_key_exists($defindex, $selectedSkins);
|
$hasCustomSkin = array_key_exists($defindex, $selectedSkins);
|
||||||
$isEquipped = $hasCustomSkin ? 'true' : 'false';
|
$isEquipped = $hasCustomSkin ? 'true' : 'false';
|
||||||
@@ -288,9 +301,7 @@ if (isset($_SESSION['steamid'])) {
|
|||||||
<img src="<?php echo $weapon['image_url']; ?>"
|
<img src="<?php echo $weapon['image_url']; ?>"
|
||||||
alt="<?php echo $weapon['paint_name']; ?>"
|
alt="<?php echo $weapon['paint_name']; ?>"
|
||||||
class="item-image">
|
class="item-image">
|
||||||
<div class="item-overlay">
|
<!-- No overlay button for default weapons -->
|
||||||
<button class="equip-btn" onclick="toggleWeaponSkins(<?php echo $defindex; ?>)">Equip Skin</button>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="item-info">
|
<div class="item-info">
|
||||||
@@ -304,7 +315,6 @@ if (isset($_SESSION['steamid'])) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
@@ -580,6 +590,11 @@ if (isset($_SESSION['steamid'])) {
|
|||||||
if (skinsData[knifeType]) {
|
if (skinsData[knifeType]) {
|
||||||
// This knife type has multiple skins
|
// This knife type has multiple skins
|
||||||
Object.entries(skinsData[knifeType]).forEach(([paintId, skin]) => {
|
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');
|
const skinOption = document.createElement('div');
|
||||||
skinOption.className = 'skin-option';
|
skinOption.className = 'skin-option';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user