-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol_ui.js
More file actions
67 lines (62 loc) · 1.84 KB
/
Copy pathcontrol_ui.js
File metadata and controls
67 lines (62 loc) · 1.84 KB
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
// potential feature to see the spectated player's controls
// only controls relevant for driving used as this is intended for use on BUSTED
console.log('init control_ui')
setTick(liveControlsTickFunc)
let lastLiveData = {
isKeyboard: true,
playername: undefined,
steering: 127,
accelerate: 0,
brake: 0,
}
function liveControlsTickFunc() {
let isKeyboard = IsInputDisabled(2)
let playername = GetPlayerName(PlayerPedId())
let acceleration = GetControlValue(0, 71) - 127
let braking = GetControlValue(0, 72) - 127
let steering = GetControlValue(0, 30)
let pushData = []
if (lastLiveData.isKeyboard != isKeyboard) {
pushData.push({ isKeyboard })
lastLiveData.isKeyboard = isKeyboard
}
if (lastLiveData.playername != playername) {
pushData.push({ playername })
lastLiveData.playername = playername
}
if (lastLiveData.acceleration != acceleration) {
pushData.push({ acceleration })
lastLiveData.acceleration = acceleration
}
if (lastLiveData.braking != braking) {
pushData.push({ braking })
lastLiveData.braking = braking
}
if (lastLiveData.steering != steering) {
pushData.push({ steering })
lastLiveData.steering = steering
}
if (pushData.length > 0) {
//console.log('New Data ' + JSON.stringify(Object.assign({}, ...pushData)))
SendNuiMessage(
JSON.stringify({
type: 'data',
data: Object.assign({}, ...pushData),
})
)
}
SetTextFont(0)
SetTextProportional(1)
SetTextScale(0.0, 0.3)
SetTextColour(128, 128, 128, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry('STRING')
AddTextComponentString(
(isKeyboard ? 'Keyboard' : 'Gamepad') + ' User: ' + playername
)
DrawText(0.005, 0.35)
Wait(500)
}