PlayPlayerAnimation

From GT-MP
Jump to: navigation, search
PlayPlayerAnimation
Shared Function
Utilities-terminal.png Server-Side System-users.png Client-Side
Csharp.png C# Javascript.png JavaScript

Plays a specific animation for a player

Dialog-warning.png Changes for AnimationFlags in 0.1.7.*


Syntax

In C#
Server-Side Function

API.playPlayerAnimation(Client player, int flag, string animDict, string animName);
  • player: parameter input should be in Client type.
  • flag: parameter input should be in int type.
  • animDict: parameter input should be in string type.
  • animName: parameter input should be in string type.

In Javascript
Client-Side Function

API.playPlayerAnimation(LocalHandle player, string animDict, string animName, int flag, int duration = -1);
  • player: parameter input should be in LocalHandle type.
  • animDict: parameter input should be in string type.
  • animName: parameter input should be in string type.
  • flag: parameter input should be in int type.
  • duration: parameter input should be in int type. (Optional)
Dialog-warning.png player parameter will be added in version 0.1.7.

Animation flags before 0.1.7.*

These flags can be used with the flag parameter. To use them you need to cast the flags to an int.

[Flags]
public enum AnimationFlags
{
     Loop = 1 << 0,
     StopOnLastFrame = 1 << 1,
     OnlyAnimateUpperBody = 1 << 4,
     AllowPlayerControl = 1 << 5,
     Cancellable = 1 << 7
}

Animation flags after 0.1.7.*

These flags can be used with the flag parameter. To use them you need to cast the flags to an int.

[Flags]
    public enum AnimationFlag
    {
        None = 0,
        Loop = 1,
        StayInEndFrame = 2,
        UpperBodyOnly = 16,
        AllowRotation = 32,
        CancelableWithMovement = 128,
        RagdollOnCollision = 4194304
    }

Usage example(s)

Example before 0.1.7.* (this animation will cuff the player and allow him to walk while being cuffed):

API.playPlayerAnimation(player, (int)(AnimationFlags.Loop | AnimationFlags.OnlyAnimateUpperBody | AnimationFlags.AllowPlayerControl), "mp_arresting", "idle");


Example after 0.1.7.* (this animation will cuff the player):

API.playPlayerAnimation(player, (int)(AnimationFlag.Loop | AnimationFlag.UpperBodyOnly), "mp_arresting", "idle");


References