I’m confused about the use of baseevents:leftVehicle
I want to compare the vehicle just exited to a known vehicle name. I found this for the GetHashKey function:
If currentVehicle is the handle to the instance of the vehicle as shown on the fivem doco page
Why do I get this when calling GetEntityModel(currentVehicle) ?
cfx> [ c-scripting-core] InvokeNative: execution failed: Tried to access invalid entity: 252674
This is my event handler
RegisterNetEvent('baseevents:leftVehicle', function(currentVehicle, currentSeat, vehicleDisplayName)
if whitelistedVehicle(currentVehicle) then
TriggerClientEvent('qb-taxi:client:leftVehicle', source)
end
end)
and the function call to compare the vehicle
local function whitelistedVehicle(veh)
local retval = false
for i = 1, #Config.AllowedVehicles, 1 do
if veh == GetHashKey(Config.AllowedVehicles[i].model) then
retval = true
end
end
if veh == GetHashKey("dynasty") then
retval = true
end
return retval
end
Interestingly, this first and secon numbers here are the “handles” if I display when leaving and entering, but the third one is the result of a call to GetVehiclePedIsIn(…)
I just need to know how to translate the incoming veh value to something that can be compared to the GetHashKey(Config.AllowedVehicles[i].model)
call.