Quantcast

Jump to content

» «
Photo

Replacing Ped Model With Character Model?

1 reply to this topic
TrickyDickNixon1969
  • TrickyDickNixon1969

    The Truth

  • Members
  • Joined: 10 Dec 2017
  • United-States

#1

Posted 13 January 2018 - 07:06 PM Edited by TrickyDickNixon1969, 13 January 2018 - 07:06 PM.

Hi, I want to replace any ped model with an in-game (vanilla) model of Trevor for a project I'm working on.
So, how should I go about doing this? Can I save a custom player model using mods? Or is there a mod to duplicate the player model? Or is there even a way to spawn it through the rockstar editor? 

I'm kind of model illiterate, so

Thanks!


Bob_74
  • Bob_74

    Square Civilian

  • Members
  • Joined: 05 Jan 2018
  • None

#2

Posted 14 January 2018 - 02:37 PM

You cannot change a ped's model on the fly afaik (only the player's model).

So you need to delete NPCs and creates new ones with Trevor's model.

 

I gave it a quick try in C#

Model trevor = new Model(-1686040670);
foreach (Ped ped in World.GetAllPeds())
{
    if (ped.Model.Hash != trevor.Hash && !ped.IsPlayer && ped.IsHuman && !ped.IsPersistent && ped.IsVisible)
    {
        Ped trevorPed;
        Vector3 pos = ped.Position;
        float heading = ped.Heading;

        // If ped is in vehicle
        if (ped.CurrentVehicle != null)
        {
            Vehicle veh = ped.CurrentVehicle;
            VehicleSeat seat = ped.SeatIndex;
            Vector3 posUnderground = pos;
            posUnderground.Z = posUnderground.Z - 50.0f;
            ped.MarkAsNoLongerNeeded();
            ped.Delete();
            trevorPed = World.CreatePed(trevor, posUnderground, heading);
            trevorPed.SetIntoVehicle(veh, seat);
        }
        else
        {
            ped.MarkAsNoLongerNeeded();
            ped.Delete();
            trevorPed = World.CreatePed(trevor, pos, heading);
        }

        trevorPed.RandomizeOutfit(); // randomize the clothes
        Script.Yield();
    }
}

It works but I've got graphic glitches and a memory error when I do it too often, so there must be a cleaner way to do so.

 

If you want to use specific clothes, you'll need to use PED::SET_PED_COMPONENT_VARIATION (http://www.dev-c.com...62b14f48d29de80)

You can see how to use it here: http://gtaforums.com...903982-outifts/





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users