From 3b6b8b27beb41309bf4e661c2cce6ac3c2d5cfd6 Mon Sep 17 00:00:00 2001 From: FjamZoo <34508112+FjamZoo@users.noreply.github.com> Date: Thu, 16 Nov 2023 04:40:08 +0100 Subject: [PATCH 1/3] fix(statebags): wait for entity ID to exist in network * fix(statebags): wait for entity ID to exsist in network * fix typo * fix typo * fix typo --------- Co-authored-by: Manason --- modules/utils.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/utils.lua b/modules/utils.lua index 44f4f0265..21ec2d6e5 100644 --- a/modules/utils.lua +++ b/modules/utils.lua @@ -369,11 +369,13 @@ else function GetEntityAndNetIdFromBagName(bagName) -- luacheck: ignore local netId = tonumber(bagName:gsub('entity:', ''), 10) - lib.waitFor(function() - return NetworkDoesEntityExistWithNetworkId(netId) + local idExist = lib.waitFor(function() + local netIdExist = NetworkDoesEntityExistWithNetworkId(netId) + + if netIdExist then return netIdExist end end, ('statebag timed out while awaiting entity creation! (%s)'):format(bagName), 10000) - local entity = NetworkDoesEntityExistWithNetworkId(netId) and NetworkGetEntityFromNetworkId(netId) or 0 + local entity = idExist and NetworkGetEntityFromNetworkId(netId) or 0 if entity == 0 then lib.print.error(('statebag received invalid entity! (%s)'):format(bagName)) From df0a6efbee3cae85c3d59c3bfd217cdeb3f478ff Mon Sep 17 00:00:00 2001 From: FjamZoo <34508112+FjamZoo@users.noreply.github.com> Date: Thu, 16 Nov 2023 04:42:47 +0100 Subject: [PATCH 2/3] feat(manifest): remove client readability --- fxmanifest.lua | 5 ----- 1 file changed, 5 deletions(-) diff --git a/fxmanifest.lua b/fxmanifest.lua index 385af0173..4cd85d60f 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -54,11 +54,6 @@ files { 'bridge/qb/client/events.lua', 'bridge/qb/shared/main.lua', 'bridge/qb/shared/export-function.lua', - 'bridge/qb/server/functions.lua', - 'bridge/qb/server/player.lua', - 'bridge/qb/server/commands.lua', - 'bridge/qb/server/debug.lua', - 'bridge/qb/server/events.lua', 'config/client.lua', 'config/shared.lua' } From 37a6d6b05cf096de2c5185e85efa5d6b90db43de Mon Sep 17 00:00:00 2001 From: Matthew <22198949+MafewTM@users.noreply.github.com> Date: Wed, 15 Nov 2023 22:44:42 -0500 Subject: [PATCH 3/3] chore: camelCase config variables * fix: camelCase config variables * fix: notifyPosition issue * fix: missing changes --------- Co-authored-by: Manason --- client/character.lua | 24 ++++++++++---------- client/discord.lua | 16 ++++++------- client/functions.lua | 4 ++-- client/loops.lua | 4 ++-- client/main.lua | 2 +- config/client.lua | 30 ++++++++++++------------- config/server.lua | 53 ++++++++++++++++++++++---------------------- config/shared.lua | 4 ++-- server/character.lua | 6 ++--- server/commands.lua | 20 ++++++++--------- server/events.lua | 20 ++++++++--------- server/functions.lua | 14 ++++++------ server/loops.lua | 10 ++++----- server/player.lua | 10 ++++----- server/storage.lua | 12 +++++----- 15 files changed, 114 insertions(+), 115 deletions(-) diff --git a/client/character.lua b/client/character.lua index 71b528d5c..5716629ff 100644 --- a/client/character.lua +++ b/client/character.lua @@ -1,10 +1,10 @@ local config = require 'config.client' -local defaultSpawn = require 'config.shared'.DefaultSpawn +local defaultSpawn = require 'config.shared'.defaultSpawn -if config.Characters.UseExternalCharacters then return end +if config.characters.useExternalCharacters then return end local previewCam = nil -local randomLocation = config.Characters.Locations[math.random(1, #config.Characters.Locations)] +local randomLocation = config.characters.locations[math.random(1, #config.characters.locations)] local randomPedModels = { `a_m_o_soucent_02`, @@ -53,19 +53,19 @@ end local function previewPed(citizenId) if not citizenId then local model = randomPedModels[math.random(1, #randomPedModels)] - lib.requestModel(model, config.LoadingModelsTimeout) + lib.requestModel(model, config.loadingModelsTimeout) SetPlayerModel(cache.playerId, model) return end local clothing, model = lib.callback.await('qbx_core:server:getPreviewPedData', false, citizenId) if model and clothing then - lib.requestModel(model, config.LoadingModelsTimeout) + lib.requestModel(model, config.loadingModelsTimeout) SetPlayerModel(cache.playerId, model) pcall(function() exports['illenium-appearance']:setPedAppearance(PlayerPedId(), json.decode(clothing)) end) else model = randomPedModels[math.random(1, #randomPedModels)] - lib.requestModel(model, config.LoadingModelsTimeout) + lib.requestModel(model, config.loadingModelsTimeout) SetPlayerModel(cache.playerId, model) end end @@ -136,14 +136,14 @@ end ---@return boolean local function checkStrings(dialog, input) local str = dialog[input] - if config.Characters.ProfanityWords[str:lower()] then return false end + if config.characters.profanityWords[str:lower()] then return false end local split = {string.strsplit(' ', str)} if #split > 5 then return false end for i = 1, #split do local word = split[i] - if config.Characters.ProfanityWords[word:lower()] then return false end + if config.characters.profanityWords[word:lower()] then return false end end return true @@ -238,7 +238,7 @@ local function createCharacter(cid) spawnDefault() TriggerEvent('qb-clothes:client:CreateFirstCharacter') else - if config.Characters.StartingApartment then + if config.characters.startingApartment then TriggerEvent('apartments:client:setupSpawnUI', newData) else TriggerEvent('qbx_core:client:spawnNoApartments') @@ -250,7 +250,7 @@ local function createCharacter(cid) end local function chooseCharacter() - randomLocation = config.Characters.Locations[math.random(1, #config.Characters.Locations)] + randomLocation = config.characters.locations[math.random(1, #config.characters.locations)] DoScreenFadeOut(500) @@ -328,7 +328,7 @@ local function chooseCharacter() destroyPreviewCam() end }, - config.Characters.EnableDeleteButton and { + config.characters.enableDeleteButton and { title = Lang:t('info.delete_character'), description = Lang:t('info.delete_character_description', { playerName = name }), icon = 'trash', @@ -394,7 +394,7 @@ CreateThread(function() if NetworkIsSessionStarted() then pcall(function() exports.spawnmanager:setAutoSpawn(false) end) Wait(250) - lib.requestModel(model, config.LoadingModelsTimeout) + lib.requestModel(model, config.loadingModelsTimeout) SetPlayerModel(cache.playerId, model) chooseCharacter() break diff --git a/client/discord.lua b/client/discord.lua index c473584c2..b8434666f 100644 --- a/client/discord.lua +++ b/client/discord.lua @@ -1,5 +1,5 @@ local maxPlayers = GlobalState.MaxPlayers -local discord = require 'config.client'.Discord +local discord = require 'config.client'.discord AddStateBagChangeHandler('PlayerCount', nil, function(bagName, _, value) if bagName == 'global' and value then @@ -8,10 +8,10 @@ AddStateBagChangeHandler('PlayerCount', nil, function(bagName, _, value) end end) -SetDiscordAppId(discord.AppId) -SetDiscordRichPresenceAsset(discord.LargeIcon.icon) -SetDiscordRichPresenceAssetText(discord.LargeIcon.text) -SetDiscordRichPresenceAssetSmall(discord.SmallIcon.icon) -SetDiscordRichPresenceAssetSmallText(discord.SmallIcon.text) -SetDiscordRichPresenceAction(0, discord.FirstButton.text, discord.FirstButton.link) -SetDiscordRichPresenceAction(1, discord.SecondButton.text, discord.SecondButton.link) +SetDiscordAppId(discord.appId) +SetDiscordRichPresenceAsset(discord.largeIcon.icon) +SetDiscordRichPresenceAssetText(discord.largeIcon.text) +SetDiscordRichPresenceAssetSmall(discord.smallIcon.icon) +SetDiscordRichPresenceAssetSmallText(discord.smallIcon.text) +SetDiscordRichPresenceAction(0, discord.firstButton.text, discord.firstButton.link) +SetDiscordRichPresenceAction(1, discord.secondButton.text, discord.secondButton.link) diff --git a/client/functions.lua b/client/functions.lua index 28bd70c95..c1d682f87 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -1,4 +1,4 @@ -local NotifyPosition = require 'config.shared'.NotifyPosition +local positionConfig = require 'config.shared'.notifyPosition ---Text box popup for player which dissappears after a set time. ---@param text table|string text of the notification @@ -20,7 +20,7 @@ function Notify(text, notifyType, duration, subTitle, notifyPosition, notifyStyl else description = text end - local position = notifyPosition or NotifyPosition + local position = notifyPosition or positionConfig lib.notify({ id = title, diff --git a/client/loops.lua b/client/loops.lua index 9c163d552..ff23b8f5d 100644 --- a/client/loops.lua +++ b/client/loops.lua @@ -1,7 +1,7 @@ -local StatusInterval = require 'config.client'.StatusInterval +local statusInterval = require 'config.client'.statusInterval CreateThread(function() - local timeout = 60000 * StatusInterval + local timeout = 60000 * statusInterval while true do Wait(timeout) diff --git a/client/main.lua b/client/main.lua index 4b20319e6..3babc5ccb 100644 --- a/client/main.lua +++ b/client/main.lua @@ -60,6 +60,6 @@ lib.callback.register('qbx_core:client:setHealth', function(health) SetEntityHealth(cache.ped, health) end) -local mapText = require 'config.client'.PauseMapText +local mapText = require 'config.client'.pauseMapText if mapText == '' or type(mapText) ~= 'string' then mapText = 'FiveM' end AddTextEntry('FE_THDR_GTAO', mapText) \ No newline at end of file diff --git a/config/client.lua b/config/client.lua index 1cda554d5..5872e477e 100644 --- a/config/client.lua +++ b/config/client.lua @@ -1,19 +1,19 @@ return { - StatusInterval = 5, -- how often to check hunger/thirst status in minutes - LoadingModelsTimeout = 10000, -- Waiting time for ox_lib to load the models before throws an error, for low specs pc + statusInterval = 5, -- how often to check hunger/thirst status in minutes + loadingModelsTimeout = 10000, -- Waiting time for ox_lib to load the models before throws an error, for low specs pc - PauseMapText = 'Powered by Qbox', -- Text shown above the map when ESC is pressed. If left empty 'FiveM' will appear + pauseMapText = 'Powered by Qbox', -- Text shown above the map when ESC is pressed. If left empty 'FiveM' will appear - Characters = { - UseExternalCharacters = false, -- Whether you have an external character management resource. (If true, disables the character management inside the core) - EnableDeleteButton = true, -- Whether players should be able to delete characters themselves. - StartingApartment = true, -- If set to false, skips apartment choice in the beginning (requires qbx_spawn if true) + characters = { + useExternalCharacters = false, -- Whether you have an external character management resource. (If true, disables the character management inside the core) + enableDeleteButton = true, -- Whether players should be able to delete characters themselves. + startingApartment = false, -- If set to false, skips apartment choice in the beginning (requires qbx_spawn if true) - ProfanityWords = { + profanityWords = { ['bad word'] = true }, - Locations = { -- Spawn locations for multichar, these are chosen randomly + locations = { -- Spawn locations for multichar, these are chosen randomly { pedCoords = vec4(969.25, 72.61, 116.18, 276.55), camCoords = vec4(972.2, 72.9, 116.68, 97.27), @@ -42,25 +42,25 @@ return { }, - Discord = { - AppId = '', -- This is the Application ID (Replace this with you own) + discord = { + appId = '', -- This is the Application ID (Replace this with you own) - LargeIcon = { -- To set this up, visit https://forum.cfx.re/t/how-to-updated-discord-rich-presence-custom-image/157686 + largeIcon = { -- To set this up, visit https://forum.cfx.re/t/how-to-updated-discord-rich-presence-custom-image/157686 icon = 'logo_name', -- Here you will have to put the image name for the 'large' icon. text = 'This is a large icon with text', -- Here you can add hover text for the 'large' icon. }, - SmallIcon = { + smallIcon = { icon = 'logo_name', -- Here you will have to put the image name for the 'small' icon. text = 'This is a small icon with text', -- Here you can add hover text for the 'small' icon. }, - FirstButton = { + firstButton = { text = 'First Button!', link = 'fivem://connect/localhost:30120', }, - SecondButton = { + secondButton = { text = 'Second Button!', link = 'fivem://connect/localhost:30120', } diff --git a/config/server.lua b/config/server.lua index 3a230be3a..192954c4a 100644 --- a/config/server.lua +++ b/config/server.lua @@ -1,29 +1,29 @@ return { - UpdateInterval = 5, -- how often to update player data in minutes + updateInterval = 5, -- how often to update player data in minutes ---@alias MoneyType 'cash' | 'bank' | 'crypto' ---@alias Money {cash: number, bank: number, crypto: number} ---@type Money - Money = { - MoneyTypes = { cash = 500, bank = 5000, crypto = 0 }, -- type = startamount - Add or remove money types for your server (for ex. blackmoney = 0), remember once added it will not be removed from the database! - DontAllowMinus = { 'cash', 'crypto' }, -- Money that is not allowed going in minus - PaycheckTimeout = 10, -- The time in minutes that it will give the paycheck - PaycheckSociety = false -- If true paycheck will come from the society account that the player is employed at, requires qb-management + money = { + moneyTypes = { cash = 500, bank = 5000, crypto = 0 }, -- type = startamount - Add or remove money types for your server (for ex. blackmoney = 0), remember once added it will not be removed from the database! + dontAllowMinus = { 'cash', 'crypto' }, -- Money that is not allowed going in minus + paycheckTimeout = 10, -- The time in minutes that it will give the paycheck + paycheckSociety = false -- If true paycheck will come from the society account that the player is employed at, requires qb-management }, - Player = { - HungerRate = 4.2, -- Rate at which hunger goes down. - ThirstRate = 3.8, -- Rate at which thirst goes down. + player = { + hungerRate = 4.2, -- Rate at which hunger goes down. + thirstRate = 3.8, -- Rate at which thirst goes down. ---@enum BloodType - Bloodtypes = { + bloodTypes = { "A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-", }, ---@alias UniqueIdType 'citizenid' | 'AccountNumber' | 'PhoneNumber' | 'FingerId' | 'WalletId' | 'SerialNumber' ---@type table - IdentifierTypes = { + identifierTypes = { citizenid = { valueFunction = function() return tostring(RandomLetter(3) .. RandomNumber(5)):upper() @@ -61,7 +61,7 @@ return { ---@alias TableName string ---@alias ColumnName string ---@type table - CharacterDataTables = { + characterDataTables = { players = 'citizenid', apartments = 'citizenid', bank_accounts_new = 'id', @@ -77,28 +77,27 @@ return { }, -- Rows to be deleted when the character is deleted - Server = { - PVP = true, -- Enable or disable pvp on the server (Ability to shoot other players) - Closed = false, -- Set server closed (no one can join except people with ace permission 'qbadmin.join') - ClosedReason = 'Server Closed', -- Reason message to display when people can't join the server - Uptime = 0, -- Time the server has been up. - Whitelist = false, -- Enable or disable whitelist on the server - WhitelistPermission = 'admin', -- Permission that's able to enter the server when the whitelist is on - Discord = '', -- Discord invite link - CheckDuplicateLicense = true, -- Check for duplicate rockstar license on join - Permissions = { 'god', 'admin', 'mod' }, -- Add as many groups as you want here after creating them in your server.cfg + server = { + pvp = true, -- Enable or disable pvp on the server (Ability to shoot other players) + closed = false, -- Set server closed (no one can join except people with ace permission 'qbadmin.join') + closedReason = 'Server Closed', -- Reason message to display when people can't join the server + whitelist = false, -- Enable or disable whitelist on the server + whitelistPermission = 'admin', -- Permission that's able to enter the server when the whitelist is on + discord = '', -- Discord invite link + checkDuplicateLicense = true, -- Check for duplicate rockstar license on join + permissions = { 'god', 'admin', 'mod' }, -- Add as many groups as you want here after creating them in your server.cfg }, - Characters = { - PlayersNumberOfCharacters = { -- Define maximum amount of player characters by rockstar license (you can find this license in your server's database in the player table) + characters = { + playersNumberOfCharacters = { -- Define maximum amount of player characters by rockstar license (you can find this license in your server's database in the player table) ['license2:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'] = 5, }, - DefaultNumberOfCharacters = 3, -- Define maximum amount of default characters (maximum 3 characters defined by default) + defaultNumberOfCharacters = 3, -- Define maximum amount of default characters (maximum 3 characters defined by default) }, ---@type { name: string, amount: integer, metadata: fun(source: number): table } - StarterItems = { -- Character starting items + starterItems = { -- Character starting items { name = 'phone', amount = 1 }, { name = 'id_card', amount = 1, metadata = function(source) if GetResourceState('qbx_idcard') ~= 'started' then @@ -116,7 +115,7 @@ return { }, }, - GiveVehicleKeys = function(src, plate) + giveVehicleKeys = function(src, plate) exports.qbx_vehiclekeys:GiveKeys(src, plate) end } \ No newline at end of file diff --git a/config/shared.lua b/config/shared.lua index d96cb56c1..559c15360 100644 --- a/config/shared.lua +++ b/config/shared.lua @@ -1,4 +1,4 @@ return { - DefaultSpawn = vec4(-540.58, -212.02, 37.65, 208.88), - NotifyPosition = 'top-right' -- 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left' + defaultSpawn = vec4(-540.58, -212.02, 37.65, 208.88), + notifyPosition = 'top-right' -- 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left' } \ No newline at end of file diff --git a/server/character.lua b/server/character.lua index d0de8963e..d8c20f99f 100644 --- a/server/character.lua +++ b/server/character.lua @@ -3,7 +3,7 @@ local config = require 'config.server' ---@param license2 string ---@param license? string local function getAllowedAmountOfCharacters(license2, license) - return config.Characters.PlayersNumberOfCharacters[license2] or license and config.Characters.PlayersNumberOfCharacters[license] or config.Characters.DefaultNumberOfCharacters + return config.characters.playersNumberOfCharacters[license2] or license and config.characters.playersNumberOfCharacters[license] or config.characters.defaultNumberOfCharacters end ---@param source Source @@ -12,8 +12,8 @@ local function giveStarterItems(source) Wait(100) end - for i = 1, #config.StarterItems do - local item = config.StarterItems[i] + for i = 1, #config.starterItems do + local item = config.starterItems[i] if item.metadata and type(item.metadata) == 'function' then exports.ox_inventory:AddItem(source, item.name, item.amount, item.metadata(source)) else diff --git a/server/commands.lua b/server/commands.lua index 93a32dce6..d6e68fbbe 100644 --- a/server/commands.lua +++ b/server/commands.lua @@ -1,6 +1,6 @@ local config = require 'config.server' -GlobalState.PVPEnabled = config.Server.PVP +GlobalState.PVPEnabled = config.server.pvp -- Teleport lib.addCommand('tp', { @@ -47,8 +47,8 @@ lib.addCommand('togglepvp', { help = Lang:t("command.togglepvp.help"), restricted = "group.admin" }, function() - config.Server.PVP = not config.Server.PVP - GlobalState.PVPEnabled = config.Server.PVP + config.server.pvp = not config.server.pvp + GlobalState.PVPEnabled = config.server.pvp end) -- Permissions @@ -93,12 +93,12 @@ lib.addCommand('openserver', { help = Lang:t("command.openserver.help"), restricted = "group.admin" }, function(source) - if not config.Server.Closed then + if not config.server.closed then Notify(source, Lang:t('error.server_already_open'), 'error') return end if HasPermission(source, 'admin') then - config.Server.Closed = false + config.server.closed = false Notify(source, Lang:t('success.server_opened'), 'success') else KickWithReason(source, Lang:t("error.no_permission"), nil, nil) @@ -112,16 +112,16 @@ lib.addCommand('closeserver', { }, restricted = "group.admin" }, function(source, args) - if config.Server.Closed then + if config.server.closed then Notify(source, Lang:t('error.server_already_closed'), 'error') return end if HasPermission(source, 'admin') then local reason = args[Lang:t("command.closeserver.params.reason.name")] or 'No reason specified' - config.Server.Closed = true - config.Server.ClosedReason = reason + config.server.closed = true + config.server.closedReason = reason for k in pairs(QBX.Players) do - if not HasPermission(k, config.Server.WhitelistPermission) then + if not HasPermission(k, config.server.whitelistPermission) then KickWithReason(k, reason, nil, nil) end end @@ -143,7 +143,7 @@ lib.addCommand('car', { if not args then return end local netId = SpawnVehicle(source, args[Lang:t("command.car.params.model.name")], nil, true) local plate = GetPlate(NetworkGetEntityFromNetworkId(netId)) - config.GiveVehicleKeys(source, plate) + config.giveVehicleKeys(source, plate) end) lib.addCommand('dv', { diff --git a/server/events.lua b/server/events.lua index adb6a99b6..814026e48 100644 --- a/server/events.lua +++ b/server/events.lua @@ -1,4 +1,4 @@ -local serverConfig = require 'config.server'.Server +local serverConfig = require 'config.server'.server -- Event Handler @@ -13,7 +13,7 @@ AddEventHandler('chatMessage', function(_, _, message) end) AddEventHandler('playerJoining', function() - if not serverConfig.CheckDuplicateLicense then return end + if not serverConfig.checkDuplicateLicense then return end local src = source --[[@as string]] local license = GetPlayerIdentifierByType(src, 'license2') or GetPlayerIdentifierByType(src, 'license') if not license then return end @@ -58,9 +58,9 @@ local function onPlayerConnecting(name, _, deferrals) -- Mandatory wait Wait(0) - if serverConfig.Closed then + if serverConfig.closed then if not IsPlayerAceAllowed(src, 'qbadmin.join') then - deferrals.done(serverConfig.ClosedReason) + deferrals.done(serverConfig.closedReason) end end @@ -73,7 +73,7 @@ local function onPlayerConnecting(name, _, deferrals) if not license then deferrals.done(Lang:t('error.no_valid_license')) - elseif serverConfig.CheckDuplicateLicense and IsLicenseInUse(license) then + elseif serverConfig.checkDuplicateLicense and IsLicenseInUse(license) then deferrals.done(Lang:t('error.duplicate_license')) end @@ -90,7 +90,7 @@ local function onPlayerConnecting(name, _, deferrals) end end) - if serverConfig.Whitelist and success then + if serverConfig.whitelist and success then deferrals.update(string.format(Lang:t('info.checking_whitelisted'), name)) success, err = pcall(function() if not IsWhitelisted(src --[[@as Source]]) then @@ -148,10 +148,10 @@ RegisterNetEvent('QBCore:Server:CloseServer', function(reason) local src = source --[[@as Source]] if HasPermission(src, 'admin') then reason = reason or 'No reason specified' - serverConfig.Closed = true - serverConfig.ClosedReason = reason + serverConfig.closed = true + serverConfig.closedReason = reason for k in pairs(QBX.Players) do - if not HasPermission(k, serverConfig.WhitelistPermission) then + if not HasPermission(k, serverConfig.whitelistPermission) then KickWithReason(k, reason, nil, nil) end end @@ -163,7 +163,7 @@ end) RegisterNetEvent('QBCore:Server:OpenServer', function() local src = source --[[@as Source]] if HasPermission(src, 'admin') then - serverConfig.Closed = false + serverConfig.closed = false else KickWithReason(src, Lang:t("error.no_permission"), nil, nil) end diff --git a/server/functions.lua b/server/functions.lua index 7e719c4fb..db5a9f5f5 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -1,5 +1,5 @@ -local serverConfig = require 'config.server'.Server -local positionConfig = require 'config.shared'.NotifyPosition +local serverConfig = require 'config.server'.server +local positionConfig = require 'config.shared'.notifyPosition -- Getters -- Get your player first and then trigger a function on them @@ -209,8 +209,8 @@ exports('CanUseItem', CanUseItem) ---@param source Source ---@return boolean function IsWhitelisted(source) - if not serverConfig.Whitelist then return true end - if HasPermission(source, serverConfig.WhitelistPermission) then return true end + if not serverConfig.whitelist then return true end + if HasPermission(source, serverConfig.whitelistPermission) then return true end return false end @@ -244,7 +244,7 @@ function RemovePermission(source, permission) end else local hasUpdated = false - for _, v in pairs(serverConfig.Permissions) do + for _, v in pairs(serverConfig.permissions) do if IsPlayerAceAllowed(source --[[@as string]], v) then lib.removePrincipal('player.' .. source, 'group.' .. v) lib.removeAce('player.' .. source, 'group.' .. v) @@ -282,7 +282,7 @@ exports('HasPermission', HasPermission) ---@return table function GetPermission(source) local perms = {} - for _, v in pairs (serverConfig.Permissions) do + for _, v in pairs (serverConfig.permissions) do if IsPlayerAceAllowed(source --[[@as string]], v) then perms[v] = true end @@ -398,7 +398,7 @@ local function ExploitBan(playerId, origin) bannedBy = 'Anti Cheat' }) end) - DropPlayer(playerId --[[@as string]], Lang:t('info.exploit_banned', {discord = serverConfig.Discord})) + DropPlayer(playerId --[[@as string]], Lang:t('info.exploit_banned', {discord = serverConfig.discord})) TriggerEvent("qb-log:server:CreateLog", "anticheat", "Anti-Cheat", "red", name .. " has been banned for exploiting " .. origin, true) end diff --git a/server/loops.lua b/server/loops.lua index c28a45ac0..969b7dde8 100644 --- a/server/loops.lua +++ b/server/loops.lua @@ -1,10 +1,10 @@ local config = require 'config.server' -lib.cron.new(('*/%s * * * *'):format(config.UpdateInterval), function() +lib.cron.new(('*/%s * * * *'):format(config.updateInterval), function() for src, player in pairs(QBX.Players) do if player then - local newHunger = player.PlayerData.metadata.hunger - config.Player.HungerRate - local newThirst = player.PlayerData.metadata.thirst - config.Player.ThirstRate + local newHunger = player.PlayerData.metadata.hunger - config.player.hungerRate + local newThirst = player.PlayerData.metadata.thirst - config.player.thirstRate if newHunger <= 0 then newHunger = 0 end @@ -29,7 +29,7 @@ local function pay(player) local payment = QBX.Shared.Jobs[job.name].grades[job.grade.level].payment or job.payment if payment <= 0 then return end if not QBX.Shared.Jobs[job.name].offDutyPay and not job.onduty then return end - if not config.Money.PaycheckSociety then + if not config.money.paycheckSociety then sendPaycheck(player, payment) return end @@ -46,7 +46,7 @@ local function pay(player) sendPaycheck(player, payment) end -lib.cron.new(('*/%s * * * *'):format(config.Money.PaycheckTimeout), function() +lib.cron.new(('*/%s * * * *'):format(config.money.paycheckTimeout), function() for _, player in pairs(QBX.Players) do pay(player) end diff --git a/server/player.lua b/server/player.lua index 56f61436c..3ce9382c9 100644 --- a/server/player.lua +++ b/server/player.lua @@ -1,5 +1,5 @@ local config = require 'config.server' -local defaultSpawn = require 'config.shared'.DefaultSpawn +local defaultSpawn = require 'config.shared'.defaultSpawn ---@class PlayerData : PlayerEntity ---@field source? Source present if player is online @@ -69,7 +69,7 @@ function CheckPlayerData(source, playerData) playerData.cid = playerData.charinfo?.cid or playerData.cid or 1 playerData.money = playerData.money or {} playerData.optin = playerData.optin or true - for moneytype, startamount in pairs(config.Money.MoneyTypes) do + for moneytype, startamount in pairs(config.money.moneyTypes) do playerData.money[moneytype] = playerData.money[moneytype] or startamount end @@ -101,7 +101,7 @@ function CheckPlayerData(source, playerData) playerData.metadata.phone = playerData.metadata.phone or {} playerData.metadata.fitbit = playerData.metadata.fitbit or {} playerData.metadata.commandbinds = playerData.metadata.commandbinds or {} - playerData.metadata.bloodtype = playerData.metadata.bloodtype or config.Player.Bloodtypes[math.random(1, #config.Player.Bloodtypes)] + playerData.metadata.bloodtype = playerData.metadata.bloodtype or config.player.bloodTypes[math.random(1, #config.player.bloodTypes)] playerData.metadata.dealerrep = playerData.metadata.dealerrep or 0 playerData.metadata.craftingrep = playerData.metadata.craftingrep or 0 playerData.metadata.attachmentcraftingrep = playerData.metadata.attachmentcraftingrep or 0 @@ -367,7 +367,7 @@ function CreatePlayer(playerData, Offline) amount = tonumber(amount) --[[@as number]] if amount < 0 then return false end if not self.PlayerData.money[moneytype] then return false end - for _, mtype in pairs(config.Money.DontAllowMinus) do + for _, mtype in pairs(config.money.dontAllowMinus) do if mtype == moneytype then if (self.PlayerData.money[moneytype] - amount) < 0 then return false @@ -552,7 +552,7 @@ exports('DeleteCharacter', ForceDeleteCharacter) ---@return string | number UniqueVal unique value generated function GenerateUniqueIdentifier(type) local isUnique, uniqueId - local table = config.Player.IdentifierTypes[type] + local table = config.player.identifierTypes[type] repeat uniqueId = table.valueFunction() isUnique = FetchIsUnique(type, uniqueId) diff --git a/server/storage.lua b/server/storage.lua index 656eedecf..fc35e5c95 100644 --- a/server/storage.lua +++ b/server/storage.lua @@ -1,5 +1,5 @@ -local DefaultSpawn = require 'config.shared'.DefaultSpawn -local CharacterDataTables = require 'config.server'.CharacterDataTables +local defaultSpawn = require 'config.shared'.defaultSpawn +local characterDataTables = require 'config.server'.characterDataTables ---@class InsertBanRequest ---@field name string @@ -180,8 +180,8 @@ end local function convertPosition(position) local pos = json.decode(position) - local actualPos = (not pos.x or not pos.y or not pos.z) and DefaultSpawn or pos - return vec4(actualPos.x, actualPos.y, actualPos.z, actualPos.w or DefaultSpawn.w) + local actualPos = (not pos.x or not pos.y or not pos.z) and defaultSpawn or pos + return vec4(actualPos.x, actualPos.y, actualPos.z, actualPos.w or defaultSpawn.w) end ---@param license2 string @@ -225,14 +225,14 @@ function FetchPlayerEntity(citizenId) } or nil end ----deletes character data using the CharacterDataTables object in the config file +---deletes character data using the characterDataTables object in the config file ---@param citizenId string ---@return boolean success if operation is successful. function DeletePlayerEntity(citizenId) local query = "DELETE FROM %s WHERE %s = ?" local queries = {} - for tableName, columnName in pairs(CharacterDataTables) do + for tableName, columnName in pairs(characterDataTables) do queries[#queries + 1] = { query = query:format(tableName, columnName), values = {