From fcee9da4f308c8912f7d0434565666b6fb22be22 Mon Sep 17 00:00:00 2001 From: Alex Zamfir <72597190+m0b-x@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:13:31 +0200 Subject: [PATCH] Update GetPlayerAnimationFlags.md, added code sample and a warning (#874) * Update GetPlayerAnimationFlags.md, added code sample and a warning * Added anim flag masks * Changed ambigous flag names * Fix typo * Updated freeze flag * Update docs/scripting/functions/GetPlayerAnimationFlags.md Co-authored-by: Adib * Update docs/scripting/functions/GetPlayerAnimationFlags.md Co-authored-by: Adib * Update docs/scripting/functions/GetPlayerAnimationFlags.md Co-authored-by: Adib * Update docs/scripting/functions/GetPlayerAnimationFlags.md Co-authored-by: Adib * Update docs/scripting/functions/GetPlayerAnimationFlags.md Co-authored-by: Adib * Removed duplicate notes. --------- Co-authored-by: Adib --- .../functions/GetPlayerAnimationFlags.md | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/docs/scripting/functions/GetPlayerAnimationFlags.md b/docs/scripting/functions/GetPlayerAnimationFlags.md index 7c2e25f3f..fac1c9d7e 100644 --- a/docs/scripting/functions/GetPlayerAnimationFlags.md +++ b/docs/scripting/functions/GetPlayerAnimationFlags.md @@ -16,14 +16,49 @@ Get the player animation flags. ## Returns -Returns the player animation flags as integer. +Returns the player animation flags as an integer. ## Examples +In order to get each flag separately, bit masking is used. + ```c -new flags = GetPlayerAnimationFlags(playerid); + +#define ANIM_FREEZE_FLAG 0b0000000000000100 +#define ANIM_LOCK_X_FLAG 0b0010000000000 +#define ANIM_LOCK_Y_FLAG 0b0001000000000 +#define ANIM_LOOP_FLAG 0b0000100000000 + +public OnPlayerCommandText(playerid, cmdtext[]) +{ + if (!strcmp(cmdtext, "/myanimflags")) + { + new messageString[128]; + new flags = GetPlayerAnimationFlags(playerid); + + new bool:freeze = (flags & ANIM_FREEZE_FLAG) != 0 ? true : false; + new bool:lockx = (flags & ANIM_LOCK_X_FLAG) != 0 ? true : false; + new bool:locky = (flags & ANIM_LOCK_Y_FLAG) != 0 ? true : false; + new bool:loop = (flags & ANIM_LOOP_FLAG) != 0 ? true : false; + + format(messageString, sizeof(messageString), "Your anim flags are: [freeze:%i] [lockx:%i] [locky:%i] [loop:%i]", freeze, lockx, locky, loop); + SendClientMessage(playerid, -1, messageString); + + return 1; + } + + return 0; +} ``` +## Notes + +:::warning + +If the player state is not on-foot, all returned animation flags are 0. + +::: + ## Related Functions - [ApplyAnimation](ApplyAnimation): Apply an animation to a player.