You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I've spent several hours debugging a issue in my script, which boiled down to variable shadowing. My script used a global variable named Zones, and I encountered unexpected behaviors related to the creation and removal of zones using ox_lib's exports.
Discovery: When I renamed my script's global variable from Zones to JobZones, the erratic behavior was resolved. This led me to conclude that variable shadowing is occurring between my script and ox_lib. I used QBCore.Debug(Zones) and noticed there were both integer (1-5) and string (a,b,c,d,e from my script) keys in Zones.
Impact: While this might seem like a minor issue, it was HARD to diagnose. The collision was not immediately apparent until I looked into this file:
Describe the solution you'd like
I would suggest prefixing global variables or localizing when possible to help others avoid issues like this. I am not sure how widespread this practice is within the library.
I appreciate the work you guys put into these projects!
The text was updated successfully, but these errors were encountered:
Aside from some special cases I do try to avoid globals; obviously I can't remove existing ones as that would break some resources.
Regardless I localised a few globals to prevent shadowing, but still need to add them to _ENV.
Aside from some special cases I do try to avoid globals; obviously I can't remove existing ones as that would break some resources. Regardless I localised a few globals to prevent shadowing, but still need to add them to _ENV.
Is your feature request related to a problem? Please describe.
I've spent several hours debugging a issue in my script, which boiled down to variable shadowing. My script used a global variable named Zones, and I encountered unexpected behaviors related to the creation and removal of zones using ox_lib's exports.
Discovery: When I renamed my script's global variable from
Zones
toJobZones
, the erratic behavior was resolved. This led me to conclude that variable shadowing is occurring between my script and ox_lib. I used QBCore.Debug(Zones) and noticed there were both integer (1-5) and string (a,b,c,d,e from my script) keys inZones
.Impact: While this might seem like a minor issue, it was HARD to diagnose. The collision was not immediately apparent until I looked into this file:
ox_lib/imports/zones/client.lua
Line 18 in dda2e09
Describe the solution you'd like
I would suggest prefixing global variables or localizing when possible to help others avoid issues like this. I am not sure how widespread this practice is within the library.
I appreciate the work you guys put into these projects!
The text was updated successfully, but these errors were encountered: