Log in to reply
 

A script to trigger a specific animation in nearby peds



  • I know it's possible, the emotes mod and join me mod basically do what I'm talking about.



  • Code:
    if (e.KeyCode == Keys.E)
    {

    Native.Function.Call(Native.Hash.REQUEST_ANIM_DICT, "anim_dict_here");
    Wait(50);
    Ped[] NearbyPeds = World.GetNearbyPeds(Game.Player.Character,20f);
    foreach(Ped p in NearbyPeds)
    {
    p.Task.ClearAllTasks();
    p.Task.PlayAnimation(p,"ANIM_NAME","ANIM_DICT",8.0 , 8.0*-1 , -1 , 0 , 0 , false, false, false);
    }

    }


    A lot of the variables in the PlayAnimation command are unknown, so if you want to figure out the different animation speeds and types, here's a link to GTA X Scripting

    Animation dictionary list: Animation Dictionary



  • @Kwang4 Thanks for the input! But I tried this and couldn't get it to work. Not sure what's wrong. This is the animation I'd like the nearby ped to play, and here's is exactly how I have the code, in a .cs file:

    using GTA;
    using GTA.Math;
    using System;
    using GTA.Native;
    using System.IO;
    using System.Windows.Forms;

    public

    if (e.KeyCode == Keys.E)
    {

    Native.Function.Call(Native.Hash.REQUEST_ANIM_DICT, "missprologueig_1");
    Wait(50);
    Ped[] NearbyPeds = World.GetNearbyPeds(Game.Player.Character,20f);
    for each(Ped p in NearbyPeds)
    {
    p.Task.ClearAllTasks();
    p.Task.PlayAnimation(p,"idle_loop_malehostage02","missprologueig_1",8.0 , 8.0*-1 , -1 , 0 , 0 , false, false, false);
    }

    }



  • It would be best to compile the code (such as with Visual Studio) so that you can know if it is correct C# code or not before trying it out in GTA. That is not correct C# code. Here is a fixed up version, which I have no idea if works or not:

    using GTA;
    using GTA.Math;
    using GTA.Native;
    using System;
    using System.IO;
    using System.Windows.Forms;
    
    public class AnimMod : Script
    {
    	public AnimMod()
    	{
    		KeyDown += AnimMod_KeyDown;
    	}
    	
    	private void AnimMod_KeyDown(object sender, KeyEventArgs e)
    	{
    		if (e.KeyCode == Keys.E)
    		{
    			Native.Function.Call(Native.Hash.REQUEST_ANIM_DICT, "missprologueig_1");
    			
    			Wait(50);
    			
    			Ped[] NearbyPeds = World.GetNearbyPeds(Game.Player.Character, 20f);
    			
    			foreach (Ped p in NearbyPeds)
    			{
    				p.Task.ClearAllTasks();
    				p.Task.PlayAnimation(p, "idle_loop_malehostage02", "missprologueig_1", 8.0, 8.0 * -1, -1, 0, 0, false, false, false);
    			}
    		}
    	}
    }

Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.