Den Vagen
Новичок
Всех приветствую, как можно с помощью CEF вывести ник игрока на экран?
Вот я пробовал и не получилось, вот мой код:
HTML/CSS/JS
Подключение сайта в CEF + вызывание самого сайта в OnPlayerSpawn
Сток AddWelcome
Вот я пробовал и не получилось, вот мой код:
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>
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);
PHP:
stock AddWelcome(playerid, head[])
{
cef_emit_event(playerid, "data:welcome", CEFSTR(head));
return 1;
}
