The @Guard wrapper validates the player context with a truthy check on player.clientID. RageMP assigns id: 0 to the very first player who connects, and that flows through into clientID. Because 0 is falsy in JavaScript, the wrapper mistakes a real Player for an invalid context and throws before authorization runs.
Steps to reproduce
-
Define any guarded command:
@Command('test')
@Guard({ rank: 1 })
testCommand(player: Player) {
player.send('ok')
}
-
Start a fresh RageMP server
-
Join as the first player. Your clientID is 0
-
Run /test
Expected
The guard checks the player's principal/rank like any other player.
Actual
The wrapper throws before authorization runs:
Guard Security Error: Context is not a player
The
@Guardwrapper validates the player context with a truthy check onplayer.clientID. RageMP assignsid: 0to the very first player who connects, and that flows through intoclientID. Because0is falsy in JavaScript, the wrapper mistakes a real Player for an invalid context and throws before authorization runs.Steps to reproduce
Define any guarded command:
Start a fresh RageMP server
Join as the first player. Your
clientIDis0Run
/testExpected
The guard checks the player's principal/rank like any other player.
Actual
The wrapper throws before authorization runs: