Skip to content

Commit

Permalink
Merge branch 'main' into remove-import
Browse files Browse the repository at this point in the history
  • Loading branch information
Manason committed Nov 16, 2023
2 parents cef8a7a + 37a6d6b commit 95e11c2
Show file tree
Hide file tree
Showing 17 changed files with 119 additions and 123 deletions.
24 changes: 12 additions & 12 deletions client/character.lua
Original file line number Diff line number Diff line change
@@ -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`,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand All @@ -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)

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions client/discord.lua
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
4 changes: 2 additions & 2 deletions client/functions.lua
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions client/loops.lua
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
30 changes: 15 additions & 15 deletions config/client.lua
Original file line number Diff line number Diff line change
@@ -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),
Expand Down Expand Up @@ -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',
}
Expand Down
53 changes: 26 additions & 27 deletions config/server.lua
Original file line number Diff line number Diff line change
@@ -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<UniqueIdType, {valueFunction: function}>
IdentifierTypes = {
identifierTypes = {
citizenid = {
valueFunction = function()
return tostring(RandomLetter(3) .. RandomNumber(5)):upper()
Expand Down Expand Up @@ -61,7 +61,7 @@ return {
---@alias TableName string
---@alias ColumnName string
---@type table<TableName, ColumnName>
CharacterDataTables = {
characterDataTables = {
players = 'citizenid',
apartments = 'citizenid',
bank_accounts_new = 'id',
Expand All @@ -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
Expand All @@ -116,7 +115,7 @@ return {
},
},

GiveVehicleKeys = function(src, plate)
giveVehicleKeys = function(src, plate)
exports.qbx_vehiclekeys:GiveKeys(src, plate)
end
}
4 changes: 2 additions & 2 deletions config/shared.lua
Original file line number Diff line number Diff line change
@@ -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'
}
5 changes: 0 additions & 5 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,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'
}
Expand Down
8 changes: 5 additions & 3 deletions modules/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions server/character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit 95e11c2

Please sign in to comment.