Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vehicle performance modifications are not taking effect #2732

Open
JeanNeez opened this issue Aug 20, 2024 · 0 comments
Open

Vehicle performance modifications are not taking effect #2732

JeanNeez opened this issue Aug 20, 2024 · 0 comments
Labels
bug triage Needs a preliminary assessment to determine the urgency and required action

Comments

@JeanNeez
Copy link

JeanNeez commented Aug 20, 2024

What happened?

On our server, vehicles are spawned server-side using the CreateVehicle native function, and we request that the entity owner applies both visual and performance modifications. Visual modifications, such as bumpers, spoilers, colors, liveries, and others, are applied correctly. Performance modifications (engine, brakes, transmission, suspension, and turbo) also seem to be applied successfully. In all cases, the native function GetVehicleMod returns the expected values for these modifications. However, when driving the vehicle, we notice that its performance is significantly below expectations. Despite the modifications being present, they don't seem to have the intended effect on the vehicle's performance.

We've managed to work around this issue by creating a handler for the game event CEventNetworkPlayerEnteredVehicle, which reapplies the modifications when the player enters the vehicle and starts the engine. The implementation looks like this:

_AEH("gameEventTriggered", function(eventName, eventArgs)
    if eventName ~= "CEventNetworkPlayerEnteredVehicle" then return end
    if eventArgs[1] ~= 128 then return end
    if not eventSpamChecker(eventName) then return end
    while GetVehiclePedIsEntering(PlayerPedId()) > 0 do
        Wait(100)
    end
    if GetPedInVehicleSeat(eventArgs[2], -1) ~= PlayerPedId() then return end
    repeat
        Wait(0)
        if not DoesEntityExist(eventArgs[2]) or GetVehiclePedIsUsing(PlayerPedId()) ~= eventArgs[2] then return end
    until GetIsVehicleEngineRunning(eventArgs[2])
    SetVehicleMod(eventArgs[2], 11, GetVehicleMod(eventArgs[2], 11)) -- Engine
    SetVehicleMod(eventArgs[2], 12, GetVehicleMod(eventArgs[2], 12)) -- Brakes
    SetVehicleMod(eventArgs[2], 13, GetVehicleMod(eventArgs[2], 13)) -- Transmission
    SetVehicleMod(eventArgs[2], 15, GetVehicleMod(eventArgs[2], 15)) -- Suspension
    SetVehicleMod(eventArgs[2], 16, GetVehicleMod(eventArgs[2], 16)) -- Armor
    ToggleVehicleMod(eventArgs[2], 18, IsToggleModOn(eventArgs[2], 18)) -- Turbo
end)

Without reapply modifications:
https://drive.google.com/file/d/1xlRDZ6WQ-RKeZt6fhAvm0GYQJ_y1cipA/view?usp=sharing

Reapplying modifications:
https://drive.google.com/file/d/16xkps8NmFiL-scZvjHUXa0LX4BB_DnNm/view?usp=sharing

This ensures that the vehicle's performance modifications are properly applied when the player is inside the vehicle and ready to drive, effectively resolving the issue and restoring the vehicle's expected performance.

Expected result

Performance modifications should take effect on the vehicle when set.

Reproduction steps

  1. Spawn server-side vehicle using CreateVehicle
  2. Apply performance modifications client-side:
    SetVehicleMod(vehicle, 11, 3) -- Engine
    SetVehicleMod(vehicle, 12, 2) -- Brakes
    SetVehicleMod(vehicle, 13, 2) -- Transmission
    SetVehicleMod(vehicle, 15, 3) -- Suspension
    SetVehicleMod(vehicle, 16, 4) -- Armor
    ToggleVehicleMod(vehicle, 18, true) -- Turbo
  1. Take a drive
  2. Reapply performance modifications once you're inside the vehicle
  3. Take another drive

Importancy

There's a workaround

Area(s)

FiveM

Specific version(s)

FiveM 9517 canary, Server 9404 windows

Additional information

No response

@JeanNeez JeanNeez added bug triage Needs a preliminary assessment to determine the urgency and required action labels Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Needs a preliminary assessment to determine the urgency and required action
Projects
None yet
Development

No branches or pull requests

1 participant