About this vehicle spawn snippet


#1

Hey guys,

I’m new to fiveM and lua scripting and was studying some codes snippets like this one:

AddEventHandler('VehicleSpawn', function(vehicleName)
    local myPed = GetPlayerPed(-1)
    local player = PlayerId()
    local vehicle = GetHashKey(vehicleName)

    RequestModel(vehicle)

    while not HasModelLoaded(vehicle) do
        Wait(1)
    end

    local coords = GetOffsetFromEntityInWorldCoords(myPed, 0, 5.0, 0)
    local spawned_vehcile = CreateVehicle(vehicle, coords, GetEntityHeading(myPed), true, false)
    SetVehicleOnGroundProperly(spawned_vehcile)
    SetModelAsNoLongerNeeded(vehicle)
    Citizen.InvokeNative(0xB736A491E64A32CF,Citizen.PointerValueIntInitialized(spawned_vehcile))
end)

I was able to understand all the code except for this line:

Citizen.InvokeNative(0xB736A491E64A32CF,Citizen.PointerValueIntInitialized(spawned_vehcile))

This line invoke a native function for GTA? or FiveM? What does that hex number mean? What does this native function do?


#2

That line isn’t even needed anymore since a year, it’s equivalent to

SetVehicleAsNoLongerNeeded(spawned_vehcile)

… and a lot of this code actually seems to be using ‘old’ methods, and even has a typo :confused:


#3

Oh boy… thanks for your answer.
Looking your answer and at natives GTA V function (http://www.dev-c.com/nativedb/func/info/b736a491e64a32cf) I get it. You really helped me. Ty.