• Уважаемый Гость.
    - Прежде чем создать свою тему, пожалуйста, попробуй воспользоваться этим -> ПОИСКОМ !!!
    - После решения Вашего вопроса (проблемы) - нажмите "Лучший ответ", на сообщении, которое его решило. За игнорирование этого действия - Вы получите соответствующее предупреждение. Мы - стараемся Вам помочь. Уделите 10 секунд - чтобы нажать кнопку. (Если у Вас нет такой возможности - укажите в последнем своем сообщении какой ответ Вы считаете лучшим. Наши модераторы сделают это за Вас)
    ЗАПРЕЩЕНО:
    - Cоздавать темы с названиями "Помогите", "Плиз", "Ошибка", "Не могу найти", "Хелп" и тому подобное;
    - Cоздавать темы без детального описания того, что нужно исправить.
    - Cоздавать темы из одного скриншота.
    За игнор правил форума - Ваша тема будет удалена, а Вы получите системное предупреждение.

Как отобразить ник в CEF

Den Vagen

Новичок
Всех приветствую, как можно с помощью CEF вывести ник игрока на экран?
Вот я пробовал и не получилось, вот мой код:


HTML/CSS/JS
HTML:
<!DOCTYPE html>
<head>
    <style>
        body
        {
            background: transparent;
            overflow: hidden;
        }
        .background
        {
            background: linear-gradient(94.79deg, rgba(72, 91, 99, 0.8) 12.79%, rgba(41, 56, 60, 0.8) 112.24%);
            border-radius: 4px;
            /*left:200px;*/
            margin: auto;
            top:300px;
            position: relative;
            width: 220px;
            height: 45px;
            animation: fade2 1s 5s forwards;
            margin-top: -125px;
            box-shadow: 0 0 10px rgba(59, 75, 82, 0.411);
            display: block;
        }
        .background-num
        {
            background: linear-gradient(94.79deg, rgb(0, 173, 247) 12.79%, rgba(0, 132, 255, 0.945) 112.24%);
            border-radius: 4px;
            left:12px;
            top:1000px;
            position: relative;
            width: 55px;
            height: 60px;
            animation: fade2 1s 5s forwards;
            margin-top: -125px;
            /*box-shadow: 0 0 10px rgba(59, 75, 82, 0.411);*/
            position: absolute;
        }
        .text-head
        {
            color: white;
            font-family:  TT Norms;
            font-size: 18px;
            text-align: center;
            left:65px;
            top:0px;
            position: relative;
            animation: fade2 1s 5s forwards;
            font-weight: bold;
            font-family:'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
        }
        .text-second
        {
            color: rgb(218, 218, 218);
            font-family:  TT Norms;
            font-size: 15px;
            text-align: center;
            left:0px;
            top:19px;
            position: relative;   
            animation: fade2 1s 5s forwards;
            font-family:'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
            font-weight: bold;
        }
        .icon
        {
            top: 7px;
            left:10px;
            position: relative;
        }
        .icon img
        {
            width: 30px;
            height: 30px;
        }
        h1
        {
            color: white;
            font-weight: bold;
            text-align: center;
            font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
            margin-top: 3px;
        }
        .sname
        {
            font-weight: bold;
            font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
            color: white;
            text-align: center;
            margin-top: -29px;
            margin-right: 2px;
        }
        @keyframes fade1 {
        0% {
            opacity: 1;
        }
        99% {
            opacity: 0;
            height: 200px;
            width: 200px;
        }
        100% {
            opacity: 0;
            height: 0;
            width: 0;
        }
        }

        @keyframes fade2 {
        0% {
            opacity: 1;
            visibility: visible;
        }
        99% {
            opacity: 0;
            visibility: hidden;
            position: relative;
        }
        100% {
            opacity: 0;
            position: fixed;
        }
        }




    </style>
</head>
<body>
    <div id="append" class="main">
        <div class="background">
            <!--<div class="icon">
                <img src="logo.png">
            </div>
            <a id="head" class="text-head">
                Den_Mitter
            </a>-->
            <p id="second" class="text-second">Добро пожаловать на сервер</p>
        </div>
    </div>

<script>
    cef.on("data:welcome", (head) => {
        addwelcom(heads, seconds);
    });


    function addwelcom(head) {
           let div =  document.createElement('div');
           div.className = "background";

           let icon = document.createElement('div');
           icon.className = "icon";
           div.append(icon);

           let img = document.createElement('img');
           img.src = "error.png";
           icon.append(img);


           let a1 = document.createElement('a');

           a1.className = "text-head";
           a1.innerHTML = head;
           div.append(a1);

           let p2 = document.createElement('p');

           p2.className = "text-second";
           p2.innerHTML = seconds;
           div.append(p2);

           let app = document.getElementById('append');

           app.append(div);
    }
</script>
</body>
Подключение сайта в CEF + вызывание самого сайта в OnPlayerSpawn

PHP:
    cef_create_browser(playerid, BROWSER_WELCOME, "http://ws26174.freecastle.site/welcome.html", false, false);
    new str[256];
    format(str, sizeof(str), "%s", player_name[playerid]);
    AddWelcome(playerid, str);
Сток AddWelcome
PHP:
stock AddWelcome(playerid, head[])
{
    cef_emit_event(playerid, "data:welcome", CEFSTR(head));
    return 1;
}
 
Сверху Снизу