Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Make ped follow player

Featured Replies

I've been trying to achieve this but it never ends up working well, the best code I get is below but the ped sometimes gets stuck in the ladders(he stays looking at the ladder) and the movement of the ped isn't smooth:

 


	Ped ped = new Ped(player.GetOffsetPosition(new Vector3(0f, -4f, 0f)));

	GameFiber.Sleep(1000);

	NativeFunction.CallByName<uint>("SET_PED_PATH_CAN_USE_CLIMBOVERS", ped, true);

	NativeFunction.CallByName<uint>("SET_PED_PATH_CAN_USE_LADDERS", ped, true);

	NativeFunction.CallByName<uint>("SET_PED_PATH_CAN_DROP_FROM_HEIGHT", ped, true);

	while (!Game.IsKeyDown(Keys.Y))

	{

	    GameFiber.Yield();

	    if (Vector3.Distance(player.Position, ped.Position) > 2.0f)

	    {

	        Vector3 p = player.GetOffsetPosition(new Vector3(0f, -1.25f, 0f));

	        Task t = ped.Tasks.FollowNavigationMeshToPosition(p, player.Heading, 1.0f);

	        while (Vector3.Distance(player.Position, ped.Position) > 5.0f)

	        {

	            GameFiber.Yield();

	            if (Vector3.Distance(p, ped.Position) < 2.0f) break;

	            if (t.Status == TaskStatus.Interrupted) break;

	            if (!t.IsActive) break;

	        }

	        ped.Tasks.Clear();

	    }

	}


 

 

 

Does anyone have a better code?

Edited by alexguirre

You need to provide some more WaitTime I think. Maybe you could try Sleeping the GameFiber for 500 ms or so every tick?

Also, although I'm not sure in this case, I don't recommend clearing the ped's tasks every time.

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

  • Author
4 hours ago, Albo1125 said:

You need to provide some more WaitTime I think. Maybe you could try Sleeping the GameFiber for 500 ms or so every tick?

Also, although I'm not sure in this case, I don't recommend clearing the ped's tasks every time.

That makes it work a bit smoother. When it gets stuck in front of a ladder if I clear the tasks and make the loop again he climbs it, I suppose it gets the vector3 in midair and the AI doesn't know what to do. I might check if the player is climbing d wait for it to finish and tanhen get the vector3 and assign the task.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.