Помощь Вывод skill в профиль игрока

travka zelenaj

Супер активный
Участник
10.04.2022
143
60
Всех приветствую,нужна подсказка вывода skill в профиль игрока.
вроде как прописываю в tpl/home/profile.tpl
тык:
                                {if('{steam_id}' == '---' || '{steam_id}' == '')}
                                <tr class="newsblock">
                                    <td>Скилл с паблика</td>
                                    <td>Steam ID не указан. <a href="../settings">Указать<a></td>
                                </tr>
                                {else}
                                <tr class="newsblock">
                                    <td>Скилл с паблика</td>
                                    <td><span class="label label-{skill_color}">{skill_name} ({skill})</span></td>
                                </tr>
                                {/if}
но получаю.
Есть у кого какие идеи?
если что,стата скальпеля
 

Вложения

  • Скриншот 26.01.25_10.21.25.png
    Скриншот 26.01.25_10.21.25.png
    59 KB · Просмотры: 30

degrando

tg/lazydsgn
Скриптер
03.12.2023
43
80
Всех приветствую,нужна подсказка вывода skill в профиль игрока.
вроде как прописываю в tpl/home/profile.tpl
тык:
                                {if('{steam_id}' == '---' || '{steam_id}' == '')}
                                <tr class="newsblock">
                                    <td>Скилл с паблика</td>
                                    <td>Steam ID не указан. <a href="../settings">Указать<a></td>
                                </tr>
                                {else}
                                <tr class="newsblock">
                                    <td>Скилл с паблика</td>
                                    <td><span class="label label-{skill_color}">{skill_name} ({skill})</span></td>
                                </tr>
                                {/if}
но получаю.
Есть у кого какие идеи?
если что,стата скальпеля
переменные просто так не передаются в во все шаблоны сайта, нужно в modules_extra/profile/index.php прописать скилл
 

travka zelenaj

Супер активный
Участник
10.04.2022
143
60
@degrando,
приветствую, я думаю в "modules/profile/index.php" прописать скилл)
в общем прописал в modules /profile/index.php

тык:
$tpl->set("{time_stats}", implode('', $time_stats));
$tpl->set("{skill_name}", $skill_name);
$tpl->set("{skill_color}", $skill_color);
$tpl->set("{skill}", $skill);

почти в самый конец
и вот
 

Вложения

  • Скриншот 26.01.25_12.12.32.png
    Скриншот 26.01.25_12.12.32.png
    62 KB · Просмотры: 25

Tako

takocode.ru
Участник
15.01.2023
107
202
takocode.ru
Откуда у тебя будет брать значение $time_stats $skill_name $skill_color?
Вот пример:

modules\admin\stat.php:
if(file_exists("logs/stat.log")) {
    $file = file("logs/stat.log");
    $col = sizeof($file);
    if ($col > sizeof($file)) {
        $col = sizeof($file);
    }
    $data = '';
    for ($i = sizeof($file) - 1; $i + 1 > sizeof($file) - $col; $i--) {
        $string = explode("|",$file[$i]);

        for ($j = 0; $j < count($string); $j++) {
            if(empty($string[$j])) {
                $string[$j] = '';
            }
        }

        $data .= "
        <tr>
            <td>".$i."</td>
            <td>".$string[0]."</td>
            <td>".$string[1]."</td>
            <td>".$string[2]."</td>
            <td>".$string[3]."</td>
        </tr>
        ";
    }
} else {
    $data = '';
}

$tpl->load_template('stat.tpl');
$act = 0; $act2 = 0;
if(configs()->stat == 1){
    $act = 'active';
} elseif (configs()->stat == 2) {
    $act2 = 'active';
}
$tpl->set("{act_st}", $act);
$tpl->set("{act2_st}", $act2);
$tpl->set("{stat_number}", configs()->stat_number);
$tpl->set("{data}", $data);
$tpl->compile( 'content' );
$tpl->clear();
 

Tako

takocode.ru
Участник
15.01.2023
107
202
takocode.ru
Откуда у тебя будет брать значение $time_stats $skill_name $skill_color?
Вот пример:

modules\admin\stat.php:
if(file_exists("logs/stat.log")) {
    $file = file("logs/stat.log");
    $col = sizeof($file);
    if ($col > sizeof($file)) {
        $col = sizeof($file);
    }
    $data = '';
    for ($i = sizeof($file) - 1; $i + 1 > sizeof($file) - $col; $i--) {
        $string = explode("|",$file[$i]);

        for ($j = 0; $j < count($string); $j++) {
            if(empty($string[$j])) {
                $string[$j] = '';
            }
        }

        $data .= "
        <tr>
            <td>".$i."</td>
            <td>".$string[0]."</td>
            <td>".$string[1]."</td>
            <td>".$string[2]."</td>
            <td>".$string[3]."</td>
        </tr>
        ";
    }
} else {
    $data = '';
}

$tpl->load_template('stat.tpl');
$act = 0; $act2 = 0;
if(configs()->stat == 1){
    $act = 'active';
} elseif (configs()->stat == 2) {
    $act2 = 'active';
}
$tpl->set("{act_st}", $act);
$tpl->set("{act2_st}", $act2);
$tpl->set("{stat_number}", configs()->stat_number);
$tpl->set("{data}", $data);
$tpl->compile( 'content' );
$tpl->clear();
А вообще, я даже не прав. Основной код находиться в inc/classes/class.getdata.php.
Скажи какую систему уровней ты используешь. Накину код
 

travka zelenaj

Супер активный
Участник
10.04.2022
143
60
А вообще, я даже не прав. Основной код находиться в inc/classes/class.getdata.php.
Скажи какую систему уровней ты используешь. Накину код
Верно, в class.getdata.php и взял

Но не хочет работать.
 

Tako

takocode.ru
Участник
15.01.2023
107
202
takocode.ru
В /modules/profile/index.php

После:
PHP:
if(isset($row->id) && ($row->accept == 0)) {
    if($row->id_sender == $_SESSION['id']) {
        $issetFriendRequestFromMe = 'true';
    }
    if($row->id_taker == $_SESSION['id']) {
        $issetFriendRequestFromHim = 'true';
    }
}

Замени все строчки снизу на:
PHP:
if($profile->steam_id == '0') {
    $timer = '<a href="../settings"><span style="color: #A52A2A;font-weight: bold;text-decoration:underline;">Steam ID не привязан</span></a>';
    $last_j = '<a href="../settings"><span style="color: #A52A2A;font-weight: bold;text-decoration:underline;">Steam ID не привязан</span></a>';
}
else{
    $STH = $pdo->query("SELECT id,st_db_host,st_db_user,st_db_pass,st_db_db,st_type,st_db_table,ip,port FROM servers WHERE st_type!=0 and id=1 LIMIT 1");
    $STH->setFetchMode(PDO::FETCH_OBJ);
    $row1 = $STH->fetch();
    $db_host = $row1->st_db_host;
    $db_user = $row1->st_db_user;
    $db_pass = $row1->st_db_pass;
    $db_db = $row1->st_db_db;
    $table = $row1->st_db_table;
    $error = "";
    if(!$pdo2 = db_connect($db_host, $db_db, $db_user, $db_pass)) {
        $error = $messages['Unable_connect_to_db'];
    }

    if($error == ""){
        $STH1 = $pdo2->query("SELECT s.id, s.skill, cs.value, cs.command FROM $table AS s JOIN csstats_settings AS cs ON cs.command = 'statsx_skill' WHERE s.steamid = '$profile->steam_id'");
        $STH1->setFetchMode(PDO::FETCH_OBJ);
    }

    $row = $STH1->fetch();
    if ($row->id != 0) {
        if (isset($row->command)) {
            $skills = explode(' ', $row->value);
        } else {
            $skills = [0, 60, 75, 85, 100, 115, 130, 140, 150, 165, 180, 195, 210];
        }
       $skills_names = ['L-', 'L', 'L+', 'M-', 'M', 'M+', 'H-', 'H', 'H+', 'P-', 'P', 'P+', 'G'];
       $skills_colors = [
           'default',
           'default',
           'default',
           'success',
           'success',
           'success',
           'primary',
           'primary',
           'primary',
           'warning',
           'warning',
           'warning',
           'danger',
       ];
       $skill = $row->skill;
    }
    else {
        $timer = '<a href="../settings"><span style="color: #A52A2A;font-weight: bold;text-decoration:underline;">Игрок ещё не был на сервере</span></a>';
        $last_j = '<a href="../settings"><span style="color: #A52A2A;font-weight: bold;text-decoration:underline;">Игрок ещё не был на сервере</span></a>';
    }
}

$editor_settings = get_editor_settings();
$tpl->load_template('/home/profile.tpl');
$tpl->set("{file_manager}", $editor_settings['file_manager']);
$tpl->set("{file_manager_theme}", $editor_settings['file_manager_theme']);
$tpl->set("{last_activity}", $last_activity);
$tpl->set("{template}", get_template());
$tpl->set("{profile_id}", $profile->id);
$tpl->set("{login}", $profile->login);
$tpl->set("{avatar}", $profile->avatar);
$tpl->set("{group}", $users_groups[$profile->rights]['name']);
$tpl->set("{group_color}", $users_groups[$profile->rights]['color']);
$tpl->set("{regdate}", expand_date($profile->regdate, 1));
$tpl->set("{name}", $profile->name);
$tpl->set("{answers}", $profile->answers);
$tpl->set("{thanks}", $profile->thanks);
$tpl->set("{telegram}", $profile->telegram);
$tpl->set("{nick}", $profile->nick);
$tpl->set("{skype}", $profile->skype);
$tpl->set("{discord}", $profile->discord);
$tpl->set("{reit}", $profile->reit);
$tpl->set("{topic_id}", $profile->last_topic);
$tpl->set("{topic_name}", $topic_name);
$tpl->set("{checker}", $checker);
$tpl->set("{vk}", $profile->vk);
$tpl->set("{vk_api}", $profile->vk_api);
$tpl->set("{fb}", $profile->fb);
$tpl->set("{fb_api}", $profile->fb_api);
$tpl->set("{steam_api}", $profile->steam_api);
$tpl->set("{steam_id}", $profile->steam_id);
$tpl->set("{birth}", expand_date($profile->birth, 2));
$tpl->set("{dell}", $profile->dell);
$tpl->set("{friends}", $tpl->result['friends'], false);
$tpl->set("{isFriend}", $isFriend);
$tpl->set("{issetFriendRequestFromMe}", $issetFriendRequestFromMe);
$tpl->set("{issetFriendRequestFromHim}", $issetFriendRequestFromHim);
$tpl->set("{shilings}", $profile->shilings);
$tpl->set("{proc}", $profile->proc);

$j = 0;
do {
    $skill_name = $skills_names[$j];
    $skill_color = $skills_colors[$j];
    ++$j;
} while (isset($skills[$j]) && ($skill >= $skills[$j]) && isset($skills_names[$j], $skills_colors[$j]));

$this->tpl->set('{skill_name}', $skill_name);
$this->tpl->set('{skill_color}', $skill_color);
$this->tpl->set('{skill}', $skill);

$tpl->compile('content');
$tpl->clear();

Если всё будет работать отпишись
 

Tako

takocode.ru
Участник
15.01.2023
107
202
takocode.ru
Постараюсь сегодня после работы скинуть или завтра утром-днем
PHP:
if($profile->steam_id == '0') {
    $timer = '<a href="../settings"><span style="color: #A52A2A;font-weight: bold;text-decoration:underline;">Steam ID не привязан</span></a>';
    $last_j = '<a href="../settings"><span style="color: #A52A2A;font-weight: bold;text-decoration:underline;">Steam ID не привязан</span></a>';
}
else{
    $STH = $pdo->query("SELECT id,st_db_host,st_db_user,st_db_pass,st_db_db,st_type,st_db_table,ip,port FROM servers WHERE st_type!=0 and id=1 LIMIT 1");
    $STH->setFetchMode(PDO::FETCH_OBJ);
    $row1 = $STH->fetch();
    $db_host = $row1->st_db_host;
    $db_user = $row1->st_db_user;
    $db_pass = $row1->st_db_pass;
    $db_db = $row1->st_db_db;
    $table = $row1->st_db_table;
    $error = "";
    if(!$pdo2 = db_connect($db_host, $db_db, $db_user, $db_pass)) {
        $error = $messages['Unable_connect_to_db'];
    }

    if($error == ""){
        $STH1 = $pdo2->query("SELECT s.id, s.skill, cs.value, cs.command FROM $table AS s JOIN csstats_settings AS cs ON cs.command = 'statsx_skill' WHERE s.steamid = '$profile->steam_id'");
        $STH1->setFetchMode(PDO::FETCH_OBJ);
    }

    $row = $STH1->fetch();
    if ($row->id != 0) {
        if (isset($row->command)) {
            $skills = explode(' ', $row->value);
        } else {
            $skills = [0, 60, 75, 85, 100, 115, 130, 140, 150, 165, 180, 195, 210];
        }
       $skills_names = ['L-', 'L', 'L+', 'M-', 'M', 'M+', 'H-', 'H', 'H+', 'P-', 'P', 'P+', 'G'];
       $skills_colors = [
           'default',
           'default',
           'default',
           'success',
           'success',
           'success',
           'primary',
           'primary',
           'primary',
           'warning',
           'warning',
           'warning',
           'danger',
       ];
       $skill = $row->skill;
    }
    else {
        $skill = '<a href="../settings"><span style="color: #A52A2A;font-weight: bold;text-decoration:underline;">Игрок ещё не был на сервере</span></a>';
       }
}

$editor_settings = get_editor_settings();
$tpl->load_template('/home/profile.tpl');
$tpl->set("{file_manager}", $editor_settings['file_manager']);
$tpl->set("{file_manager_theme}", $editor_settings['file_manager_theme']);
$tpl->set("{last_activity}", $last_activity);
$tpl->set("{template}", get_template());
$tpl->set("{profile_id}", $profile->id);
$tpl->set("{login}", $profile->login);
$tpl->set("{avatar}", $profile->avatar);
$tpl->set("{group}", $users_groups[$profile->rights]['name']);
$tpl->set("{group_color}", $users_groups[$profile->rights]['color']);
$tpl->set("{regdate}", expand_date($profile->regdate, 1));
$tpl->set("{name}", $profile->name);
$tpl->set("{answers}", $profile->answers);
$tpl->set("{thanks}", $profile->thanks);
$tpl->set("{telegram}", $profile->telegram);
$tpl->set("{nick}", $profile->nick);
$tpl->set("{skype}", $profile->skype);
$tpl->set("{discord}", $profile->discord);
$tpl->set("{reit}", $profile->reit);
$tpl->set("{topic_id}", $profile->last_topic);
$tpl->set("{topic_name}", $topic_name);
$tpl->set("{checker}", $checker);
$tpl->set("{vk}", $profile->vk);
$tpl->set("{vk_api}", $profile->vk_api);
$tpl->set("{fb}", $profile->fb);
$tpl->set("{fb_api}", $profile->fb_api);
$tpl->set("{steam_api}", $profile->steam_api);
$tpl->set("{steam_id}", $profile->steam_id);
$tpl->set("{birth}", expand_date($profile->birth, 2));
$tpl->set("{dell}", $profile->dell);
$tpl->set("{friends}", $tpl->result['friends'], false);
$tpl->set("{isFriend}", $isFriend);
$tpl->set("{issetFriendRequestFromMe}", $issetFriendRequestFromMe);
$tpl->set("{issetFriendRequestFromHim}", $issetFriendRequestFromHim);
$tpl->set("{shilings}", $profile->shilings);
$tpl->set("{proc}", $profile->proc);

$j = 0;
do {
    $skill_name = $skills_names[$j];
    $skill_color = $skills_colors[$j];
    ++$j;
} while (isset($skills[$j]) && ($skill >= $skills[$j]) && isset($skills_names[$j], $skills_colors[$j]));

$this->tpl->set('{skill_name}', $skill_name);
$this->tpl->set('{skill_color}', $skill_color);
$this->tpl->set('{skill}', $skill);

$tpl->compile('content');
$tpl->clear();
Попробуйте ещё этот код. Если не поможет, то отправьте ошибки и посмотрю
 
Сверху Снизу