[Resolved] Setting stats with StatSetInt

Thanks for your reply.

Setting the player’s model to one of the MP models and then setting the stats didn’t seem to work. However, first setting the player’s model to one of the Singleplayer characters models, setting stats and then switching back to whatever model seemed to work.

Below the code that worked, in case anyone else needs this. I tested it with a few models. It seemed to carry Michael’s stats on to the next model.

Citizen.CreateThread(function()
    -- Request Michael's model
    local hash = GetHashKey('player_zero')
    while not HasModelLoaded(hash) do
        RequestModel(hash)
        Citizen.Wait(0)
    end

    -- Set the player's model to Michael's model
    SetPlayerModel(PlayerId(), hash)
    SetModelAsNoLongerNeeded(hash)

    -- Set Michael's stats
    StatSetInt(GetHashKey('SP0_STAMINA'), 100, true)
    StatSetInt(GetHashKey('SP0_LUNG_CAPACITY'), 100, true)

    -- Now request any other model
    hash = GetHashKey('a_m_y_skater_02') -- mp_f_freemode_01
    while not HasModelLoaded(hash) do
        RequestModel(hash)
        Citizen.Wait(0)
    end

    -- Set the player's model again
    SetPlayerModel(PlayerId(), hash)
    SetModelAsNoLongerNeeded(hash)
    SetPedRandomComponentVariation(GetPlayerPed(-1), true)
end)

Also, it seems player_zero is Michael instead of Franklin :slight_smile:.