113 lines
2.4 KiB
Lua
113 lines
2.4 KiB
Lua
if Config.Framework ~= "standalone" then return end
|
|
|
|
|
|
|
|
while not NetworkIsSessionStarted() do
|
|
Wait(500)
|
|
end
|
|
|
|
|
|
Citizen.CreateThread(function()
|
|
while not LoadedUI() do
|
|
Wait(500)
|
|
end
|
|
print("Framework loaded, loading phone data...")
|
|
TriggerServerEvent('codem-phone:server:LoadPhone')
|
|
end)
|
|
|
|
function ToggleDuty()
|
|
|
|
end
|
|
|
|
function ApplyVehicleMods(vehicle, vehicleData)
|
|
if type(vehicleData.mods) == "string" then
|
|
vehicleData.mods = json.decode(vehicleData.mods)
|
|
end
|
|
|
|
SetVehicleNumberPlateText(vehicle, vehicleData.plate)
|
|
|
|
if vehicleData.engine then
|
|
SetVehicleEngineHealth(vehicle, vehicleData.engine + 0.0)
|
|
end
|
|
|
|
if vehicleData.body then
|
|
SetVehicleBodyHealth(vehicle, vehicleData.body + 0.0)
|
|
end
|
|
end
|
|
|
|
function LoadModel(model)
|
|
model = type(model) == "number" and model or joaat(model)
|
|
|
|
RequestModel(model)
|
|
|
|
while not HasModelLoaded(model) do
|
|
Wait(0)
|
|
end
|
|
|
|
return model
|
|
end
|
|
|
|
function WaitForNetworkId(netId)
|
|
local timer = GetGameTimer() + 5000
|
|
|
|
while not NetworkDoesNetworkIdExist(netId) do
|
|
Wait(0)
|
|
|
|
if GetGameTimer() > timer then
|
|
return
|
|
end
|
|
end
|
|
|
|
timer = GetGameTimer() + 5000
|
|
|
|
while not DoesEntityExist(NetworkGetEntityFromNetworkId(netId)) do
|
|
Wait(0)
|
|
|
|
if GetGameTimer() > timer then
|
|
return
|
|
end
|
|
end
|
|
|
|
return NetworkGetEntityFromNetworkId(netId)
|
|
end
|
|
|
|
function CreateFrameworkVehicle(vehicleData, coords)
|
|
local hash = tonumber(vehicleData.hash)
|
|
|
|
if not hash then
|
|
return
|
|
end
|
|
|
|
local model = LoadModel(hash)
|
|
local vehicle = CreateVehicle(model, coords.x, coords.y, coords.z, 0.0, true, false)
|
|
|
|
SetVehicleOnGroundProperly(vehicle)
|
|
ApplyVehicleMods(vehicle, vehicleData)
|
|
SetModelAsNoLongerNeeded(model)
|
|
|
|
return vehicle
|
|
end
|
|
|
|
function TakeControlOfEntity(entity)
|
|
if NetworkHasControlOfEntity(entity) then
|
|
return true
|
|
end
|
|
|
|
local timer = GetGameTimer() + 5000
|
|
|
|
while not NetworkHasControlOfEntity(entity) and timer > GetGameTimer() do
|
|
NetworkRequestControlOfEntity(entity)
|
|
Wait(0)
|
|
end
|
|
|
|
return NetworkHasControlOfEntity(entity)
|
|
end
|
|
|
|
function GiveVehicleKey(vehicle, plate)
|
|
Config.GiveVehicleKey(vehicle, plate)
|
|
end
|
|
|
|
function CanPhoneOpen()
|
|
return true
|
|
end
|