Hi,
I’ve posted this in technical support but I figured it should be here.
I’m trying to figure out how to set player stats, such as shooting or stamina stat.
What I’ve tried so far is this:
StatSetInt(GetHashKey('STAMINA'), 100, true)
StatSetInt(GetHashKey('MP0_STAMINA'), 100, true)
StatSetInt(GetHashKey('MP1_STAMINA'), 100, true)
StatSetInt(GetHashKey('MP2_STAMINA'), 100, true)
StatSetInt(GetHashKey('MP3_STAMINA'), 100, true)
StatSetInt(GetHashKey('MP4_STAMINA'), 100, true)
StatSetInt(GetHashKey('MP5_STAMINA'), 100, true)
StatSetInt(GetHashKey('MP6_STAMINA'), 100, true)
StatSetInt(GetHashKey('SP0_STAMINA'), 100, true)
StatSetInt(GetHashKey('SP1_STAMINA'), 100, true)
StatSetInt(GetHashKey('SP2_STAMINA'), 100, true)
It doesn’t seem to work, character still runs out of stamina in 2 seconds. It seems to work if I set my character model to for example Michael, but I’d rather have it working for any character (currently have the default fivem-map-skater resource running).
How do I get this to work? I know how to set unlimited stamina but that’s not what I want.
StatSetInt(GetHashKey('SP0_STAMINA'), 100, true)
- Franklin (player_zero
)
StatSetInt(GetHashKey('SP1_STAMINA'), 100, true)
- Micheal (player_one
)
StatSetInt(GetHashKey('SP2_STAMINA'), 100, true)
- Trevor (player_two
)
[details= mp_m_freemode_01 & mp_f_freemode_01]StatSetInt(GetHashKey('MP0_STAMINA'), 100, true)
StatSetInt(GetHashKey('MP1_STAMINA'), 100, true)
StatSetInt(GetHashKey('MP2_STAMINA'), 100, true)
StatSetInt(GetHashKey('MP3_STAMINA'), 100, true)
StatSetInt(GetHashKey('MP4_STAMINA'), 100, true)
StatSetInt(GetHashKey('MP5_STAMINA'), 100, true)
StatSetInt(GetHashKey('MP6_STAMINA'), 100, true)
[/details]
I am not sure if the MP Stats will work, because I think they require the GTA Online Mode.
But to answer your question, if it works in FiveM, it just works with the two models I mentioned above!
1 Like
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
.
Ops, you are right, miswrote it 
I am glad you could resolve your Problem.