-
Notifications
You must be signed in to change notification settings - Fork 1
/
hud.html
executable file
·145 lines (145 loc) · 3.68 KB
/
hud.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE HTML>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content="IE=edge">
<meta name='viewport' content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover">
<style type="text/css">
@font-face {
font-family: 'Oswald-Regular';
src: url('resources/Oswald-Regular.ttf');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Oswald-Light';
src: url('resources/Oswald-Light.ttf');
font-weight: normal;
font-style: normal;
}
.driftpoint {
position: fixed;
bottom: 64px;
text-align: center;
width: 100%;
display: none;
}
.driftzone {
background: rgba(0,0,0,0.2);
color: #FFF;
height: 75px;
display: inline-block;
border-radius: 6px;
overflow: hidden;
}
.driftzone img {
width: 75px;
border-radius: 6px 0px 0px 6px;
margin-right: 12px;
vertical-align: middle;
}
.point {
font-size: 26px;
position: relative;
top: 8px;
font-family: 'Oswald-Regular',-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,'微软雅黑',sans-serif;
margin-right: 12px;
min-width: 128px;
display: inline-block;
}
.driftname {
color: #FFF;
text-shadow: 0px 0px 2px #000;
display: block;
font-size: 18px;
margin-bottom: 8px;
font-family: 'Oswald-Regular',-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,'微软雅黑',sans-serif;
}
</style>
</head>
<body>
<div class="driftpoint">
<span class="driftname">DRIFT POINT</span>
<div class="driftzone">
<div class="blurbg"></div>
<img src="resources/driftzone.png" />
<span class="point">0</span>
</div>
</div>
</body>
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
<script>
var sid;
var ws;
var connected = false;
var inited = false;
var name = "";
var point = 0;
var health = 0;
$(function() {
function websocket () {
// Change the hk416.org to your drift point server hostname
ws = new WebSocket("wss://hk416.org/dpoint.socket/");
ws.onopen = function(event){
console.log('Connect successful');
connected = true;
};
ws.onmessage = function (event) {
// console.log(event.data);
}
ws.onclose = function(event) {
connected = false;
console.log("Connect close, status: " + this.readyState);
websocket();
};
ws.onerror = function(event) {
connected = false;
console.log("WebSocket error.");
};
}
websocket();
window.addEventListener("message", function(event) {
var data = event.data;
switch(data.msgtype) {
case "setid":
sid = data.data;
break;
case "setname":
name = data.data;
break;
case "hudstatus":
if(data.data) {
$(".driftpoint").fadeIn();
} else {
$(".driftpoint").fadeOut();
}
break;
case "point":
$(".driftpoint").fadeIn();
$(".point").html(Math.floor(data.data).toLocaleString());
point = Math.floor(data.data);
health = data.health;
break;
}
});
setInterval(function() {
if(!inited && connected) {
ws.send(JSON.stringify({
'action': 'connect',
'sid': sid
}));
inited = true;
}
if(connected) {
ws.send(JSON.stringify({
'action': 'point',
'sid': sid,
'name': name,
'point': point,
'health': health
}));
}
}, 500);
});
</script>
</html>