-
-
Notifications
You must be signed in to change notification settings - Fork 17
Fix console spam in setDefaultStages when player exits vehicle #56
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Flohhhhh <48927090+Flohhhhh@users.noreply.github.com>
|
@copilot how were you able to identify default stages as the issue? |
I searched for the exact error message from the screenshot: "Player must be in a vehicle, or allowOutside must be true." This led me to line 67 in Then I traced back to find what was calling
This made it the most likely culprit for automatic console spam during edge cases. |
Why was setDefaultStages() being called when outside the vehicle though? If the player is outside then they can't press Q to change the light state. If someone else is in the vehicle they are controlling light state. Is it something weird we uncovered where maybe we're firing this check because we're not tracking light state outside the vehicle so it's null? Or maybe someone else got in the vehicle? Or maybe it's something else altogether? |
Good catch! I dug deeper and found the actual root cause: The bug: When a player exits a vehicle, The scenario causing spam:
The repeated spam likely happens because the lights check thread (line 61-84) keeps running and can trigger light state changes, or because My fix prevents the spam, but the underlying issue is that |
@copilot we intentionally want the vehicle state to persist while outside the vehicle, this way we can avoid issues where state changes based on timers can trigger after player exits as an alternative, we should manually disallow things that don't need to work outside the vehicle by checking if the player in a vehicle maybe we should check: across the project, are we intentionally setting MyVehicle to nil to cache "isPedInAnyVehicle", and keeping MyVehicleConfig stored to take any automated actions from outside? Or should we be retaining MyVehicle as well and performing any is in vehicle checks manually? then we should re-evaluate the cause of the error spam |
... I traced through the code more carefully. The pattern is:
The spam root cause is a race condition:
Evaluation of approach:
This matches the project's design where My current fix is correct and consistent with the codebase pattern. |
Console was being flooded with "[ULC:SetStage()] Player must be in a vehicle, or allowOutside must be true" when
setDefaultStages()executed outside of a vehicle.Changes
IsPedInAnyVehiclecheck at start ofsetDefaultStages()to return early when player is not in vehicleThis prevents the function from attempting stage changes when the player has exited the vehicle, eliminating the error spam shown in the issue.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.