Skip to content

fix:(lib) - support colon syntax in __index method caching#41

Open
Krenuds wants to merge 1 commit intoCommunityOx:mainfrom
Krenuds:fix/lua-index-colon-syntax
Open

fix:(lib) - support colon syntax in __index method caching#41
Krenuds wants to merge 1 commit intoCommunityOx:mainfrom
Krenuds:fix/lua-index-colon-syntax

Conversation

@Krenuds
Copy link

@Krenuds Krenuds commented Mar 24, 2026

Summary

The __index metamethod in OxVehicle and OxPlayer (server + client) caches closures that capture self from the enclosing scope. When methods are called with : syntax (standard Lua OOP), Lua also passes self as the first implicit argument — causing all real arguments to shift by one position.

This silently corrupts any proxied method call that takes parameters: setStored, setProperties, setOwner, setGroup, setPlate, set, etc.

Example: vehicle:setStored("garage_name", true) arrives on the JS side as setStored(vehicleTable, "garage_name") — an object as the stored value, and the garage name string as the despawn boolean.

Fix

Detect whether : or . syntax was used by checking if the first argument is self, then handle both conventions correctly. Backward-compatible — existing . syntax callers are unaffected.

Files changed

  • lib/server/vehicle.lua
  • lib/server/player.lua
  • lib/client/player.lua

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant