[FREE] Alf Carkeys || The ultimate Vehicle system

Do you have any Errors?

For the Mission you can give the player the Key and after the Mission you can use the Server-Event "Alf-Carkeys:deleteKeyAll" to Delete every key with the Plate.

Hey ! Really nice job, when we enter a vehicle, even if engine is running, it turns it off.

Can we keep the motor state as it was when we entered the vehicle ?

I guess it’s in the client, around this code but i’m not sure :slight_smile: :

Thanks for your time

RegisterNetEvent('Alf-Carkeys:ToggleEngine')
AddEventHandler('Alf-Carkeys:ToggleEngine', function()
    local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
    if GetIsVehicleEngineRunning(vehicle) == false then
        **SetVehicleEngineOn(vehicle, true, false, true)**
        TriggerServerEvent('Alf-Carkeys:server:syncVehicle', NetworkGetNetworkIdFromEntity(vehicle), true)
		TriggerEvent('esx:showNotification', 'Moteur ~g~allumé')
        engine[vehicle] = true
    else
        **SetVehicleEngineOn(vehicle, false, false, true)**
        TriggerServerEvent('Alf-Carkeys:server:syncVehicle', NetworkGetNetworkIdFromEntity(vehicle), false)
		TriggerEvent('esx:showNotification', 'Moteur ~r~éteint')
        engine[vehicle] = false
    end
end)

The Engine state should be safe when you Toggle the Engine normally with the function and the function will be triggered when you use the key or start it via the menu

Try to steal an NPC car while the engine is on, when you go in, the engine turns off

Yep same here. i’m trying to fix that (without succes atm), cause i prefer that the Engine stay ON when stealing a car … :confused:

Yep, I tried to look into the code too, didfnt find a fix for now.

And when you give your key to an other player, it works in the database, but the game won’t let you use i.
I gave my key to a friend, I lost it in my Key menu, and he didn’t have it too. Weird

It only syncs the Engine from Vehicles that will be turned on by other Players

Well, maybe, but we are telling you that it’s not really working as intended, as NPC Engine turns off when we get in the vehicle :sweat_smile:

To Be honest, it’s not really usable like this if the NPC cars turn Engine OFF when we jump into them …

Alfons I fixed it, and made a pull request on Github.

1 Like

Tanks !!! awesome