public function IntefaceWP($id = "All", $server = 0, $team = 0, $skin = null)
    {
        if (!is_numeric($server) || intval($server) != $server || $server < 0 || $this->Settings('type') == 1 && $server >= $this->Db->table_count['Skins']) return ['html' => $this->Translate('_nonono')];
        if (!is_numeric($team) || intval($team) != $team || $team > 2 || $team < 0) return ['html' => $this->Translate('_nonono')];

        $weapons = "";
        $Skins = $this->get_cache($this->skins);

        $selected_skins = array_filter($Skins, function ($s) use ($id, $team, $skin) {
            if ($id !== "All" && $s['type'] !== $id) return false;
            if ($this->Settings('team') == 0 && $s['team'] != $team && $s['team'] != 2) return false;
            if ($skin && strpos(strtolower($s['name']), strtolower($skin)) === false) return false;
            return true;
        });
        
        if (!empty($selected_skins)) {
            $skinsToIterate = $selected_skins;
        } else {
            $skinsToIterate = $Skins;
        } # проверка сортировки на наличие

        if (!empty($skin)) {
            $skinsToIterate = array_filter($Skins, function ($wp) use ($skin) {
                return strpos(strtolower($wp['name']), strtolower($skin)) !== false;
            });
        } # найти скин/оружие/агентов/музыки и т.д. по названию

        if ($this->Settings('type') == 1) {
            $teamwp = empty($team) ? 2 : 3;
            $DBQuery = "SELECT 
                (SELECT `knife` FROM `wp_player_knife` WHERE `steamid` = :player_id AND `weapon_team` = :weapon_team LIMIT 1) AS `knife`,
                (SELECT `weapon_defindex` FROM `wp_player_gloves` WHERE `steamid` = :player_id AND `weapon_team` = :weapon_team LIMIT 1) AS `glove`";
            $result = $this->Db->query('Skins', $server, 0, $DBQuery, [
                'player_id' => $this->DataDBUser(),
                'weapon_team' => $teamwp,
            ]);
        } else if ($this->Settings('type') == 2) {
            $DBQuery = "SELECT `glove`, `knife` FROM `sc_items` WHERE `player_id` = :player_id AND `server_id` = :server_id AND `team` = :team LIMIT 1";
            $result = $this->Db->query('Skins', 0, 0, $DBQuery, [ 
                'player_id' => $this->DataDBUser(),
                'server_id' => $server,
                'team' => $team,
            ]);
        } # шаблон запроса к бд

        foreach ($skinsToIterate as $Skin) {

            $id = $Skin['id'];
            $id_name = $Skin['id_name'];
            $name = $Skin['name'];
    
            $color = "";
            $range = "";
            $stattrack = "";

            $button = "";
            $Sticker_html = "";
            $range_html = "";
            $desc = $this->Translate('_skins_none');
            $img = $Skin['img'];
            $choose_weapon = $this->Translate('_choose_weapon'); # ПЕРЕВОД

            if ($this->Settings('type') == 1) {
                $teamwp = empty($team) ? 2 : 3;
                $skin_active = $this->Db->query('Skins', $server, 0, "SELECT `weapon_paint_id` AS skin, `weapon_wear` AS `range`, `weapon_nametag` AS `tag`, `weapon_stattrak` AS `stattrack`, `weapon_sticker_0`, `weapon_sticker_1`, `weapon_sticker_2`, `weapon_sticker_3`, `weapon_keychain` FROM `wp_player_skins` WHERE `steamid` = :steamid AND `weapon_defindex` = :weapon_defindex AND `weapon_team` = :weapon_team LIMIT 1", [
                    'steamid' => $this->DataDBUser(),
                    'weapon_defindex' => $id,
                    'weapon_team' => $teamwp,
                ]);
                
                $skin = $skin_active['skin'];
                $float = $skin_active['range'];
                switch (true) {
                    case ($Skin['type'] == "Knife" && $result['knife'] == $id_name || $Skin['type'] == "Gloves" && $result['glove'] == $id):
                        $choice = ' choice_active';
                        $choose_weapon = $this->Translate('_choose_default'); # ПЕРЕВОД
                        break;
                    default:
                        $choice = '';
                        break;
                } # проверка выбранных ножей и перчаток
                $stickers_data = [
                    explode(';', $skin_active['weapon_sticker_0'])[0],
                    explode(';', $skin_active['weapon_sticker_1'])[0],
                    explode(';', $skin_active['weapon_sticker_2'])[0],
                    explode(';', $skin_active['weapon_sticker_3'])[0]
                ];
                $keychain_data = explode(';', $skin_active['weapon_keychain']);
            } else if ($this->Settings('type') == 2) {
                $skin_active = $this->Db->query('Skins', 0, 0, "SELECT `skin`, `skin` AS `range`, `stickers`, `stattrack`, `tag`, `keychain` FROM `sc_skins` WHERE `player_id` = :player_id AND `server_id` = :server_id AND `team` = :team AND `weapon_index` = :weapon_index LIMIT 1", [
                    'player_id' => $this->DataDBUser(),
                    'server_id' => $server,
                    'team' => $team,
                    'weapon_index' => $id,
                ]);
                $skin = explode(';', $skin_active['skin'])[0];
                $explode = explode(';', $skin_active['range']);
                $float = $explode[2];
                $stickers_data = explode(';', $skin_active['stickers']);
                $keychain_data = explode(';', $skin_active['keychain']);
                switch (true) {
                    case ($Skin['type'] == "Knife" && $result['knife'] == $id || $Skin['type'] == "Gloves" && $result['glove'] == $id):
                        $choice = ' choice_active';
                        $choose_weapon = $this->Translate('_choose_default'); # ПЕРЕВОД
                        break;
                    default:
                        $choice = '';
                        break;
                } # проверка выбранных ножей и перчаток
            }

            if (!empty($skin_active['tag'])) { 
                $name = "
{$name}
 {$skin_active['tag']}"; 
            }

            if ($skin_active['stattrack'] == 1) { 
                $stattrack = " / StatTrak™"; 
            } 

            $Sticker_html = $this->StickerHtml($stickers_data, $keychain_data);

            if (!empty($skin)) {  
                $color = " " . $Skin['skins'][$skin]['id_rarity'] ?: '';
                $img = $Skin['skins'][$skin]['image'] ?: $img;
                if ($float >= 0.45) {
                    $float_name = 'BS';
                } else if ($float >= 0.3800) {
                    $float_name = 'WW';
                } else if ($float >= 0.1500) {
                    $float_name = 'FT';
                } else if ($float >= 0.0700) {
                    $float_name = 'MW';
                } else if ($float >= 0.0001) {
                    $float_name = 'FN';
                } else {
                    $float_name = 'FN';
                }
                $range = "<div class='info-float-range'>{$float_name} / {$float}{$stattrack}<input name='float-range' class='range-1' type='range' min='0.0001' max='0.9999' step='0.0001' value='{$float}' disabled=''></div>";
                $desc = trim(explode('|', $Skin['skins'][$skin]['name'])[1]) ?: $desc;
            } # изменение скинов если есть

            $range_html = !empty($range) ? $range : (!empty($stattrack) ? "<div class='info-float-range'>StatTrak™</div>" : "");

            $add_id = "";
            if ($Skin['type'] == "Knife" && $id_name != 'weapon_taser') {
                $add_id = "id='SkinChangerAddKnife' id_knife='{$id}'";
            } else if ($Skin['type'] == "Gloves") {
                $add_id = "id='SkinChangerAddGlove' id_glove='{$id}'";
            } else {
                $add_id = "id='set-skin' id_name='{$id_name}'";
            } # выбор перчаток и ножей по нажатию

            $button = ($id_name != 'weapon_knife' && $id_name != 'glove_ct' && $id_name != 'glove_t')
                ? (($Skin['type'] == "Knife" || $Skin['type'] == "Gloves" && $id_name != 'weapon_taser') ? '<b class="button-skin" id="set-skin" id_name="' . $id_name . '">' . $this->Translate('_skins_check') . '</b>'
                : '<b class="button-skin">' . $this->Translate('_skins_check') . '</b>') : '<b class="button-skin">' . $choose_weapon . '</b>';

            $weapons .= <<<HTML
                            <div class="block-skin-fon{$choice}{$color}" {$add_id}>
                                {$range_html}{$Sticker_html}{$button}
                                <div class="block-skin-img">
                                    <img class="loader_img_weapon" src="{$img}" loading="lazy" alt="{$name}">
                                </div>
                                <div class="block-skin-info">
                                    <b>{$name}</b>
                                    <span>{$desc}</span>
                                </div>
                            </div>
                         HTML;
        }
    
        return ['html' => $weapons ?: $this->Translate('_skins_no')];
    }


optimize it so it doesnt make trillong sql requests