Skip to content

Fix linting and docummentation #1179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["sumneko.lua", "overextended.cfxlua-vscode"]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Lua.runtime.nonstandardSymbol": ["/**/", "`", "+=", "-=", "*=", "/="],
"Lua.runtime.version": "Lua 5.4",
"Lua.diagnostics.globals": ["MySQL"],
"Lua.diagnostics.disable": ["duplicate-set-field"]
}
8 changes: 8 additions & 0 deletions client/drawtext.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
--- Hides the displayed text
local function hideText()
SendNUIMessage({
action = 'HIDE_TEXT',
})
end

--- Draws text on the screen
--- @param text string
--- @param position? 'left' | 'right' | 'top' default 'left'
local function drawText(text, position)
if type(position) ~= 'string' then position = 'left' end

Expand All @@ -16,6 +20,9 @@ local function drawText(text, position)
})
end

--- Changes the text on the screen
--- @param text string
--- @param position? 'left' | 'right' | 'top' default 'left'
local function changeText(text, position)
if type(position) ~= 'string' then position = 'left' end

Expand All @@ -28,6 +35,7 @@ local function changeText(text, position)
})
end

--- Displays an animation on key press and then hides the currently displayed text
local function keyPressed()
CreateThread(function() -- Not sure if a thread is needed but why not eh?
SendNUIMessage({
Expand Down
15 changes: 10 additions & 5 deletions client/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RegisterNetEvent('QBCore:Command:GoToMarker', function()
local blipMarker <const> = GetFirstBlipInfoId(8)
if not DoesBlipExist(blipMarker) then
QBCore.Functions.Notify(Lang:t('error.no_waypoint'), 'error', 5000)
return 'marker'
return
end

-- Fade screen to hide how clients get teleported.
Expand Down Expand Up @@ -128,12 +128,14 @@ RegisterNetEvent('QBCore:Command:SpawnVehicle', function(vehName)
Wait(0)
end

if IsPedInAnyVehicle(ped) then
if IsPedInAnyVehicle(ped, false) then
SetEntityAsMissionEntity(veh, true, true)
DeleteVehicle(veh)
end

local vehicle = CreateVehicle(hash, GetEntityCoords(ped), GetEntityHeading(ped), true, false)
local coords = GetEntityCoords(ped)

local vehicle = CreateVehicle(hash, coords.x, coords.y, coords.z, GetEntityHeading(ped), true, false)
TaskWarpPedIntoVehicle(ped, vehicle, -1)
SetVehicleFuelLevel(vehicle, 100.0)
SetVehicleDirtLevel(vehicle, 0.0)
Expand Down Expand Up @@ -230,6 +232,9 @@ end)

-- Me command

--- Draw a 3D text on the screen
--- @param coords vector3 | vector4
--- @param str string
local function Draw3DText(coords, str)
local onScreen, worldX, worldY = World3dToScreen2d(coords.x, coords.y, coords.z)
local camCoords = GetGameplayCamCoord()
Expand All @@ -239,9 +244,9 @@ local function Draw3DText(coords, str)
SetTextFont(4)
SetTextColour(255, 255, 255, 255)
SetTextEdge(2, 0, 0, 0, 150)
SetTextProportional(1)
SetTextProportional(true)
SetTextOutline()
SetTextCentre(1)
SetTextCentre(true)
BeginTextCommandDisplayText('STRING')
AddTextComponentSubstringPlayerName(str)
EndTextCommandDisplayText(worldX, worldY)
Expand Down
Loading