Get/Set vehicle props
This commit is contained in:
1 parent
71aca51cb5
commit
33868c43c4
3 files changed
+93
No files matched your search
@@ -130,6 +130,37 @@ Framework.GetPlayerInventory = function()
|
|||||||
return playerData.inventory
|
return playerData.inventory
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will return the vehicle properties for the specified vehicle.
|
||||||
|
---@param vehicle number
|
||||||
|
---@return table
|
||||||
|
Framework.GetVehicleProperties = function(vehicle)
|
||||||
|
if not vehicle or not DoesEntityExist(vehicle) then return {} end
|
||||||
|
local vehicleProps = ESX.Game.GetVehicleProperties(vehicle)
|
||||||
|
return vehicleProps or {}
|
||||||
|
end
|
||||||
|
|
||||||
|
---This will set the vehicle properties for the specified vehicle.
|
||||||
|
---@param vehicle number
|
||||||
|
---@param properties table
|
||||||
|
---@return boolean
|
||||||
|
Framework.SetVehicleProperties = function(vehicle, properties)
|
||||||
|
if not vehicle or not DoesEntityExist(vehicle) then return false end
|
||||||
|
if not properties then return false end
|
||||||
|
if NetworkGetEntityIsNetworked(vehicle) then
|
||||||
|
local vehNetID = NetworkGetNetworkIdFromEntity(vehicle)
|
||||||
|
local entOwner = GetPlayerServerId(NetworkGetEntityOwner(vehNetID))
|
||||||
|
if entOwner ~= GetPlayerServerId(PlayerId()) then
|
||||||
|
NetworkRequestControlOfEntity(vehicle)
|
||||||
|
local count = 0
|
||||||
|
while not NetworkHasControlOfEntity(vehicle) and count < 3000 do
|
||||||
|
Wait(1)
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true, QBCore.Functions.SetVehicleProperties(vehicle, properties)
|
||||||
|
end
|
||||||
|
|
||||||
---This will get a players dead status.
|
---This will get a players dead status.
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Framework.GetIsPlayerDead = function()
|
Framework.GetIsPlayerDead = function()
|
||||||
|
|||||||
@@ -171,6 +171,37 @@ Framework.GetPlayerInventory = function()
|
|||||||
return items
|
return items
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will return the vehicle properties for the specified vehicle.
|
||||||
|
---@param vehicle number
|
||||||
|
---@return table
|
||||||
|
Framework.GetVehicleProperties = function(vehicle)
|
||||||
|
if not vehicle or not DoesEntityExist(vehicle) then return {} end
|
||||||
|
local vehicleProps = QBCore.Functions.GetVehicleProperties(vehicle)
|
||||||
|
return vehicleProps or {}
|
||||||
|
end
|
||||||
|
|
||||||
|
---This will set the vehicle properties for the specified vehicle.
|
||||||
|
---@param vehicle number
|
||||||
|
---@param properties table
|
||||||
|
---@return boolean
|
||||||
|
Framework.SetVehicleProperties = function(vehicle, properties)
|
||||||
|
if not vehicle or not DoesEntityExist(vehicle) then return false end
|
||||||
|
if not properties then return false end
|
||||||
|
if NetworkGetEntityIsNetworked(vehicle) then
|
||||||
|
local vehNetID = NetworkGetNetworkIdFromEntity(vehicle)
|
||||||
|
local entOwner = GetPlayerServerId(NetworkGetEntityOwner(vehNetID))
|
||||||
|
if entOwner ~= GetPlayerServerId(PlayerId()) then
|
||||||
|
NetworkRequestControlOfEntity(vehicle)
|
||||||
|
local count = 0
|
||||||
|
while not NetworkHasControlOfEntity(vehicle) and count < 3000 do
|
||||||
|
Wait(1)
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true, QBCore.Functions.SetVehicleProperties(vehicle, properties)
|
||||||
|
end
|
||||||
|
|
||||||
---This will get a players dead status.
|
---This will get a players dead status.
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Framework.GetIsPlayerDead = function()
|
Framework.GetIsPlayerDead = function()
|
||||||
|
|||||||
@@ -108,6 +108,37 @@ Framework.GetPlayerInventory = function()
|
|||||||
return Framework.GetPlayerData().items
|
return Framework.GetPlayerData().items
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will return the vehicle properties for the specified vehicle.
|
||||||
|
---@param vehicle number
|
||||||
|
---@return table
|
||||||
|
Framework.GetVehicleProperties = function(vehicle)
|
||||||
|
if not vehicle or not DoesEntityExist(vehicle) then return {} end
|
||||||
|
local vehicleProps = lib.getVehicleProperties(vehicle)
|
||||||
|
return vehicleProps or {}
|
||||||
|
end
|
||||||
|
|
||||||
|
---This will set the vehicle properties for the specified vehicle.
|
||||||
|
---@param vehicle number
|
||||||
|
---@param properties table
|
||||||
|
---@return boolean
|
||||||
|
Framework.SetVehicleProperties = function(vehicle, properties)
|
||||||
|
if not vehicle or not DoesEntityExist(vehicle) then return false end
|
||||||
|
if not properties then return false end
|
||||||
|
if NetworkGetEntityIsNetworked(vehicle) then
|
||||||
|
local vehNetID = NetworkGetNetworkIdFromEntity(vehicle)
|
||||||
|
local entOwner = GetPlayerServerId(NetworkGetEntityOwner(vehNetID))
|
||||||
|
if entOwner ~= GetPlayerServerId(PlayerId()) then
|
||||||
|
NetworkRequestControlOfEntity(vehicle)
|
||||||
|
local count = 0
|
||||||
|
while not NetworkHasControlOfEntity(vehicle) and count < 3000 do
|
||||||
|
Wait(1)
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true, lib.setVehicleProperties(vehicle, properties)
|
||||||
|
end
|
||||||
|
|
||||||
---This will return the item count for the specified item in the players inventory.
|
---This will return the item count for the specified item in the players inventory.
|
||||||
---@param item string
|
---@param item string
|
||||||
---@return number
|
---@return number
|
||||||
|
|||||||
Reference in new issue
Block a user