Scott
2/21/2017 - 10:20 PM

Change Player Ped

Change Player Ped

NPC.Model model = NPC.AvailableModels[index];

// Request the PedHash from the menu item selected.
var characterModel = new Model(model.Hash);
characterModel.Request(500);

// Check the model is valid
if (characterModel.IsInCdImage && characterModel.IsValid)
{
    // If the model isn't loaded, wait until it is
    while (!characterModel.IsLoaded) System.Threading.Thread.Sleep(100);

    // Set the player's model
    Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, characterModel.Hash);
    Debug.WriteLine("Changed model to: " + model.Hash);
    Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character.Handle);
}

// Delete the model from memory after using it.
characterModel.MarkAsNoLongerNeeded();
Debug.WriteLine("Delete model as not longer needed: " + model.Hash);