Skip to content

Commit

Permalink
Update GetPlayerAnimationFlags.md, added code sample and a warning (#874
Browse files Browse the repository at this point in the history
)

* 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 <microsoftuser3030@gmail.com>

* Update docs/scripting/functions/GetPlayerAnimationFlags.md

Co-authored-by: Adib <microsoftuser3030@gmail.com>

* Update docs/scripting/functions/GetPlayerAnimationFlags.md

Co-authored-by: Adib <microsoftuser3030@gmail.com>

* Update docs/scripting/functions/GetPlayerAnimationFlags.md

Co-authored-by: Adib <microsoftuser3030@gmail.com>

* Update docs/scripting/functions/GetPlayerAnimationFlags.md

Co-authored-by: Adib <microsoftuser3030@gmail.com>

* Removed duplicate notes.

---------

Co-authored-by: Adib <microsoftuser3030@gmail.com>
  • Loading branch information
m0b-x and adib-yg authored Feb 7, 2024
1 parent 66f2f8e commit fcee9da
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions docs/scripting/functions/GetPlayerAnimationFlags.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit fcee9da

Please sign in to comment.