3 |
4 | - Compass Soft Car Hud **For FiveM**
5 |
6 | - Hello, this is our first script we shared. **We can say that it is a bit lacking in terms of optimization because we wanted to publish our script as soon as possible. We will of course make updates.**
7 |
8 | - 👨💻 **Discord Invite Link** [https://discord.gg/zxAMWdFntP](https://discord.gg/zxAMWdFntP)
9 |
10 | - **Features**
11 | - + 0.02 Client Side Resmon and No Server Side
12 | - + Standalone
13 | - + Seat Belt
14 | - + RPM Indicator
15 | - + Gear Indicator
16 | - + Speedometer
17 | - + Headlight Indicator
18 | - + Handbrake + Engine Health Indicator
19 | - + You can edit colors from Javascript and CSS files.
20 | - + Compatible with every screen resolution, if you send the problematic screen resolution or fix it yourself and send me a message, we can share it as an update.**
21 |
22 | - **Installation**
23 | - +Add the cs-carHud folder to your FiveM resources directory and server.cfg add "ensure cs-carHud"
24 |
25 |
Contact Me:
26 |
27 |
28 |
29 |
30 |
Languages and Tools:
31 |
32 |
33 |
34 | **WITH TURBO INDICATOR VERSION**
35 | https://github.com/justmaiklas/cs-carhud/tree/feature/turbo-indicator
36 |
37 |
38 |
--------------------------------------------------------------------------------
/client.lua:
--------------------------------------------------------------------------------
1 | local seatbeltToggle = false
2 | local antiSpam = false
3 |
4 | local function convertToPercentage(value)
5 | return math.ceil(value * 10000 - 2001) / 80
6 | end
7 |
8 | local function Normalize(value, min, max)
9 | return (value - min) / (max - min)
10 | end
11 |
12 | local function GetVehicleTurboPressureNormalized(vehicle)
13 | local hasTurbo = IsToggleModOn(vehicle,18)
14 | if not hasTurbo then return false end
15 | local normalizedTurboPressure = Normalize(GetVehicleTurboPressure(vehicle), -1, 1)
16 | return convertToPercentage(normalizedTurboPressure)
17 | end
18 |
19 | Citizen.CreateThread(function()
20 | while true do
21 | Citizen.Wait(70)
22 | local ply = PlayerPedId()
23 | if IsPauseMenuActive() then
24 | SendNUIMessage({
25 | process = 'hide';
26 | })
27 | elseif IsPedInAnyVehicle(ply) then
28 | local veh = GetVehiclePedIsUsing(ply)
29 | local fuel = GetVehicleFuelLevel(veh)
30 | local gear = GetVehicleCurrentGear(veh)
31 | local speedo = (GetEntitySpeed(veh)*3.6) --mph *2.236936
32 | local rpm = GetVehicleCurrentRpm(veh)
33 | local rpmMat = convertToPercentage(rpm)
34 | local turboPressure = GetVehicleTurboPressureNormalized(veh)
35 | local engineHp = GetVehicleEngineHealth(veh)
36 | local handbrake = GetVehicleHandbrake(veh)
37 | local _, lightsOne, lightsTwo = GetVehicleLightsState(veh)
38 | local lightsState
39 | local indicatorsState = GetVehicleIndicatorLights(veh)
40 | if indicatorsState == 0 then
41 | indicatorsState = 'off'
42 | elseif indicatorsState == 1 then
43 | indicatorsState = 'left'
44 | elseif indicatorsState == 2 then
45 | indicatorsState = 'right'
46 | elseif indicatorsState == 3 then
47 | indicatorsState = 'both'
48 | end
49 | if (lightsOne == 1 and lightsTwo == 0) then
50 | lightsState = 1;
51 | elseif (lightsOne == 1 and lightsTwo == 1) or (lightsOne == 0 and lightsTwo == 1) then
52 | lightsState = 2;
53 | else
54 | lightsState = 0;
55 | end
56 |
57 | SendNUIMessage({
58 | process = 'show';
59 | fuelLevel = fuel;
60 | gearLevel = gear;
61 | speedLevel = speedo;
62 | rpmLevel = rpmMat;
63 | engineLevel = engineHp;
64 | handbrakeLevel = handbrake;
65 | seatbeltLevel = seatbeltToggle;
66 | lightsLevel = lightsState;
67 | indicatorsState = indicatorsState;
68 | turboPressureLevel = turboPressure;
69 | })
70 | else
71 | SendNUIMessage({
72 | process = 'hide';
73 | })
74 | end
75 | end
76 | end)
77 |
78 |
79 | RegisterKeyMapping('leftIndicator', 'Vehicle left indicator', 'keyboard', 'LEFT')
80 | RegisterKeyMapping('rightIndicator', 'Vehicle right indicator', 'keyboard', 'RIGHT')
81 | RegisterKeyMapping('bothIndicators', 'Vehicle both indicators', 'keyboard', 'UP')
82 |
83 | RegisterCommand('leftIndicator', function()
84 | if not IsPedInAnyVehicle(PlayerPedId()) then return end
85 | TriggerServerEvent('cs-carhud:syncIndicators', VehToNet(GetVehiclePedIsUsing(PlayerPedId())), 1)
86 | end)
87 |
88 | RegisterCommand('rightIndicator', function()
89 | if not IsPedInAnyVehicle(PlayerPedId()) then return end
90 | TriggerServerEvent('cs-carhud:syncIndicators', VehToNet(GetVehiclePedIsUsing(PlayerPedId())), 2)
91 | end)
92 |
93 | RegisterCommand('bothIndicators', function()
94 | if not IsPedInAnyVehicle(PlayerPedId()) then return end
95 | TriggerServerEvent('cs-carhud:syncIndicators', VehToNet(GetVehiclePedIsUsing(PlayerPedId())), 3)
96 | end)
97 |
98 | RegisterNetEvent("cs-carhud:syncIndicators", function(vehNetId, indicatorState)
99 | if not NetworkDoesEntityExistWithNetworkId(vehNetId) then return end
100 | local vehicle = NetToVeh(vehNetId)
101 | SetVehicleIndicators(vehicle, indicatorState)
102 | end)
103 |
104 | function SetVehicleIndicators(vehicle, indicator)
105 | local currentIndicator = GetVehicleIndicatorLights(vehicle)
106 | if currentIndicator == indicator then
107 | SetVehicleIndicatorLights(vehicle, 0, false)
108 | SetVehicleIndicatorLights(vehicle, 1, false)
109 | return
110 | end
111 | if vehicle and vehicle ~= 0 and vehicle ~= nil then
112 | local class = GetVehicleClass(vehicle)
113 | if class ~= 15 and class ~= 16 and class ~= 14 then
114 | if indicator == 1 then
115 | SetVehicleIndicatorLights(vehicle, 0, false)
116 | SetVehicleIndicatorLights(vehicle, 1, true)
117 | elseif indicator == 2 then
118 | SetVehicleIndicatorLights(vehicle, 0, true)
119 | SetVehicleIndicatorLights(vehicle, 1, false)
120 | elseif indicator == 3 then
121 | SetVehicleIndicatorLights(vehicle, 0, true)
122 | SetVehicleIndicatorLights(vehicle, 1, true)
123 | end
124 | end
125 | end
126 | end
127 |
128 | RegisterKeyMapping('seatbelt', 'Seat Belt', 'keyboard', 'K')
129 |
130 | RegisterCommand('seatbelt', function()
131 | local ply = PlayerPedId()
132 | local veh = GetVehiclePedIsIn(player, false)
133 | local vehicleCategories = GetVehicleClass(veh)
134 | if IsPedInAnyVehicle(ply) then
135 | if antiSpam == false then
136 | if vehicleCategories ~= 13 and vehicleCategories ~= 8 then
137 | seatbeltToggle = not seatbeltToggle
138 | if seatbeltToggle == true then
139 | antiSpam = true
140 | Wait(2000)
141 | antiSpam = false
142 | SetFlyThroughWindscreenParams(10000.0, 10000.0, 17.0, 500.0);
143 | while seatbeltToggle do
144 | DisableControlAction(0,75)
145 | Citizen.Wait(5)
146 | end
147 | else
148 | SetFlyThroughWindscreenParams(16.0, 19.0, 17.0, 2000.0)
149 | SetPedConfigFlag(PlayerPedId(), 32, true)
150 | seatbeltToggle = false
151 | antiSpam = true
152 | Wait(2000)
153 | antiSpam = false
154 | end
155 | end
156 | end
157 | end
158 | end, false)
159 |
--------------------------------------------------------------------------------
/fxmanifest.lua:
--------------------------------------------------------------------------------
1 | fx_version 'adamant'
2 |
3 | game 'gta5'
4 |
5 | description 'compass script'
6 |
7 | version '1.0.0'
8 |
9 | client_script {
10 | 'client.lua'
11 | }
12 |
13 | server_script {
14 | 'server.lua'
15 | }
16 |
17 | ui_page {
18 | 'html/index.html'
19 | }
20 |
21 | files {
22 | 'html/index.html',
23 | 'html/style.css',
24 | 'html/script.js',
25 | }
26 |
--------------------------------------------------------------------------------
/html/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Document
12 |
13 |
14 |