Skip to content

Commit

Permalink
chore: using core exports (#15)
Browse files Browse the repository at this point in the history
* chore: using core exports

* fix: lint errors
  • Loading branch information
Manason authored Sep 28, 2023
1 parent 2bf0890 commit 496c78a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Before creating enhancement suggestions, please check [this list](#before-submit

* **Make sure it doesn't already exist.** Sounds silly, but there's a lot of features built in to Qbox that people don't realize so take a look through the docs and stuff to make sure it's not already there.
* **Check if there's already PR which provides that enhancement.**
* **Determine which resource the enhancement should be suggested in.** Whichever resource the suggestion is about, is where it should go. If the suggestion is about Qbox as a whole, make the suggestion in the qbx-core repository.
* **Determine which resource the enhancement should be suggested in.** Whichever resource the suggestion is about, is where it should go. If the suggestion is about Qbox as a whole, make the suggestion in the qbx_core repository.
* **Perform a [cursory search](https://github.com/search?q=is%3Aissue+user%3Aqbox-project++&type=issues&state=open)** to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.

#### How Do I Submit A (Good) Enhancement Suggestion?
Expand Down
32 changes: 16 additions & 16 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ local function loadSettings(settings)
SendNUIMessage({ test = true, event = k, toggle = v })
end
end
QBX.Functions.Notify(Lang:t("notify.hud_settings_loaded"), 'success')
exports.qbx_core:Notify(Lang:t("notify.hud_settings_loaded"), 'success')
Wait(1000)
TriggerEvent("hud:client:LoadMap")
end
Expand Down Expand Up @@ -127,7 +127,7 @@ RegisterKeyMapping('menu', Lang:t('info.open_menu'), 'keyboard', Config.OpenMenu
-- Reset hud
local function restartHud()
TriggerEvent("hud:client:playResetHudSounds")
QBX.Functions.Notify(Lang:t("notify.hud_restart"), 'error')
exports.qbx_core:Notify(Lang:t("notify.hud_restart"), 'error')
if cache.vehicle then
Wait(2600)
SendNUIMessage({ action = 'car', show = false })
Expand All @@ -137,7 +137,7 @@ local function restartHud()
SendNUIMessage({ action = 'hudtick', show = false })
SendNUIMessage({ action = 'hudtick', show = true })
Wait(2600)
QBX.Functions.Notify(Lang:t("notify.hud_start"), 'success')
exports.qbx_core:Notify(Lang:t("notify.hud_start"), 'success')
end

RegisterNUICallback('restartHud', function(_, cb)
Expand Down Expand Up @@ -358,7 +358,7 @@ RegisterNetEvent("hud:client:LoadMap", function()
Wait(150)
end
if Menu.isMapNotifChecked then
QBX.Functions.Notify(Lang:t("notify.load_square_map"), 'inform')
exports.qbx_core:Notify(Lang:t("notify.load_square_map"), 'inform')
end
SetMinimapClipType(0)
AddReplaceTexture("platform:/textures/graphics", "radarmasksm", "squaremap", "radarmasksm")
Expand Down Expand Up @@ -387,15 +387,15 @@ RegisterNetEvent("hud:client:LoadMap", function()
end
Wait(1200)
if Menu.isMapNotifChecked then
QBX.Functions.Notify(Lang:t("notify.loaded_square_map"), 'success')
exports.qbx_core:Notify(Lang:t("notify.loaded_square_map"), 'success')
end
elseif Menu.isToggleMapShapeChecked == "circle" then
RequestStreamedTextureDict("circlemap", false)
if not HasStreamedTextureDictLoaded("circlemap") then
Wait(150)
end
if Menu.isMapNotifChecked then
QBX.Functions.Notify(Lang:t("notify.load_circle_map"), 'inform')
exports.qbx_core:Notify(Lang:t("notify.load_circle_map"), 'inform')
end
SetMinimapClipType(1)
AddReplaceTexture("platform:/textures/graphics", "radarmasksm", "circlemap", "radarmasksm")
Expand Down Expand Up @@ -424,7 +424,7 @@ RegisterNetEvent("hud:client:LoadMap", function()
end
Wait(1200)
if Menu.isMapNotifChecked then
QBX.Functions.Notify(Lang:t("notify.loaded_circle_map"), 'success')
exports.qbx_core:Notify(Lang:t("notify.loaded_circle_map"), 'success')
end
end
end)
Expand Down Expand Up @@ -522,14 +522,14 @@ RegisterNUICallback('cinematicMode', function(_, cb)
CinematicShow(false)
Menu.isCineamticModeChecked = false
if Menu.isCinematicNotifChecked then
QBX.Functions.Notify(Lang:t("notify.cinematic_off"), 'error')
exports.qbx_core:Notify(Lang:t("notify.cinematic_off"), 'error')
end
DisplayRadar(true)
else
CinematicShow(true)
Menu.isCineamticModeChecked = true
if Menu.isCinematicNotifChecked then
QBX.Functions.Notify(Lang:t("notify.cinematic_on"), 'success')
exports.qbx_core:Notify(Lang:t("notify.cinematic_on"), 'success')
end
end
TriggerEvent("hud:client:playHudChecklistSound")
Expand Down Expand Up @@ -838,7 +838,7 @@ CreateThread(function()
if getFuelLevel(vehicle) <= 20 then -- At 20% Fuel Left
if Menu.isLowFuelChecked then
TriggerServerEvent("InteractSound_SV:PlayOnSource", "pager", 0.10)
QBX.Functions.Notify(Lang:t("notify.low_fuel"), 'error')
exports.qbx_core:Notify(Lang:t("notify.low_fuel"), 'error')
Wait(60000) -- repeats every 1 min until empty
end
end
Expand Down Expand Up @@ -1149,16 +1149,16 @@ CreateThread(function()
end
end)

RegisterNetEvent('qbx-hud:client:showHud', function()
RegisterNetEvent('qbx_hud:client:showHud', function()
if cache.vehicle then
DisplayRadar(true)
updateVehicleHud({
show,
true,
IsPauseMenuActive(),
seatbeltOn,
math.ceil(GetEntitySpeed(vehicle) * speedMultiplier),
getFuelLevel(vehicle),
math.ceil(GetEntityCoords(player).z * 0.5),
math.ceil(GetEntitySpeed(cache.vehicle) * speedMultiplier),
getFuelLevel(cache.vehicle),
math.ceil(GetEntityCoords(cache.ped).z * 0.5),
showAltitude,
showSeatbelt,
showSquareB,
Expand All @@ -1167,7 +1167,7 @@ RegisterNetEvent('qbx-hud:client:showHud', function()
end
end)

RegisterNetEvent('qbx-hud:client:hideHud', function()
RegisterNetEvent('qbx_hud:client:hideHud', function()
if cache.vehicle then
DisplayRadar(false)
SendNUIMessage({
Expand Down
5 changes: 2 additions & 3 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ fx_version 'cerulean'
use_experimental_fxv2_oal 'yes'
lua54 'yes'
game 'gta5'
name 'qbx-hud'
name 'qbx_hud'
author 'Qbus & Qbox Contributors'
version '1.0.0'
repository 'https://github.com/Qbox-project/qbx-hud'
repository 'https://github.com/Qbox-project/qbx_hud'
description 'HUD for Qbox'

shared_scripts {
Expand All @@ -18,7 +18,6 @@ shared_scripts {
}

modules {
'qbx_core:core',
'qbx_core:playerdata',
}

Expand Down
16 changes: 8 additions & 8 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ local resetStress = false
-- Handlers

AddEventHandler('ox_inventory:openedInventory', function(source)
TriggerClientEvent('qbx-hud:client:hideHud', source)
TriggerClientEvent('qbx_hud:client:hideHud', source)
end)

AddEventHandler('ox_inventory:closedInventory', function(source)
TriggerClientEvent('qbx-hud:client:showHud', source)
TriggerClientEvent('qbx_hud:client:showHud', source)
end)

-- Callbacks
Expand All @@ -20,7 +20,7 @@ end)

RegisterNetEvent('hud:server:GainStress', function(amount)
local src = source
local Player = QBX.Functions.GetPlayer(src)
local Player = exports.qbx_core:GetPlayer(src)
local newStress
if not Player or (Config.DisablePoliceStress and Player.PlayerData.job.type == 'leo') then return end
if not resetStress then
Expand All @@ -37,12 +37,12 @@ RegisterNetEvent('hud:server:GainStress', function(amount)
end
Player.Functions.SetMetaData('stress', newStress)
TriggerClientEvent('hud:client:UpdateStress', src, newStress)
TriggerClientEvent('QBCore:Notify', src, Lang:t("notify.stress_gain"), 'inform', 2500, _, _, {'#141517', '#ffffff'}, 'brain', '#C53030')
TriggerClientEvent('QBCore:Notify', src, Lang:t("notify.stress_gain"), 'inform', 2500, nil, nil, {'#141517', '#ffffff'}, 'brain', '#C53030')
end)

RegisterNetEvent('hud:server:RelieveStress', function(amount)
local src = source
local Player = QBX.Functions.GetPlayer(src)
local Player = exports.qbx_core:GetPlayer(src)
local newStress
if not Player then return end
if not resetStress then
Expand All @@ -59,7 +59,7 @@ RegisterNetEvent('hud:server:RelieveStress', function(amount)
end
Player.Functions.SetMetaData('stress', newStress)
TriggerClientEvent('hud:client:UpdateStress', src, newStress)
TriggerClientEvent('QBCore:Notify', src, Lang:t("notify.stress_removed"), 'inform', 2500, _, _, {'#141517', '#ffffff'}, 'brain', '#0F52BA')
TriggerClientEvent('QBCore:Notify', src, Lang:t("notify.stress_removed"), 'inform', 2500, nil, nil, {'#141517', '#ffffff'}, 'brain', '#0F52BA')
end)

-- Commands
Expand All @@ -68,15 +68,15 @@ lib.addCommand(Lang:t('commands.cash'), {
help = Lang:t('commands.help.cash'),
restricted = 'group.admin'
}, function(source)
local player = QBX.Functions.GetPlayer(source)
local player = exports.qbx_core:GetPlayer(source)
local cashAmount = player.PlayerData.money.cash
TriggerClientEvent('hud:client:ShowAccounts', source, 'cash', cashAmount)
end)

lib.addCommand(Lang:t('commands.bank'), {
help = Lang:t('commands.help.bank'),
}, function(source)
local player = QBX.Functions.GetPlayer(source)
local player = exports.qbx_core:GetPlayer(source)
local bankAmount = player.PlayerData.money.bank
TriggerClientEvent('hud:client:ShowAccounts', source, 'bank', bankAmount)
end)
Expand Down

0 comments on commit 496c78a

Please sign in to comment.