How to set mp freemode model?

I tried this SetPlayerModel(PlayerPedId(), 'mp_f_freemode_01') , but it doesn’t work. Help please.

Hi @Mindslug,

The native SetPlayerModel requires the 2nd parameter to be of type Hash.

CURRENT

SetPlayerModel(PlayerId(), 'mp_f_freemode_01')

REPLACEMENT

SetPlayerModel(PlayerId(), GetHashKey("mp_f_freemode_01"))
1 Like

Also it should be PlayerId()
Final result:

SetPlayerModel(PlayerId(), GetHashKey("mp_f_freemode_01"))

or

SetPlayerModel(PlayerId(), `mp_f_freemode_01`))
3 Likes

my game crashes after that:

RegisterCommand("model", function()
    
	SetPlayerModel(PlayerId(), GetHashKey("mp_f_freemode_01"))
	
end)

image
Why?;(

There is a complete and short video explanation for your issue. Check it out.
You will find working code and how it works.

1 Like

Now the skin is just invisible, lol.


Code:

function setModel()

    local playerPed = PlayerPedId()
    local pedModel = GetHashKey("mp_f_freemode_01")

    Citizen.CreateThread(function() 

        RequestModel(pedModel)
        while not HasModelLoaded(pedModel) do
            Citizen.Wait(50)
        end
    
        if IsModelInCdimage(pedModel) and IsModelValid(pedModel) then
            SetPlayerModel(PlayerId(), pedModel)
            SetPedComponentVariation(playerPed, 0, 0, 0, 2) 
			SetPedComponentVariation(playerPed, 2, 11, 4, 2) 
			SetPedComponentVariation(playerPed, 4, 1, 5, 2) 
			SetPedComponentVariation(playerPed, 6, 1, 0, 2) 
			SetPedComponentVariation(playerPed, 11, 7, 2, 2)
        end

        

    end)

end


RegisterCommand("model", function(source, args, rawCommand)
        
    setModel()
        
end, false)

Does anyone have a solution for this?

@Mindslug

Try this:

RegisterCommand("model", function()
    set_model()
end, false)

function set_model()
    local freemode_model = GetHashKey("mp_m_freemode_01")

    if IsModelInCdimage(freemode_model) and IsModelValid(freemode_model) then
        RequestModel(freemode_model)
        while not HasModelLoaded(freemode_model) do
            Wait(50)
        end

        SetPlayerModel(PlayerId(), freemode_model)
        local player_ped = PlayerPedId()
        SetPedComponentVariation(player_ped, 0, 0, 0, 2)
        SetPedComponentVariation(player_ped, 2, 11, 4, 2)
        SetPedComponentVariation(player_ped, 4, 1, 5, 2)
        SetPedComponentVariation(player_ped, 6, 1, 0, 2)
        SetPedComponentVariation(player_ped, 11, 7, 2, 2)
    end
end

EDIT: Implemented @AvaN0x’s fix :slight_smile:

2 Likes

Ped is invisible again(

I edited @akeem’s code a bit:

RegisterCommand("model", function()
    set_model()
end, false)

function set_model()
    local freemode_model = GetHashKey("mp_m_freemode_01")

    if IsModelInCdimage(freemode_model) and IsModelValid(freemode_model) then
        RequestModel(freemode_model)
        while not HasModelLoaded(freemode_model) do
            Wait(50)
        end

        SetPlayerModel(PlayerId(), freemode_model)
        local player_ped = PlayerPedId()
        SetPedComponentVariation(player_ped, 0, 0, 0, 2)
        SetPedComponentVariation(player_ped, 2, 11, 4, 2)
        SetPedComponentVariation(player_ped, 4, 1, 5, 2)
        SetPedComponentVariation(player_ped, 6, 1, 0, 2)
        SetPedComponentVariation(player_ped, 11, 7, 2, 2)
    end
end

This one is tested and it works.
The issue was the the player_ped was accessed before changing it. When using SetPlayerModel the ped of the player will change.

3 Likes

Thanks, it really works, I noted your solution. I think it will help someone else.

1 Like