Skip to content

fix(lib/server): use the instance source in player.getState - #255

Open
DoluTattoo wants to merge 1 commit into
overextended:mainfrom
DoluTattoo:fix/player-getstate-source
Open

fix(lib/server): use the instance source in player.getState#255
DoluTattoo wants to merge 1 commit into
overextended:mainfrom
DoluTattoo:fix/player-getstate-source

Conversation

@DoluTattoo

Copy link
Copy Markdown
Contributor

Problem

PlayerInterface.getState reads the global source instead of the instance property:

getState() {
  return Player(source).state;
}

Looks like an oversight: the constructor already assigns this.source, and every other method uses it. Whenever the instance is used outside of a handler for that same player, getState returns another player's state bag, and writes land on the wrong entity.

Fix

getState() {
  return Player(this.source).state;
}

lib/server/player.lua already does this, and lib/server/vehicle.ts resolves its state bag from this.entity.

Impact

No API change. Calls that were correct by accident keep working; the others now target the intended player.

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