Merge pull request #1062 from bfivem/main

refactor: small optimization
This commit is contained in:
Kakarot
2024-02-10 17:41:33 -05:00
committed by GitHub
4 changed files with 11 additions and 9 deletions
+1 -1
View File
@@ -120,7 +120,7 @@ end)
RegisterNetEvent('QBCore:Command:SpawnVehicle', function(vehName)
local ped = PlayerPedId()
local hash = GetHashKey(vehName)
local hash = joaat(vehName)
local veh = GetVehiclePedIsUsing(ped)
if not IsModelInCdimage(hash) then return end
RequestModel(hash)
+2 -2
View File
@@ -434,7 +434,7 @@ function QBCore.Functions.GetBoneDistance(entity, boneType, boneIndex)
end
function QBCore.Functions.AttachProp(ped, model, boneId, x, y, z, xR, yR, zR, vertex)
local modelHash = type(model) == 'string' and GetHashKey(model) or model
local modelHash = type(model) == 'string' and joaat(model) or model
local bone = GetPedBoneIndex(ped, boneId)
QBCore.Functions.LoadModel(modelHash)
local prop = CreateObject(modelHash, 1.0, 1.0, 1.0, 1, 1, 0)
@@ -447,7 +447,7 @@ end
function QBCore.Functions.SpawnVehicle(model, cb, coords, isnetworked, teleportInto)
local ped = PlayerPedId()
model = type(model) == 'string' and GetHashKey(model) or model
model = type(model) == 'string' and joaat(model) or model
if not IsModelInCdimage(model) then return end
if coords then
coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords
+2 -1
View File
@@ -306,8 +306,9 @@ end
QBCore.Functions.UpdateGang = UpdateGang
exports('UpdateGang', UpdateGang)
local resourceName = GetCurrentResourceName()
local function GetCoreVersion(InvokingResource)
local resourceVersion = GetResourceMetadata(GetCurrentResourceName(), 'version')
local resourceVersion = GetResourceMetadata(resourceName, 'version')
if InvokingResource and InvokingResource ~= '' then
print(('%s called qbcore version check: %s'):format(InvokingResource or 'Unknown Resource', resourceVersion))
end
+6 -5
View File
@@ -5,6 +5,7 @@ QBCore.Player = {}
-- Don't touch any of this unless you know what you are doing
-- Will cause major issues!
local resourceName = GetCurrentResourceName()
function QBCore.Player.Login(source, citizenid, newData)
if source and source ~= '' then
if citizenid then
@@ -31,7 +32,7 @@ function QBCore.Player.Login(source, citizenid, newData)
end
return true
else
QBCore.ShowError(GetCurrentResourceName(), 'ERROR QBCORE.PLAYER.LOGIN - NO SOURCE GIVEN!')
QBCore.ShowError(resourceName, 'ERROR QBCORE.PLAYER.LOGIN - NO SOURCE GIVEN!')
return false
end
end
@@ -520,9 +521,9 @@ function QBCore.Player.Save(source)
metadata = json.encode(PlayerData.metadata)
})
if GetResourceState('qb-inventory') ~= 'missing' then exports['qb-inventory']:SaveInventory(source) end
QBCore.ShowSuccess(GetCurrentResourceName(), PlayerData.name .. ' PLAYER SAVED!')
QBCore.ShowSuccess(resourceName, PlayerData.name .. ' PLAYER SAVED!')
else
QBCore.ShowError(GetCurrentResourceName(), 'ERROR QBCORE.PLAYER.SAVE - PLAYERDATA IS EMPTY!')
QBCore.ShowError(resourceName, 'ERROR QBCORE.PLAYER.SAVE - PLAYERDATA IS EMPTY!')
end
end
@@ -541,9 +542,9 @@ function QBCore.Player.SaveOffline(PlayerData)
metadata = json.encode(PlayerData.metadata)
})
if GetResourceState('qb-inventory') ~= 'missing' then exports['qb-inventory']:SaveInventory(PlayerData, true) end
QBCore.ShowSuccess(GetCurrentResourceName(), PlayerData.name .. ' OFFLINE PLAYER SAVED!')
QBCore.ShowSuccess(resourceName, PlayerData.name .. ' OFFLINE PLAYER SAVED!')
else
QBCore.ShowError(GetCurrentResourceName(), 'ERROR QBCORE.PLAYER.SAVEOFFLINE - PLAYERDATA IS EMPTY!')
QBCore.ShowError(resourceName, 'ERROR QBCORE.PLAYER.SAVEOFFLINE - PLAYERDATA IS EMPTY!')
end
end