Skip to content

Commit

Permalink
feat(client:carhud): Speed Metrics for KMH and MPH configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
renzuzu committed Jul 26, 2021
1 parent 60ea5db commit 6b8a564
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 49 deletions.
100 changes: 52 additions & 48 deletions renzu_hud/client/function.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function Hud:UpdateStatus(export,vitals)
self.vitals = vitals
if self.notloaded then return end
if export then
self.vitals = exports['renzu_status']:GetStatus(self.statuses)
self.vitals = exports['renzu_status']:GetStatus(self.statuses)
end
self.statusloop = 0
sleep = 11
Expand Down Expand Up @@ -174,6 +174,7 @@ function Hud:EnterVehicleEvent(state,vehicle)
self.hp = GetVehicleEngineHealth(vehicle)
self.gasolina = GetVehicleFuelLevel(vehicle)
self.lastplate = self:GetPlate(vehicle)
SendNUIMessage({type = "SetMetrics", content = config.carui_metric})
if self.uimove and config.enable_carui then
Wait(500)
local content = {
Expand Down Expand Up @@ -479,6 +480,10 @@ function Hud:RpmandSpeedLoop()
while self.ped == nil do
Wait(1000)
end
SendNUIMessage({
type = "SetMetrics",
content = config.carui_metric
})
while self.invehicle do
local sleep = 2000
if self.vehicle ~= nil and self.vehicle ~= 0 then
Expand Down Expand Up @@ -609,57 +614,56 @@ function Hud:NuiCarhpandGas()
end
self:CalculateTimeToDisplay()
self:timeformat()
SendNUIMessage({type = "SetMetrics", content = config.carui_metric})
local sleep = 2000


local door = true
local hood = 0
local trunk = 0
if self.vehicle ~= nil and self.vehicle ~= 0 then
----print(GetVehicleDoorStatus(self.vehicle ))
for i = 0, 6 do
Wait(100)
if GetVehicleDoorAngleRatio(self.vehicle ,i) ~= 0.0 then
door = false
break
local door = true
local hood = 0
local trunk = 0
if self.vehicle ~= nil and self.vehicle ~= 0 then
----print(GetVehicleDoorStatus(self.vehicle ))
for i = 0, 6 do
Wait(100)
if GetVehicleDoorAngleRatio(self.vehicle ,i) ~= 0.0 then
door = false
break
end
end
if door then
doorstatus = 0
else
doorstatus = 2
end
if newdoorstatus ~= doorstatus or newdoorstatus == nil then
newdoorstatus = doorstatus
SendNUIMessage({
type = "setDoor",
content = doorstatus
})
end
if GetVehicleDoorAngleRatio(self.vehicle ,4) ~= 0.0 then
hood = 2
end
end
if door then
doorstatus = 0
else
doorstatus = 2
end
if newdoorstatus ~= doorstatus or newdoorstatus == nil then
newdoorstatus = doorstatus
SendNUIMessage({
type = "setDoor",
content = doorstatus
})
end
if GetVehicleDoorAngleRatio(self.vehicle ,4) ~= 0.0 then
hood = 2
end

if newhood ~= hood or newhood == nil then
newhood = hood
SendNUIMessage({
type = "setHood",
content = hood
})
end
if newhood ~= hood or newhood == nil then
newhood = hood
SendNUIMessage({
type = "setHood",
content = hood
})
end

if GetVehicleDoorAngleRatio(self.vehicle ,5) ~= 0.0 then
trunk = 2
end
if newtrunk ~= trunk or newtrunk == nil then
newtrunk = trunk
SendNUIMessage({
type = "setTrunk",
content = trunk
})
if GetVehicleDoorAngleRatio(self.vehicle ,5) ~= 0.0 then
trunk = 2
end
if newtrunk ~= trunk or newtrunk == nil then
newtrunk = trunk
SendNUIMessage({
type = "setTrunk",
content = trunk
})
end
end
end
--SetVehicleHighGear(self.vehicle ,self.maxgear)
--SetVehicleHighGear(self.vehicle ,self.maxgear)
end
Wait(wait)
end
Expand Down Expand Up @@ -3845,7 +3849,7 @@ function Hud:SyncWheelAndSound(sounds,wheels)
end
for k,v in pairs(self.nearstancer) do
if v.dist > 250 or not DoesEntityExist(v.entity) then
print(v.plate,"deleted")
--print(v.plate,"deleted")
self.nearstancer[k] = nil
end
end
Expand Down
2 changes: 1 addition & 1 deletion renzu_hud/client/manual.lua
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ function Hud:gearspeed(sg, wheel)
else
self.vehicletopspeed = Hud:GetHandling(Hud:GetPlate(self.vehicle)).maxspeed * 1.5
end
else
elseif Hud:GetPlate(self.vehicle) ~= nil then
self.vehicletopspeed = Hud:GetHandling(Hud:GetPlate(self.vehicle)).maxspeed * 1.0
end
end
Expand Down
1 change: 1 addition & 0 deletions renzu_hud/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ config.enablestatus = true -- enable/disable status v1 ( icons,progress status )
config.enablecompass = true -- enable/disable compass
config.enable_carui = true -- enable/disable the car UI (THIS WILL DISABLE ALL VEHICLE FUNCTION AS WELL)
config.carui = 'simple' -- Choose a Carui Version ( simple, minimal, modern )
config.carui_metric = 'mph' -- Speed Metrics to Use 'kmh' or 'mph'
config.available_carui = {
['simple'] = true,
['minimal'] = true,
Expand Down

0 comments on commit 6b8a564

Please sign in to comment.