Jump to content

[SOLVED] Can't Manipulate Ped after Invoking Animation


Rich

Recommended Posts

Goal:  Make ped flee when player is within X distance of the ped (before pursuit initiates).

Problem:  When I am within 50m of the ped, the animation stops but nothing else happens.  The ped becomes static.  They don't even flee when the pursuit initiates unless I knock them over.  I've spent a majority of the day troubleshooting and trying different solutions (including using natives, clearing ped tasks, and changing BlockPermanentEvents to false).  I would appreciate some guidance.

Edit:  It turns out that when I am within 50m the animation will stop and the ped is static, but when I leave the 50m area the ped will then flee.

Solution Edit:  I was able to fix my problem by creating a boolean for Fleeing and incorporating it into my if statement, similar to how the pursuit is managed.  I will leave this post here in case someone has a similar issue in the future.

 

OnCalloutAccepted()

if ((SpawnChance >= 5 && SpawnChance <= 9) && rand <= 50)
{
  Game.LogTrivial("Spawning Dealer ped outside of buyer vehicle");
  Dealer = new Ped("csb_ballasog", BuyerVehicle.GetOffsetPosition(new Vector3(1f, 0f, 0f)), BuyerVehicle.Heading + 90f);
  Dealer.RandomizeVariation(); // Random clothing
  Dealer.IsPersistent = true;
  Dealer.BlockPermanentEvents = true;
  Dealer.Tasks.PlayAnimation("amb@prop_human_bum_shopping_cart@male@idle_a", "idle_b", 1, AnimationFlags.Loop);
}

Process()

if (Game.LocalPlayer.Character.DistanceTo(Dealer.Position) < 50f)
{
  // Make dealer flee when player is within 50m

  //Game.DisplayHelp("Player within distance");
  Dealer.Tasks.Flee(Game.LocalPlayer.Character, 100, -1);
}

Process() fixed

if (!Fleeing && Game.LocalPlayer.Character.DistanceTo(Dealer.Position) < 50f)
{
  // Make dealer flee when player is within 50m

  //Game.DisplayHelp("Player within distance");
  Dealer.Tasks.Flee(Game.LocalPlayer.Character, 100, -1);
  Fleeing = true;
}

 

Edited by Rich

Released plugins

Automatic Siren Cutout | Rich's Police EnhancementsScene Manager | Rich Ambiance

Retired - No more updates

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...