Game

Flags

Some game data is a set of on/off flags: which buttons a player holds, which parts of the HUD are hidden, whether an entity is on the ground. In a plugin such a set is an array of names:

function hideMoney(
player
: Player) {
player
.
hideHud
= ["money", "timer"]; // set exactly these
player
.
hideHud
.
push
("flashlight"); // add one
const
hidden
=
player
.
hideHud
.
includes
("money"); // check one
player
.
hideHud
=
player
.
hideHud
.
filter
((
f
) =>
f
!= "money"); // remove one
player
.
hideHud
= []; // clear all
const
jumping
=
player
.
buttons
.
includes
("jump");
const
onGround
=
player
.
flags
.
includes
("onGround");
console
.
log
(`${
hidden
} ${
jumping
} ${
onGround
}`);
}

The names are a closed list: the editor suggests them and rejects a typo with Type '"mony"' is not assignable to type 'HideHud'. Did you mean '"money"'?

  • Reading gives an array of the flags that are on, in a fixed order - not the order they were added in.
  • Assigning an array sets exactly those flags.
  • push turns one more flag on in the game at once.
  • To turn a flag off, assign a filtered array. pop, splice and the other array methods change only the array you hold, not the game.

Flag properties

PropertyOnNames
flagsEntityEntityFlag: "onGround", "client", "inWater", "fly", "ducking", "fakeClient", "frozen", "godMode", …
effectsEntityEffect: "noDraw", "dimLight", "brightLight", "muzzleFlash", …
buttons, oldButtonsEntityButton: "attack", "attack2", "jump", "duck", "forward", "back", "use", "reload", "score", …
weaponsEntityWeaponKind: "knife", "usp", "ak47", … - the weapons a player carries, as weapon.kind names them
buttonLast, buttonPressed, buttonReleasedPlayerButton: what was held the frame before, what was pressed and what was let go this frame
hideHud, hideHudSentPlayerHideHud: "weapons", "flashlight", "all", "health", "timer", "money", "crosshair", "observerCrosshair"
damageTypePlayerDamage: "fall", "burn", "freeze", "bullet", "blast", …
physicsFlagsPlayerPhysicsFlag: "onLadder", "onTrain", "onBarnacle", "ducking", "using", "observer"
weaponStateWeaponWeaponState: "uspSilenced", "glock18Burst", "m4a1Silenced", "eliteLeft", "famasBurst", "shieldDrawn"

The types are exported from @amxts/core, for a parameter of your own: function press(player: Player, button: Button). Admin rights are an array of names too: player.access, of the type Access (commands).

Assigning weapons changes only the list, not what the player carries: to give a weapon, player.give("weapon_ak47") (Players).

hideHud is what the game sends to the player's client on its next frame. To hide parts of the HUD at once, use player.screen.hideHud(["money"]) (Players).