Open TomTheDark opened 1 year ago
I have the same problem, when a player enters a vehicle to pass a license, the vehicle flashes and is almost invisible to other players ..
Have you solved the problem, I'm sure it's a parameter detail or something?
this creates this error I have been looking for 3 days but no way to find it could be an id problem on the server side
3Warning: [entity] NETWORK_GET_NETWORK_ID_FROM_ENTITY: no net object for entity (script id xxxx) 3Warning: [entity] GetNetworkObject: no object by ID xxxx 3Warning: NETWORK_GET_NETWORK_ID_FROM_ENTITY: no net object for entity (script id xxxx)
so first of all, I apologize for my English which must not be easy to read because I use a translator. then I specify that I am not an expert but a beginner in the language, so after several days I found a solution by taking inspiration from what I was able to find,
so basically the problem would come from the fact that to avoid the unknown ID, the request for information which will go to the client side to spawn the VEH must go through the server.
so here is the method that I used which solves the problem for 95% of spawns (I have not yet tested with mass player)
step 1= we modify the original function to return the dataVEH on the server side => RegisterNetEvent('qb-dmv:client:startdriver', function() TriggerServerEvent('qb-dmv:server:startdriver') end)
step 2 = arrived on the server side => RegisterServerEvent('qb-dmv:server:startcdl')-- BMB PL client -> server = arriver , Renvoie -> client pour generer le veh model onesync AddEventHandler('qb-dmv:server:startcdl', function() local playerLocal = source -- ID du joueur source (côté serveur) -- Les données du véhicule que vous souhaitez transmettre côté client local vehData = { model = Config.VehicleModels.cdl, coords = Config.Location['spawn'], heading = Config.Location['spawn'].w }
-- Vous pouvez transmettre les données du véhicule au côté client en utilisant un événement
TriggerClientEvent('qb-dmv:startcdl_client', playerLocal, vehData)
end)
step 3 = return to key side to spawn vehicle with model verification => RegisterNetEvent('qb-dmv:startdriver_client') AddEventHandler('qb-dmv:startdriver_client', function(vehData)
print(vehData)
CurrentTest = 'drive'
DriveErrors = 0
LastCheckPoint = -1
CurrentCheckPoint = 0
IsAboveSpeedLimit = false
CurrentZoneType = 'residence'
local prevCoords = GetEntityCoords(PlayerPedId())
local vehicleModel = GetHashKey(vehData.model)
--BMB utiliser pour precharger le veh car venant de server
--sinon il est inconnus lors ud spawn
RequestModel(vehicleModel)
while not HasModelLoaded(vehicleModel) do
Citizen.Wait(0)
end
local vehicleCoords = vector3(vehData.coords.x, vehData.coords.y, vehData.coords.z)
local vehicleHeading = vehData.heading
local veh = CreateVehicle(vehicleModel, vehicleCoords.x, vehicleCoords.y, vehicleCoords.z, vehicleHeading, true, true)
TaskWarpPedIntoVehicle(PlayerPedId(), veh, -1)
exports['qb-sna-fuel']:SetFuel(veh, 100)
local plate = "AS" .. tostring(math.random(1000, 9999))
SetVehicleNumberPlateText(veh, plate)
SetEntityAsMissionEntity(veh, true, true)
SetEntityHeading(veh, vehicleHeading)
TriggerEvent('vehiclekeys:client:SetOwner', QBCore.Functions.GetPlate(veh))
TriggerServerEvent('qb-vehicletuning:server:SaveVehicleProps', QBCore.Functions.GetVehicleProperties(veh))
LastVehicleHealth = GetVehicleBodyHealth(veh)
CurrentVehicle = veh
TriggerEvent('qb-dmv:Notify', 'Vous passez l\'examen de conduite.', 3000, 'success', 'succes')
end)
there is probably another or even better way to do it but I only found this one for my part, if it can help someone
When people pass the drive test the vehicles are invisible and the people clipping in the ground but only for the other player not for the player inself.