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

Sync vehicle nitro state for nearby players also when it is disabled by setVehicleNitroActivated #2726

Open
1 task done
C0DELEVEL opened this issue Aug 31, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@C0DELEVEL
Copy link

Is your feature request related to a problem? Please describe.

Currently, when nitro in a vehicle is activated (by button or by setVehicleNitroActivated function), this information is synchronized to other players. However, the moment we call setVehicleNitroActivated(vehicle, false) in the driver (which is syncer) - nitro will be disabled only for the driver (as localPlayer which executed this function), for other players it will still be active and cause a lot of desynchronization (acceleration is greater than on syncer side).

Describe the solution you'd like

Synchronize the status of nitro according to the current status of syncer (driver).

Describe alternatives you've considered

Currently, you have to work around this with a script, e.g. manually synchronizing nitro state (mainly off, as on by key is synced correctly) - driver -> server -> players nearby

Additional context

The problem mainly relates to the implementation of nitro on the button - hold = on, release = off. Sample script code that turns off the nitro when you release the button:

function toggleNOS(btn, state)
local veh = getPedOccupiedVehicle(localPlayer)
if veh and getVehicleController(veh) == localPlayer then
if isVehicleNitroActivated(veh) then
setVehicleNitroActivated (veh, false) -- <- This should be synced with nearby players, as it is when we set it to true.
end
end
end
bindKey("vehicle_fire", "up", toggleNOS)

Security Policy

  • I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.
@C0DELEVEL C0DELEVEL added the enhancement New feature or request label Aug 31, 2022
@Proxy-99
Copy link
Contributor

Proxy-99 commented Sep 9, 2024

This should fix the issue #3706

@C0DELEVEL
Copy link
Author

C0DELEVEL commented Sep 9, 2024

This should fix the issue #3706

@Proxy-99 Thank you for your contribution, but I don't think this is a good solution (#3706) to this issue. It is useful in some cases, but not necessarily in the one I reported.

Why? Your solution has 2 drawbacks:

  • It requires serverside, while the state of vehicles and nitro are synchronized from clientside
  • Such information is sent to all players on the server, which is a waste of cpu/bandwith (why player A on dim 1 need to know that vehicle on dim 900 has the nitro activated/deactivated?)

My suggestion was to improve the synchronization packets so that it works like turning on nitro on clientside.

  1. Pressing LPM to turn on nitro -> sends packet to nearby players about active nitro in car
  2. Depressing LPM to disable nitro (nitro is turned off clientside via setVehicleNitroActivated) -> sends an analogous packet to players nearby with disabled nitro status in the car.

Currently, the logic in the MTA only works halfway - a packet is sent about the activation of nitro, but not about its deactivation.

@Proxy-99
Copy link
Contributor

Proxy-99 commented Sep 9, 2024

maybe I should add argument for dimension, if dimension not supplied a packet will be sent to all, so could be optimized a bit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants