Skip to content

Commit

Permalink
refactor: camelCase, notify, utils
Browse files Browse the repository at this point in the history
* fix: camelCase

* fix: linting
  • Loading branch information
mafewtm authored Nov 17, 2023
1 parent 37f9c06 commit bb4c273
Show file tree
Hide file tree
Showing 9 changed files with 365 additions and 389 deletions.
251 changes: 124 additions & 127 deletions client/admin.lua

Large diffs are not rendered by default.

41 changes: 21 additions & 20 deletions client/dev.lua
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
local ShowCoords = false
local VehicleDev = false
local VehicleTypes = {'Compacts', 'Sedans', 'SUVs', 'Coupes', 'Muscle', 'Sports Classics', 'Sports', 'Super', 'Motorcycles', 'Off-road', 'Industrial', 'Utility', 'Vans', 'Cycles', 'Boats', 'Helicopters', 'Planes', 'Service', 'Emergency', 'Military', 'Commercial', 'Trains', 'Open Wheel'}
local Options = {
local showCoords = false
local vehicleDev = false
local vehicleTypes = {'Compacts', 'Sedans', 'SUVs', 'Coupes', 'Muscle', 'Sports Classics', 'Sports', 'Super', 'Motorcycles', 'Off-road', 'Industrial', 'Utility', 'Vans', 'Cycles', 'Boats', 'Helicopters', 'Planes', 'Service', 'Emergency', 'Military', 'Commercial', 'Trains', 'Open Wheel'}
local options = {
function() CopyToClipboard('coords2') lib.showMenu('qbx_adminmenu_dev_menu', MenuIndexes.qbx_adminmenu_dev_menu) end,
function() CopyToClipboard('coords3') lib.showMenu('qbx_adminmenu_dev_menu', MenuIndexes.qbx_adminmenu_dev_menu) end,
function() CopyToClipboard('coords4') lib.showMenu('qbx_adminmenu_dev_menu', MenuIndexes.qbx_adminmenu_dev_menu) end,
function() CopyToClipboard('heading') lib.showMenu('qbx_adminmenu_dev_menu', MenuIndexes.qbx_adminmenu_dev_menu) end,
function()
ShowCoords = not ShowCoords
while ShowCoords do
local Coords, Heading = GetEntityCoords(cache.ped), GetEntityHeading(cache.ped)
Draw2DText(string.format('~o~vector4~w~(%s, %s, %s, %s)', Round(Coords.x, 2), Round(Coords.y, 2), Round(Coords.z, 2), Round(Heading, 2)), 6, {255, 255, 255}, 0.5, 0.4, 0.025)
showCoords = not showCoords
while showCoords do
local coords, heading = GetEntityCoords(cache.ped), GetEntityHeading(cache.ped)
DrawText2D(string.format('~o~vector4~w~(%s, %s, %s, %s)', math.round(coords.x, 2), math.round(coords.y, 2), math.round(coords.z, 2), math.round(heading, 2)), vec2(0.5, 0.020), 1.0, 1.0, 0.5, 6, 255, 255, 255)
Wait(0)
end
end,
function()
VehicleDev = not VehicleDev
while VehicleDev do
vehicleDev = not vehicleDev
while vehicleDev do
if cache.vehicle then
local Clutch, Gear, Rpm, Temperature = GetVehicleClutch(cache.vehicle), GetVehicleCurrentGear(cache.vehicle), GetVehicleCurrentRpm(cache.vehicle), GetVehicleEngineTemperature(cache.vehicle)
local Oil, Angle, Body, Class = GetVehicleOilLevel(cache.vehicle), GetVehicleSteeringAngle(cache.vehicle), GetVehicleBodyHealth(cache.vehicle), VehicleTypes[GetVehicleClass(cache.vehicle)]
local Dirt, MaxSpeed, NetId, Hash = GetVehicleDirtLevel(cache.vehicle), GetVehicleEstimatedMaxSpeed(cache.vehicle), VehToNet(cache.vehicle), GetEntityModel(cache.vehicle)
local Name = GetLabelText(GetDisplayNameFromVehicleModel(Hash))
Draw2DText(string.format('~o~Clutch: ~w~ %s | ~o~Gear: ~w~ %s | ~o~Rpm: ~w~ %s | ~o~Temperature: ~w~ %s', Round(Clutch, 4), Gear, Round(Rpm, 4), Temperature), 6, {255, 255, 255}, 0.45, 0.05, 0.100)
Draw2DText(string.format('~o~Oil: ~w~ %s | ~o~Steering Angle: ~w~ %s | ~o~Body: ~w~ %s | ~o~Class: ~w~ %s', Round(Oil, 4), Round(Angle, 4), Round(Body, 4), Class), 6, {255, 255, 255}, 0.45, 0.05, 0.125)
Draw2DText(string.format('~o~Dirt: ~w~ %s | ~o~Est Max Speed: ~w~ %s | ~o~Net ID: ~w~ %s | ~o~Hash: ~w~ %s', Round(Dirt, 4), Round(MaxSpeed, 4) * 3.6, NetId, Hash), 6, {255, 255, 255}, 0.45, 0.05, 0.150)
Draw2DText(string.format('~o~Vehicle Name: ~w~ %s', Name), 6, {255, 255, 255}, 0.45, 0.05, 0.175)
local clutch, gear, rpm, temperature = GetVehicleClutch(cache.vehicle), GetVehicleCurrentGear(cache.vehicle), GetVehicleCurrentRpm(cache.vehicle), GetVehicleEngineTemperature(cache.vehicle)
local oil, angle, body, class = GetVehicleOilLevel(cache.vehicle), GetVehicleSteeringAngle(cache.vehicle), GetVehicleBodyHealth(cache.vehicle), vehicleTypes[GetVehicleClass(cache.vehicle)]
local dirt, maxSpeed, netId, hash = GetVehicleDirtLevel(cache.vehicle), GetVehicleEstimatedMaxSpeed(cache.vehicle), VehToNet(cache.vehicle), GetEntityModel(cache.vehicle)
local name = GetLabelText(GetDisplayNameFromVehicleModel(hash))
EndTextCommandDisplayText()
DrawText2D(string.format('~o~Clutch: ~w~ %s | ~o~Gear: ~w~ %s | ~o~Rpm: ~w~ %s | ~o~Temperature: ~w~ %s', math.round(clutch, 4), gear, math.round(rpm, 4), temperature), vec2(0.5, 0.075), 1.0, 1.0, 0.45, 6, 255, 255, 255)
DrawText2D(string.format('~o~Oil: ~w~ %s | ~o~Steering Angle: ~w~ %s | ~o~Body: ~w~ %s | ~o~Class: ~w~ %s', math.round(oil, 4), math.round(angle, 4), math.round(body, 4), class), vec2(0.5, 0.1), 1.0, 1.0, 0.45, 6, 255, 255, 255)
DrawText2D(string.format('~o~Dirt: ~w~ %s | ~o~Est Max Speed: ~w~ %s | ~o~Net ID: ~w~ %s | ~o~Hash: ~w~ %s', math.round(dirt, 4), math.round(maxSpeed, 4) * 3.6, netId, hash), vec2(0.5, 0.125), 1.0, 1.0, 0.45, 6, 255, 255, 255)
DrawText2D(string.format('~o~Vehicle Name: ~w~ %s', name), vec2(0.5, 0.150), 1.0, 1.0, 0.45, 6, 255, 255, 255)
Wait(0)
else
Wait(800)
Expand All @@ -39,7 +40,7 @@ lib.registerMenu({
title = Lang:t('title.dev_menu'),
position = 'top-right',
onClose = function(keyPressed)
CloseMenu(false, keyPressed, 'qbx_adminmenu_main_menu')
closeMenu(false, keyPressed, 'qbx_adminmenu_main_menu')
end,
onSelected = function(selected)
MenuIndexes.qbx_adminmenu_dev_menu = selected
Expand All @@ -53,5 +54,5 @@ lib.registerMenu({
{label = Lang:t('dev_options.label6'), description = Lang:t('dev_options.desc6'), icon = 'fas fa-car-side', close = false}
}
}, function(selected)
Options[selected]()
options[selected]()
end)
24 changes: 3 additions & 21 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ lib.registerMenu({
title = Lang:t('title.main_menu'),
position = 'top-right',
onClose = function()
CloseMenu(true)
closeMenu(true)
end,
onSelected = function(selected)
MenuIndexes.qbx_adminmenu_main_menu = selected
Expand All @@ -25,24 +25,7 @@ lib.registerMenu({
end
end)

function Round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end

function Draw2DText(content, font, colour, scale, x, y)
SetTextFont(font)
SetTextScale(scale, scale)
SetTextColour(colour[1], colour[2], colour[3], 255)
BeginTextCommandDisplayText('STRING')
SetTextDropShadow()
SetTextEdge(4, 0, 0, 0, 255)
SetTextOutline()
AddTextComponentSubstringPlayerName(content)
EndTextCommandDisplayText(x, y)
end

function CloseMenu(isFullMenuClose, keyPressed, previousMenu)
function closeMenu(isFullMenuClose, keyPressed, previousMenu)
if isFullMenuClose or not keyPressed or keyPressed == 'Escape' then
lib.hideMenu(false)
return
Expand All @@ -59,8 +42,7 @@ RegisterNetEvent('qbx_admin:client:setModel', function(skin)
local model = joaat(skin)
SetEntityInvincible(cache.ped, true)
if IsModelInCdimage(model) and IsModelValid(model) then
RequestModel(model)
while not HasModelLoaded(model) do Wait(0) end
lib.requestModel(model)
SetPlayerModel(cache.playerId, model)
SetPedRandomComponentVariation(cache.ped, 1)
SetModelAsNoLongerNeeded(model)
Expand Down
Loading

0 comments on commit bb4c273

Please sign in to comment.