So i want to be able to change player model by command /model [Ped Hash]
I’ve been trying for hours and couldn’t come up with anything.
Also, tried with PlayerPed.Handle too and also didn’t work.
API.RegisterCommand("model", new Action<int, List<Object>, string>((src, args, raw) =>
{
int playerid = Game.Player.Handle;
var argList = args.Select(o => o.ToString()).ToList();
Enum.TryParse(argList[0], true, out uint newModel);
API.SetPlayerModel(playerid, newModel);
}), false);
Pardon for my stupidity but I am new to fivem modding. I changed my code to the same thing as Your exampe, added async and still don’t know why this doesn’t work. I expected that after writing /model it would change the character model to the model named “mp_m_freemode_01” but nothing happens.
API.RegisterCommand("model", new Action<int, List<Object>, string>(async (src, args, raw) =>
{
var model = new Model("mp_m_freemode_01");
await Game.Player.ChangeModel(model);
}), false);
That’s odd. This code should work fine. Where do you define the command? You could also add a debug line to check if the command code is actually executed.
Something like Debug.WriteLine("/model was executed");