-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.lua
More file actions
43 lines (39 loc) · 2.01 KB
/
client.lua
File metadata and controls
43 lines (39 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
local QBCore = exports['qb-core']:GetCoreObject()
local despawnedVehicles = {}
RegisterNetEvent('QBCore:Client:LeftVehicle', function(data)
if data.vehicle == nil or data.plate == nil then return end
local plate = data.plate
local vehCoords = GetEntityCoords(data.vehicle)
local vehHeading = GetEntityHeading(data.vehicle)
local vehModel = GetEntityModel(data.vehicle)
local vehProperties = QBCore.Functions.GetVehicleProperties(data.vehicle)
TriggerServerEvent('Ogi-NoDespawn:Server:AddVehicleNoDespawn', plate, vehProperties, vehCoords, vehModel, NetworkGetNetworkIdFromEntity(data.vehicle), vehHeading)
end)
RegisterNetEvent('Ogi-NoDespawn:Client:UpdateDespawnedVehicle', function(vehProps, vehModel, vehPlate, vehCoords, vehHeading)
Citizen.CreateThread(function()
QBCore.Functions.TriggerCallback('QBCore:Server:SpawnVehicle', function(netId)
local veh = NetToVeh(netId)
if DoesEntityExist(veh) then
NetworkRequestControlOfEntity(veh)
local timeout = 2000
while timeout > 0 and not NetworkHasControlOfEntity(veh) do
Wait(100)
timeout = timeout - 100
end
SetVehicleHasBeenOwnedByPlayer(veh, true)
SetEntityAsMissionEntity(veh, true, true)
SetVehicleIsStolen(veh, false)
SetVehicleIsWanted(veh, false)
SetVehRadioStation(veh, 'OFF')
SetNetworkIdCanMigrate(netId, true)
SetVehicleNumberPlateText(veh, vehPlate)
SetEntityHeading(veh, vehHeading)
while (NetworkGetEntityOwner(veh) ~= NetworkPlayerIdToInt()) do
Wait(500)
end
QBCore.Functions.SetVehicleProperties(veh, vehProps)
TriggerServerEvent('Ogi-NoDespawn:Server:AddVehicleNoDespawn', vehPlate, vehProps, vehCoords, vehModel, netId, vehHeading)
end
end, vehModel, vehCoords, false)
end)
end)