Compare commits
31 Commits
build-370
...
4f6cc349bd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f6cc349bd | ||
|
|
c1cd229ea8 | ||
|
|
efc37e6232 | ||
|
|
930c673e2a | ||
|
|
cceb9b10d7 | ||
|
|
0d7077063f | ||
|
|
cc5da9eabb | ||
|
|
b7ff9e2848 | ||
|
|
d0ae4b4c51 | ||
|
|
a43de55776 | ||
|
|
b87639d0e2 | ||
|
|
6f02180dd4 | ||
|
|
c1a9642961 | ||
|
|
b1d365ecb8 | ||
|
|
4f7af6986d | ||
|
|
0ebab4e371 | ||
|
|
bfa69b7e59 | ||
|
|
a2e60df71f | ||
|
|
e8871f91ac | ||
|
|
5c3b1b48b0 | ||
|
|
4ab85d09e2 | ||
|
|
dbc8f2ebf8 | ||
|
|
742e753e70 | ||
|
|
199a090e8c | ||
|
|
048ce5cf5e | ||
|
|
e540e1e8e3 | ||
|
|
dd7f45902b | ||
|
|
0e7d4a8356 | ||
|
|
b2dc9ed56d | ||
|
|
6870dd0e57 | ||
|
|
03b9e686b5 |
@@ -3,7 +3,7 @@
|
|||||||
"signatures": {
|
"signatures": {
|
||||||
"library": "server",
|
"library": "server",
|
||||||
"windows": "48 89 6C 24 ? 56 48 83 EC ? 48 8B EA 48 8B F1 E8 ? ? ? ? 84 C0 0F 84",
|
"windows": "48 89 6C 24 ? 56 48 83 EC ? 48 8B EA 48 8B F1 E8 ? ? ? ? 84 C0 0F 84",
|
||||||
"linux": "55 48 89 E5 41 57 41 56 41 55 49 89 F5 41 54 49 89 FC 53 48 81 EC A8 00 00 00"
|
"linux": "55 48 89 E5 41 55 41 54 49 89 F4 53 48 89 FB 48 83 EC ? E8 ? ? ? ? 84 C0 74"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"CAttributeList_SetOrAddAttributeValueByName": {
|
"CAttributeList_SetOrAddAttributeValueByName": {
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
"signatures": {
|
"signatures": {
|
||||||
"library": "server",
|
"library": "server",
|
||||||
"windows": "48 89 5C 24 08 48 89 74 24 10 57 48 83 EC 20 41 8B F8 48 8B F2 48 8B D9 E8 ? ? ? ?",
|
"windows": "48 89 5C 24 08 48 89 74 24 10 57 48 83 EC 20 41 8B F8 48 8B F2 48 8B D9 E8 ? ? ? ?",
|
||||||
"linux": "55 48 89 E5 41 56 49 89 F6 41 55 41 89 D5 41 54 49 89 FC 48 83 EC 08"
|
"linux": "55 48 89 E5 41 55 49 89 F5 41 54 41 89 D4 53 48 89 FB 48 83 EC 08 E8 ? ? ? ? 48 85 C0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,3 @@ define('STEAM_API_KEY', '');
|
|||||||
define('STEAM_DOMAIN_NAME', '');
|
define('STEAM_DOMAIN_NAME', '');
|
||||||
define('STEAM_LOGOUT_PAGE', '');
|
define('STEAM_LOGOUT_PAGE', '');
|
||||||
define('STEAM_LOGIN_PAGE', '');
|
define('STEAM_LOGIN_PAGE', '');
|
||||||
|
|
||||||
|
|||||||
@@ -1,95 +1,159 @@
|
|||||||
<?php
|
<?php
|
||||||
class UtilsClass
|
class UtilsClass
|
||||||
{
|
{
|
||||||
|
// Knife defindexes as constants for better maintainability
|
||||||
|
private const KNIFE_DEFINDEXES = [
|
||||||
|
500, 503, 505, 506, 507, 508, 509, 512, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 525, 526
|
||||||
|
];
|
||||||
|
|
||||||
|
// Knife mapping for better maintainability
|
||||||
|
private const KNIFE_MAPPING = [
|
||||||
|
500 => 'weapon_bayonet',
|
||||||
|
503 => 'weapon_knife_css',
|
||||||
|
505 => 'weapon_knife_flip',
|
||||||
|
506 => 'weapon_knife_gut',
|
||||||
|
507 => 'weapon_knife_karambit',
|
||||||
|
508 => 'weapon_knife_m9_bayonet',
|
||||||
|
509 => 'weapon_knife_tactical',
|
||||||
|
512 => 'weapon_knife_falchion',
|
||||||
|
514 => 'weapon_knife_survival_bowie',
|
||||||
|
515 => 'weapon_knife_butterfly',
|
||||||
|
516 => 'weapon_knife_push',
|
||||||
|
517 => 'weapon_knife_cord',
|
||||||
|
518 => 'weapon_knife_canis',
|
||||||
|
519 => 'weapon_knife_ursus',
|
||||||
|
520 => 'weapon_knife_gypsy_jackknife',
|
||||||
|
521 => 'weapon_knife_outdoor',
|
||||||
|
522 => 'weapon_knife_stiletto',
|
||||||
|
523 => 'weapon_knife_widowmaker',
|
||||||
|
525 => 'weapon_knife_skeleton',
|
||||||
|
526 => 'weapon_knife_css'
|
||||||
|
];
|
||||||
|
|
||||||
|
// Weapon categories for better organization
|
||||||
|
private const WEAPON_CATEGORIES = [
|
||||||
|
'Rifles' => [7, 8, 10, 13, 16, 60, 39, 40, 38],
|
||||||
|
'Pistols' => [1, 2, 3, 4, 30, 32, 36, 61, 63, 64],
|
||||||
|
'SMGs' => [17, 19, 24, 26, 33, 34],
|
||||||
|
'Shotguns' => [25, 27, 29, 35],
|
||||||
|
'Snipers' => [9, 11, 38],
|
||||||
|
'Machine Guns' => [14, 28],
|
||||||
|
'Grenades' => [43, 44, 45, 46, 47, 48]
|
||||||
|
];
|
||||||
|
|
||||||
|
private static $skinCache = null;
|
||||||
|
private static $weaponCache = null;
|
||||||
|
private static $knifeCache = null;
|
||||||
|
|
||||||
|
public static function getKnifeDefindexes(): array
|
||||||
|
{
|
||||||
|
return self::KNIFE_DEFINDEXES;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getKnifeMapping(): array
|
||||||
|
{
|
||||||
|
return self::KNIFE_MAPPING;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getWeaponCategories(): array
|
||||||
|
{
|
||||||
|
return self::WEAPON_CATEGORIES;
|
||||||
|
}
|
||||||
|
|
||||||
public static function skinsFromJson(): array
|
public static function skinsFromJson(): array
|
||||||
{
|
{
|
||||||
|
if (self::$skinCache !== null) {
|
||||||
|
return self::$skinCache;
|
||||||
|
}
|
||||||
|
|
||||||
$skins = [];
|
$skins = [];
|
||||||
$json = json_decode(file_get_contents(__DIR__ . "/../data/".SKIN_LANGUAGE.".json"), true);
|
$jsonFile = __DIR__ . "/../data/" . SKIN_LANGUAGE . ".json";
|
||||||
|
|
||||||
|
if (!file_exists($jsonFile)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = json_decode(file_get_contents($jsonFile), true);
|
||||||
|
if (!$json) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($json as $skin) {
|
foreach ($json as $skin) {
|
||||||
$skins[(int) $skin['weapon_defindex']][(int) $skin['paint']] = [
|
$defindex = (int) $skin['weapon_defindex'];
|
||||||
|
$paintId = (int) $skin['paint'];
|
||||||
|
|
||||||
|
$skins[$defindex][$paintId] = [
|
||||||
'weapon_name' => $skin['weapon_name'],
|
'weapon_name' => $skin['weapon_name'],
|
||||||
'paint_name' => $skin['paint_name'],
|
'paint_name' => $skin['paint_name'],
|
||||||
'image_url' => $skin['image'],
|
'image_url' => $skin['image'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self::$skinCache = $skins;
|
||||||
return $skins;
|
return $skins;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getWeaponsFromArray()
|
public static function getWeaponsFromArray(): array
|
||||||
{
|
{
|
||||||
$weapons = [];
|
if (self::$weaponCache !== null) {
|
||||||
$temp = self::skinsFromJson();
|
return self::$weaponCache;
|
||||||
|
|
||||||
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'],
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$weapons = [];
|
||||||
|
$skins = self::skinsFromJson();
|
||||||
|
|
||||||
|
foreach ($skins as $defindex => $skinList) {
|
||||||
|
if (!isset($weapons[$defindex]) && isset($skinList[0])) {
|
||||||
|
$weapons[$defindex] = [
|
||||||
|
'weapon_name' => $skinList[0]['weapon_name'],
|
||||||
|
'paint_name' => $skinList[0]['paint_name'],
|
||||||
|
'image_url' => $skinList[0]['image_url'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$weaponCache = $weapons;
|
||||||
return $weapons;
|
return $weapons;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getKnifeTypes()
|
public static function getKnifeTypes(): array
|
||||||
{
|
{
|
||||||
$knifes = [];
|
if (self::$knifeCache !== null) {
|
||||||
$temp = self::getWeaponsFromArray();
|
return self::$knifeCache;
|
||||||
|
|
||||||
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,
|
|
||||||
526
|
|
||||||
])
|
|
||||||
)
|
|
||||||
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",
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$knifes = [];
|
||||||
|
$weapons = self::getWeaponsFromArray();
|
||||||
|
|
||||||
|
foreach (self::KNIFE_DEFINDEXES as $defindex) {
|
||||||
|
if (isset($weapons[$defindex])) {
|
||||||
|
$weapon = $weapons[$defindex];
|
||||||
|
$knifes[$defindex] = [
|
||||||
|
'weapon_name' => $weapon['weapon_name'],
|
||||||
|
'paint_name' => rtrim(explode("|", $weapon['paint_name'])[0]),
|
||||||
|
'image_url' => $weapon['image_url'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add default knife
|
||||||
|
$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);
|
ksort($knifes);
|
||||||
|
self::$knifeCache = $knifes;
|
||||||
return $knifes;
|
return $knifes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSelectedSkins(array $temp)
|
public static function getSelectedSkins(array $queryResult): array
|
||||||
{
|
{
|
||||||
$selected = [];
|
$selected = [];
|
||||||
|
|
||||||
foreach ($temp as $weapon) {
|
foreach ($queryResult as $weapon) {
|
||||||
$selected[$weapon['weapon_defindex']] = [
|
$selected[$weapon['weapon_defindex']] = [
|
||||||
'weapon_paint_id' => $weapon['weapon_paint_id'],
|
'weapon_paint_id' => $weapon['weapon_paint_id'],
|
||||||
'weapon_seed' => $weapon['weapon_seed'],
|
'weapon_seed' => $weapon['weapon_seed'],
|
||||||
'weapon_wear' => $weapon['weapon_wear'],
|
'weapon_wear' => $weapon['weapon_wear'],
|
||||||
@@ -98,4 +162,23 @@ class UtilsClass
|
|||||||
|
|
||||||
return $selected;
|
return $selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isKnifeDefindex(int $defindex): bool
|
||||||
|
{
|
||||||
|
return in_array($defindex, self::KNIFE_DEFINDEXES);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isKnifeWeapon(array $weapon): bool
|
||||||
|
{
|
||||||
|
return $weapon['weapon_name'] === 'weapon_knife' ||
|
||||||
|
strpos($weapon['weapon_name'], 'knife') !== false ||
|
||||||
|
strpos($weapon['paint_name'], '★') !== false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function clearCache(): void
|
||||||
|
{
|
||||||
|
self::$skinCache = null;
|
||||||
|
self::$weaponCache = null;
|
||||||
|
self::$knifeCache = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
304
website/class/weapon_handler.php
Normal file
@@ -0,0 +1,304 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'utils.php';
|
||||||
|
require_once 'database.php';
|
||||||
|
|
||||||
|
class WeaponHandler
|
||||||
|
{
|
||||||
|
private $db;
|
||||||
|
private $steamid;
|
||||||
|
|
||||||
|
public function __construct($steamid)
|
||||||
|
{
|
||||||
|
$this->db = new DataBase();
|
||||||
|
$this->steamid = $steamid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handleWeaponUpdate($postData): bool
|
||||||
|
{
|
||||||
|
if (!isset($postData['forma'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$formaParts = explode("-", $postData['forma']);
|
||||||
|
|
||||||
|
if ($formaParts[0] === "knife") {
|
||||||
|
return $this->handleKnifeSelection($formaParts[1]);
|
||||||
|
} else {
|
||||||
|
return $this->handleWeaponSkin($formaParts, $postData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function handleKnifeSelection($knifeId): bool
|
||||||
|
{
|
||||||
|
$knifes = UtilsClass::getKnifeTypes();
|
||||||
|
|
||||||
|
if (!isset($knifes[$knifeId])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$knifeData = $knifes[$knifeId];
|
||||||
|
|
||||||
|
// Clear existing knife data
|
||||||
|
$this->clearKnifeData();
|
||||||
|
|
||||||
|
// Set new knife selection (insert for both teams separately)
|
||||||
|
$this->db->query(
|
||||||
|
"INSERT INTO `wp_player_knife` (`steamid`, `knife`, `weapon_team`) VALUES (:steamid, :knife, 2)",
|
||||||
|
["steamid" => $this->steamid, "knife" => $knifeData['weapon_name']]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->db->query(
|
||||||
|
"INSERT INTO `wp_player_knife` (`steamid`, `knife`, `weapon_team`) VALUES (:steamid, :knife, 3)",
|
||||||
|
["steamid" => $this->steamid, "knife" => $knifeData['weapon_name']]
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function handleWeaponSkin($formaParts, $postData): bool
|
||||||
|
{
|
||||||
|
$defindex = $formaParts[0];
|
||||||
|
$paintId = $formaParts[1];
|
||||||
|
|
||||||
|
$skins = UtilsClass::skinsFromJson();
|
||||||
|
|
||||||
|
if (!isset($skins[$defindex][$paintId]) ||
|
||||||
|
!isset($postData['wear']) ||
|
||||||
|
!isset($postData['seed'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$wear = $this->validateWear($postData['wear']);
|
||||||
|
$seed = $this->validateSeed($postData['seed']);
|
||||||
|
|
||||||
|
if ($wear === false || $seed === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle knife skins
|
||||||
|
if (UtilsClass::isKnifeDefindex($defindex)) {
|
||||||
|
$this->handleKnifeSkin($defindex, $paintId, $wear, $seed);
|
||||||
|
} else {
|
||||||
|
$this->handleRegularWeaponSkin($defindex, $paintId, $wear, $seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function handleKnifeSkin($defindex, $paintId, $wear, $seed): void
|
||||||
|
{
|
||||||
|
$knifeMapping = UtilsClass::getKnifeMapping();
|
||||||
|
|
||||||
|
// Clear existing knife data
|
||||||
|
$this->clearKnifeData();
|
||||||
|
|
||||||
|
// Clear other knife skins
|
||||||
|
$knifeDefindexes = UtilsClass::getKnifeDefindexes();
|
||||||
|
foreach ($knifeDefindexes as $knifeDefindex) {
|
||||||
|
if ($knifeDefindex != $defindex) {
|
||||||
|
$this->db->query(
|
||||||
|
"DELETE FROM `wp_player_skins` WHERE `steamid` = :steamid AND `weapon_defindex` = :weapon_defindex",
|
||||||
|
["steamid" => $this->steamid, "weapon_defindex" => $knifeDefindex]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set knife type in wp_player_knife table
|
||||||
|
if (isset($knifeMapping[$defindex])) {
|
||||||
|
$this->db->query(
|
||||||
|
"INSERT INTO `wp_player_knife` (`steamid`, `knife`, `weapon_team`) VALUES (:steamid, :knife, 2)",
|
||||||
|
["steamid" => $this->steamid, "knife" => $knifeMapping[$defindex]]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->db->query(
|
||||||
|
"INSERT INTO `wp_player_knife` (`steamid`, `knife`, `weapon_team`) VALUES (:steamid, :knife, 3)",
|
||||||
|
["steamid" => $this->steamid, "knife" => $knifeMapping[$defindex]]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set knife skin
|
||||||
|
$this->upsertWeaponSkin($defindex, $paintId, $wear, $seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function handleRegularWeaponSkin($defindex, $paintId, $wear, $seed): void
|
||||||
|
{
|
||||||
|
$this->upsertWeaponSkin($defindex, $paintId, $wear, $seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function upsertWeaponSkin($defindex, $paintId, $wear, $seed): void
|
||||||
|
{
|
||||||
|
$selectedSkins = $this->getSelectedSkins();
|
||||||
|
|
||||||
|
if (array_key_exists($defindex, $selectedSkins)) {
|
||||||
|
// Update existing
|
||||||
|
$this->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",
|
||||||
|
[
|
||||||
|
"weapon_paint_id" => $paintId,
|
||||||
|
"weapon_wear" => $wear,
|
||||||
|
"weapon_seed" => $seed,
|
||||||
|
"steamid" => $this->steamid,
|
||||||
|
"weapon_defindex" => $defindex
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Insert new for both teams
|
||||||
|
$this->db->query(
|
||||||
|
"INSERT INTO wp_player_skins (`steamid`, `weapon_defindex`, `weapon_paint_id`, `weapon_wear`, `weapon_seed`, `weapon_team`) VALUES (:steamid, :weapon_defindex, :weapon_paint_id, :weapon_wear, :weapon_seed, 2)",
|
||||||
|
[
|
||||||
|
"steamid" => $this->steamid,
|
||||||
|
"weapon_defindex" => $defindex,
|
||||||
|
"weapon_paint_id" => $paintId,
|
||||||
|
"weapon_wear" => $wear,
|
||||||
|
"weapon_seed" => $seed
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->db->query(
|
||||||
|
"INSERT INTO wp_player_skins (`steamid`, `weapon_defindex`, `weapon_paint_id`, `weapon_wear`, `weapon_seed`, `weapon_team`) VALUES (:steamid, :weapon_defindex, :weapon_paint_id, :weapon_wear, :weapon_seed, 3)",
|
||||||
|
[
|
||||||
|
"steamid" => $this->steamid,
|
||||||
|
"weapon_defindex" => $defindex,
|
||||||
|
"weapon_paint_id" => $paintId,
|
||||||
|
"weapon_wear" => $wear,
|
||||||
|
"weapon_seed" => $seed
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function clearKnifeData(): void
|
||||||
|
{
|
||||||
|
$knifeDefindexes = UtilsClass::getKnifeDefindexes();
|
||||||
|
|
||||||
|
// Clear knife skins
|
||||||
|
foreach ($knifeDefindexes as $knifeDefindex) {
|
||||||
|
$this->db->query(
|
||||||
|
"DELETE FROM `wp_player_skins` WHERE `steamid` = :steamid AND `weapon_defindex` = :weapon_defindex",
|
||||||
|
["steamid" => $this->steamid, "weapon_defindex" => $knifeDefindex]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear basic knife selection
|
||||||
|
$this->db->query(
|
||||||
|
"DELETE FROM `wp_player_knife` WHERE `steamid` = :steamid",
|
||||||
|
["steamid" => $this->steamid]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateWear($wear)
|
||||||
|
{
|
||||||
|
$wear = floatval($wear);
|
||||||
|
return ($wear >= 0.00 && $wear <= 1.00) ? $wear : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateSeed($seed)
|
||||||
|
{
|
||||||
|
$seed = intval($seed);
|
||||||
|
return ($seed >= 0) ? $seed : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSelectedSkins(): array
|
||||||
|
{
|
||||||
|
$query = $this->db->select(
|
||||||
|
"SELECT `weapon_defindex`, MAX(`weapon_paint_id`) AS `weapon_paint_id`, MAX(`weapon_wear`) AS `weapon_wear`, MAX(`weapon_seed`) AS `weapon_seed`
|
||||||
|
FROM `wp_player_skins`
|
||||||
|
WHERE `steamid` = :steamid
|
||||||
|
GROUP BY `weapon_defindex`, `steamid`",
|
||||||
|
["steamid" => $this->steamid]
|
||||||
|
);
|
||||||
|
|
||||||
|
return UtilsClass::getSelectedSkins($query ?: []);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSelectedKnife(): array
|
||||||
|
{
|
||||||
|
return $this->db->select(
|
||||||
|
"SELECT * FROM `wp_player_knife` WHERE `steamid` = :steamid LIMIT 1",
|
||||||
|
["steamid" => $this->steamid]
|
||||||
|
) ?: [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLoadoutData(): array
|
||||||
|
{
|
||||||
|
$weapons = UtilsClass::getWeaponsFromArray();
|
||||||
|
$knifes = UtilsClass::getKnifeTypes();
|
||||||
|
$selectedSkins = $this->getSelectedSkins();
|
||||||
|
$selectedKnife = $this->getSelectedKnife();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'weapons' => $weapons,
|
||||||
|
'knifes' => $knifes,
|
||||||
|
'selectedSkins' => $selectedSkins,
|
||||||
|
'selectedKnife' => $selectedKnife,
|
||||||
|
'displayKnife' => $this->getDisplayKnife($selectedSkins, $selectedKnife, $knifes)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDisplayKnife($selectedSkins, $selectedKnife, $knifes): array
|
||||||
|
{
|
||||||
|
$skins = UtilsClass::skinsFromJson();
|
||||||
|
|
||||||
|
// Check for knife skin first
|
||||||
|
foreach ($selectedSkins as $defindex => $selectedSkin) {
|
||||||
|
if (UtilsClass::isKnifeDefindex($defindex) && isset($skins[$defindex][$selectedSkin['weapon_paint_id']])) {
|
||||||
|
return [
|
||||||
|
'data' => $skins[$defindex][$selectedSkin['weapon_paint_id']],
|
||||||
|
'source' => 'skin'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for basic knife selection
|
||||||
|
if (!empty($selectedKnife)) {
|
||||||
|
foreach ($knifes as $knife) {
|
||||||
|
if ($selectedKnife[0]['knife'] === $knife['weapon_name']) {
|
||||||
|
return [
|
||||||
|
'data' => $knife,
|
||||||
|
'source' => 'basic'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default knife
|
||||||
|
return [
|
||||||
|
'data' => $knifes[0] ?? null,
|
||||||
|
'source' => 'default'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOrganizedWeapons(): array
|
||||||
|
{
|
||||||
|
$weapons = UtilsClass::getWeaponsFromArray();
|
||||||
|
$knifes = UtilsClass::getKnifeTypes();
|
||||||
|
$categories = UtilsClass::getWeaponCategories();
|
||||||
|
|
||||||
|
$organized = [
|
||||||
|
'Knives' => [],
|
||||||
|
'Gloves' => []
|
||||||
|
];
|
||||||
|
|
||||||
|
// Add weapon categories
|
||||||
|
foreach ($categories as $categoryName => $weaponIds) {
|
||||||
|
$organized[$categoryName] = [];
|
||||||
|
foreach ($weaponIds as $weaponId) {
|
||||||
|
if (isset($weapons[$weaponId])) {
|
||||||
|
$organized[$categoryName][$weaponId] = $weapons[$weaponId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add knives (exclude default)
|
||||||
|
foreach ($knifes as $knifeId => $knife) {
|
||||||
|
if ($knifeId !== 0) {
|
||||||
|
$organized['Knives'][$knifeId] = $knife;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove empty categories
|
||||||
|
return array_filter($organized, function($category) {
|
||||||
|
return !empty($category);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 79 KiB |
BIN
website/img/skins/weapon_knife.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 58 KiB |
BIN
website/img/skins/weapon_knife_kukri.png
Normal file
|
After Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 36 KiB |
BIN
website/img/skins/weapon_taser.png
Normal file
|
After Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 79 KiB |
BIN
website/img/weapon/weapon_knife.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 58 KiB |
BIN
website/img/weapon/weapon_knife_kukri.png
Normal file
|
After Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 74 KiB |