Skip to content

Commit

Permalink
refactor: standardize single quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
mafewtm authored Mar 14, 2024
1 parent 53a498a commit c0e8531
Show file tree
Hide file tree
Showing 17 changed files with 222 additions and 222 deletions.
2 changes: 1 addition & 1 deletion bridge/qb/client/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ function functions.SetVehicleProperties(vehicle, props)

--- lib.setVehicleProperties copied and pasted from Overextended below so that we can remove the error so that setting properties is best effort
if not DoesEntityExist(vehicle) then
error(("Unable to set vehicle properties for '%s' (entity does not exist)"):
error(('Unable to set vehicle properties for "%s" (entity does not exist)'):
format(vehicle))
end

Expand Down
2 changes: 1 addition & 1 deletion bridge/qb/server/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local commands = {}
function commands.Add(name, help, arguments, argsrequired, callback, permission)
local properties = {
help = help,
restricted = permission and permission ~= "user" and 'group.'..permission or false,
restricted = permission and permission ~= 'user' and 'group.'..permission or false,
params = {}
}
for i = 1, #arguments do
Expand Down
2 changes: 1 addition & 1 deletion bridge/qb/server/debug.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---@deprecated Call lib.print.debug() instead
---@param tbl any
RegisterServerEvent('QBCore:DebugSomething', function(tbl)
local resource = GetInvokingResource() or "qbx_core"
local resource = GetInvokingResource() or 'qbx_core'
lib.print.debug(resource, tbl)
end)
96 changes: 48 additions & 48 deletions bridge/qb/server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,19 @@ functions.GetPlate = qbx.getVehiclePlate
---@deprecated incompatible with ox_inventory. Update ox_inventory item config instead.
local function AddItem(itemName, item)
lib.print.warn(('%s invoked deprecated function AddItem. This is incompatible with ox_inventory'):format(GetInvokingResource() or 'unknown resource'))
if type(itemName) ~= "string" then
return false, "invalid_item_name"
if type(itemName) ~= 'string' then
return false, 'invalid_item_name'
end

if QBX.Shared.Items[itemName] then
return false, "item_exists"
return false, 'item_exists'
end

QBX.Shared.Items[itemName] = item

TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Items', itemName, item)
TriggerEvent('QBCore:Server:UpdateObject')
return true, "success"
return true, 'success'
end

functions.AddItem = AddItem
Expand All @@ -158,16 +158,16 @@ createQbExport('AddItem', AddItem)
---@deprecated incompatible with ox_inventory. Update ox_inventory item config instead.
local function UpdateItem(itemName, item)
lib.print.warn(('%s invoked deprecated function UpdateItem. This is incompatible with ox_inventory'):format(GetInvokingResource() or 'unknown resource'))
if type(itemName) ~= "string" then
return false, "invalid_item_name"
if type(itemName) ~= 'string' then
return false, 'invalid_item_name'
end
if not QBX.Shared.Items[itemName] then
return false, "item_not_exists"
return false, 'item_not_exists'
end
QBX.Shared.Items[itemName] = item
TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Items', itemName, item)
TriggerEvent('QBCore:Server:UpdateObject')
return true, "success"
return true, 'success'
end

functions.UpdateItem = UpdateItem
Expand All @@ -178,19 +178,19 @@ createQbExport('UpdateItem', UpdateItem)
local function AddItems(items)
lib.print.warn(('%s invoked deprecated function AddItems. This is incompatible with ox_inventory'):format(GetInvokingResource() or 'unknown resource'))
local shouldContinue = true
local message = "success"
local message = 'success'
local errorItem = nil

for key, value in pairs(items) do
if type(key) ~= "string" then
message = "invalid_item_name"
if type(key) ~= 'string' then
message = 'invalid_item_name'
shouldContinue = false
errorItem = items[key]
break
end

if QBX.Shared.Items[key] then
message = "item_exists"
message = 'item_exists'
shouldContinue = false
errorItem = items[key]
break
Expand All @@ -212,19 +212,19 @@ createQbExport('AddItems', AddItems)
---@deprecated incompatible with ox_inventory. Update ox_inventory item config instead.
local function RemoveItem(itemName)
lib.print.warn(('%s invoked deprecated function RemoveItem. This is incompatible with ox_inventory'):format(GetInvokingResource() or 'unknown resource'))
if type(itemName) ~= "string" then
return false, "invalid_item_name"
if type(itemName) ~= 'string' then
return false, 'invalid_item_name'
end

if not QBX.Shared.Items[itemName] then
return false, "item_not_exists"
return false, 'item_not_exists'
end

QBX.Shared.Items[itemName] = nil

TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Items', itemName, nil)
TriggerEvent('QBCore:Server:UpdateObject')
return true, "success"
return true, 'success'
end

functions.RemoveItem = RemoveItem
Expand All @@ -237,16 +237,16 @@ createQbExport('RemoveItem', RemoveItem)
---@return boolean success
---@return string message
local function addJob(jobName, job)
if type(jobName) ~= "string" then
return false, "invalid_job_name"
if type(jobName) ~= 'string' then
return false, 'invalid_job_name'
end

if GetJob(jobName) then
return false, "job_exists"
return false, 'job_exists'
end

CreateJobs({[jobName] = job})
return true, "success"
return true, 'success'
end

functions.AddJob = function(jobName, job)
Expand All @@ -262,7 +262,7 @@ createQbExport('AddJob', addJob)
---@return Job? errorJob job causing the error message. Only present if success is false.
local function addJobs(jobs)
for key in pairs(jobs) do
if type(key) ~= "string" then
if type(key) ~= 'string' then
return false, 'invalid_job_name', jobs[key]
end

Expand All @@ -287,16 +287,16 @@ createQbExport('AddJobs', addJobs)
---@return boolean success
---@return string message
local function updateJob(jobName, job)
if type(jobName) ~= "string" then
return false, "invalid_job_name"
if type(jobName) ~= 'string' then
return false, 'invalid_job_name'
end

if not GetJob(jobName) then
return false, "job_not_exists"
return false, 'job_not_exists'
end

CreateJobs({[jobName] = job})
return true, "success"
return true, 'success'
end

functions.UpdateJob = function(jobName, job)
Expand All @@ -311,16 +311,16 @@ createQbExport('UpdateJob', updateJob)
---@return boolean success
---@return string message
local function addGang(gangName, gang)
if type(gangName) ~= "string" then
return false, "invalid_gang_name"
if type(gangName) ~= 'string' then
return false, 'invalid_gang_name'
end

if GetGang(gangName) then
return false, "gang_exists"
return false, 'gang_exists'
end

CreateGangs({[gangName] = gang})
return true, "success"
return true, 'success'
end

functions.AddGang = function(gangName, gang)
Expand All @@ -335,16 +335,16 @@ createQbExport('AddGang', addGang)
---@return boolean success
---@return string message
local function updateGang(gangName, gang)
if type(gangName) ~= "string" then
return false, "invalid_gang_name"
if type(gangName) ~= 'string' then
return false, 'invalid_gang_name'
end

if not GetGang(gangName) then
return false, "gang_not_exists"
return false, 'gang_not_exists'
end

CreateGangs({[gangName] = gang})
return true, "success"
return true, 'success'
end

functions.UpdateGang = function(gangName, gang)
Expand All @@ -360,7 +360,7 @@ createQbExport('UpdateGang', updateGang)
---@return Gang? errorGang present if success is false. Gang that caused the error message.
local function addGangs(gangs)
for key in pairs(gangs) do
if type(key) ~= "string" then
if type(key) ~= 'string' then
return false, 'invalid_gang_name', gangs[key]
end

Expand Down Expand Up @@ -392,7 +392,7 @@ createQbExport('RemoveGang', RemoveGang)
---Use-case:
-- [[
-- AddEventHandler('QBCore:Server:PlayerLoaded', function(Player)
-- functions.AddPlayerMethod(Player.PlayerData.source, "functionName", function(oneArg, orMore)
-- functions.AddPlayerMethod(Player.PlayerData.source, 'functionName', function(oneArg, orMore)
-- -- do something here
-- end)
-- end)
Expand All @@ -403,7 +403,7 @@ createQbExport('RemoveGang', RemoveGang)
---@param handler function
function functions.AddPlayerMethod(ids, methodName, handler)
local idType = type(ids)
if idType == "number" then
if idType == 'number' then
if ids == -1 then
for _, v in pairs(QBX.Players) do
v.Functions[methodName] = handler
Expand All @@ -413,7 +413,7 @@ function functions.AddPlayerMethod(ids, methodName, handler)

QBX.Players[ids].Functions[methodName] = handler
end
elseif idType == "table" and table.type(ids) == "array" then
elseif idType == 'table' and table.type(ids) == 'array' then
for i = 1, #ids do
functions.AddPlayerMethod(ids[i], methodName, handler)
end
Expand All @@ -424,7 +424,7 @@ end
---Use-case:
--[[
AddEventHandler('QBCore:Server:PlayerLoaded', function(Player)
functions.AddPlayerField(Player.PlayerData.source, "fieldName", "fieldData")
functions.AddPlayerField(Player.PlayerData.source, 'fieldName', 'fieldData')
end)
]]
---@deprecated
Expand All @@ -433,7 +433,7 @@ end
---@param data any
function functions.AddPlayerField(ids, fieldName, data)
local idType = type(ids)
if idType == "number" then
if idType == 'number' then
if ids == -1 then
for _, v in pairs(QBX.Players) do
v.Functions.AddField(fieldName, data)
Expand All @@ -443,7 +443,7 @@ function functions.AddPlayerField(ids, fieldName, data)

QBX.Players[ids].Functions.AddField(fieldName, data)
end
elseif idType == "table" and table.type(ids) == "array" then
elseif idType == 'table' and table.type(ids) == 'array' then
for i = 1, #ids do
functions.AddPlayerField(ids[i], fieldName, data)
end
Expand All @@ -457,19 +457,19 @@ end
---@return boolean success
---@return string message
local function SetMethod(methodName, handler)
if type(methodName) ~= "string" then
return false, "invalid_method_name"
if type(methodName) ~= 'string' then
return false, 'invalid_method_name'
end

functions[methodName] = handler

TriggerEvent('QBCore:Server:UpdateObject')

return true, "success"
return true, 'success'
end

functions.SetMethod = SetMethod
createQbExport("SetMethod", SetMethod)
createQbExport('SetMethod', SetMethod)

-- Add or change (a) field(s) in the QBCore table
---@deprecated
Expand All @@ -478,19 +478,19 @@ createQbExport("SetMethod", SetMethod)
---@return boolean success
---@return string message
local function SetField(fieldName, data)
if type(fieldName) ~= "string" then
return false, "invalid_field_name"
if type(fieldName) ~= 'string' then
return false, 'invalid_field_name'
end

QBX[fieldName] = data

TriggerEvent('QBCore:Server:UpdateObject')

return true, "success"
return true, 'success'
end

functions.SetField = SetField
exports("SetField", SetField)
exports('SetField', SetField)

---@param identifier Identifier
---@return integer source of the player with the matching identifier or 0 if no player found
Expand Down
8 changes: 4 additions & 4 deletions bridge/qb/server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ function AddDeprecatedFunctions(player)

---@deprecated call ox_inventory instead
function player.Functions.GetCardSlot()
error("player.Functions.GetCardSlot is unsupported. Call ox_inventory directly")
error('player.Functions.GetCardSlot is unsupported. Call ox_inventory directly')
end

---@deprecated player.Functions.SetMetaData instead
function player.Functions.AddField()
error("player.Functions.AddField is unsupported. Use player.Functions.SetMetaData instead")
error('player.Functions.AddField is unsupported. Use player.Functions.SetMetaData instead')
end

---@deprecated
function player.Functions.AddMethod()
error("player.Functions.AddMethod is unsupported")
error('player.Functions.AddMethod is unsupported')
end

return player
Expand Down Expand Up @@ -77,7 +77,7 @@ end

---@deprecated unsupported. Call Login or CreatePlayer
function playerObj.CheckPlayerData()
error("Unsupported. Call Login or CreatePlayer")
error('Unsupported. Call Login or CreatePlayer')
end

---On player logout
Expand Down
6 changes: 3 additions & 3 deletions client/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ end)
RegisterNetEvent('QBCore:Command:GoToMarker', function()
local blipMarker <const> = GetFirstBlipInfoId(8)
if not DoesBlipExist(blipMarker) then
Notify(locale("error.no_waypoint"), 'error')
Notify(locale('error.no_waypoint'), 'error')
return 'marker'
end

Expand Down Expand Up @@ -120,12 +120,12 @@ RegisterNetEvent('QBCore:Command:GoToMarker', function()
-- If we can't find the coords, set the coords to the old ones.
-- We don't unpack them before since they aren't in a loop and only called once.
SetPedCoordsKeepVehicle(ped, oldCoords.x, oldCoords.y, oldCoords.z - 1.0)
Notify(locale("error.tp_error"), 'error')
Notify(locale('error.tp_error'), 'error')
end

-- If Z coord was found, set coords in found coords.
SetPedCoordsKeepVehicle(ped, x, y, groundZ)
Notify(locale("success.teleported_waypoint"), 'success')
Notify(locale('success.teleported_waypoint'), 'success')
end)

-- Vehicle Commands
Expand Down
2 changes: 1 addition & 1 deletion client/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local positionConfig = require 'config.shared'.notifyPosition
---@param notifyIconColor? string Custom color for the icon chosen before
function Notify(text, notifyType, duration, subTitle, notifyPosition, notifyStyle, notifyIcon, notifyIconColor)
local title, description
if type(text) == "table" then
if type(text) == 'table' then
title = text.text or 'Placeholder'
description = text.caption or nil
elseif subTitle then
Expand Down
2 changes: 1 addition & 1 deletion client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ CreateThread(function()
for _, v in pairs(GetVehiclesByName()) do
if v.model and v.name then
local gameName = GetDisplayNameFromVehicleModel(v.model)
if gameName and gameName ~= "CARNOTFOUND" then
if gameName and gameName ~= 'CARNOTFOUND' then
AddTextEntryByHash(joaat(gameName), v.name)
else
lib.print.warn('Could not find gameName value in vehicles.meta for vehicle model %s', v.model)
Expand Down
Loading

0 comments on commit c0e8531

Please sign in to comment.