fivem icon indicating copy to clipboard operation
fivem copied to clipboard

FiveM - (6420) CreatePed: Error executing native [Custom resources]

Open mikk809h opened this issue 2 years ago • 13 comments

I am currently running a FiveM server with QBCore and encountering an issue with the "CreatePed" native. Whenever players load in through the qb-multicharacter resource and select a character this error shows up (attached image) on client-side. If the player ignores this error and attempts to join the world anyway, the game crashes.

This is only an issue when a specific streamable resource is loaded (clothes resource), but anyhow it is still an error I would like to be able to determine the root cause of, so I can fix it properly.

Interestingly, this error does not occur if a player chooses a different character and then switches back to the original "problematic" ped. In such cases, the ped loads without any issues, and gameplay continues smoothly.

The problem seems to be specifically associated with the initial loading of the affected model. Any guidance or suggestions for resolving this issue would be greatly appreciated.

RequestModel(model) --# load custom model
while not HasModelLoaded(model) do
    Wait(0)
end
--# Model is loaded successfully
ped = CreatePed(2, model, -813.5, 176.22, 75.76, 0.0, false, true)
--# Crashes on CreatePed ^ even though the requested model was loaded.

image

Could you please help me better understand and address the root cause of the issue? Your assistance is greatly appreciated.

mikk809h avatar Apr 29 '23 23:04 mikk809h

assuming model is a string in the docs the second param asks for a hash not a string image then is good practice to SetModelAsNoLongerNeeded

outsider31000 avatar Apr 30 '23 00:04 outsider31000

assuming model is a string in the docs the second param asks for a hash not a string image then is good practice to SetModelAsNoLongerNeeded

I'm pretty sure it doesn't matter in this case, anything that has hash as an argument has a function automatically converts strings to the hash (at least in Lua)

local function _ch(hash)
	if g.type(hash) == 'string' then
		return g.GetHashKey(hash)
	end

	return hash
end
function Global.CreatePed(pedType, modelHash, x, y, z, heading, isNetwork, bScriptHostPed)
	return _in(0xD49F9B0955C367DE, pedType, _ch(modelHash), x, y, z, heading, isNetwork, bScriptHostPed, _ri)
end

As for the crash I couldn't tell you exactly what it is, it would be best to see if somehow the model you're crashing on is improperly setup.

AvarianKnight avatar Apr 30 '23 01:04 AvarianKnight

Thanks for your feedback,

The 'model' variable in this case is indeed a hash key for the given model, not a string - and it works as intended with this specific model disabled.

I do not have much knowledge about creating models, and I assume there is something wrong with it: However, it is odd that it works as intended after another model (default character model) has been created.

I will provide four scenarios each explaining different perspectives of the issue:

Successful scenario (with offending model running as a resource)

  1. Select empty character on select screen
  2. Character loads the default ped as expected
  3. Join world with selected character

Successful scenario (without offending model running as a resource)

  1. Select empty character on select screen
  2. Character loads the default ped as expected
  3. Join world with selected character

Failed / successful scenario (with offending model running as a resource)

  1. Select character with any non-default model. (This model does not need to be from the offending resource)
  2. Script error in console. -- The failure as in Original Post
  3. Select a default character with default ped
  4. No script error, and default ped loads
  5. Select the custom model-character again
  6. No error and custom model loads as intended

Failed scenario (with offending model running as a resource)

  1. Select character with any non-default model. (This model does not need to be from the offending resource)
  2. Script error in console. (attached in Original Post)
  3. Join world anyway: Game crash

I hope this information can help further, and thanks again for your replies.

mikk809h avatar Apr 30 '23 07:04 mikk809h

I don't see this 'specific streamable resource' provided here. Did you forget to attach it?

blattersturm avatar May 02 '23 03:05 blattersturm

I don't see this 'specific streamable resource' provided here. Did you forget to attach it?

Ah, sorry; I did not intend to attach the resource as it (in the scenarios provided) doesn't seem to be the root cause for the crashes, as the non-default characters doesn't use the model/clothes from this resouce.

I will attach it here to hopefully allow further insight into the issue. erroneous-resource.zip

mikk809h avatar May 02 '23 09:05 mikk809h

I don't have time to actually look into this myself yet, but a quick note:

as the non-default characters doesn't use the model/clothes from this resouce

When any script requests mp_m_freemode_01, all metadata files that are registered as a SHOP_PED_APPAREL_META_FILE for that model get loaded as well, so the issue might be related to something acting up about the creature metadata file here.

There's a lot of conflicting information about creating such metadata files and some of it is weirdly gatekept, and given the complexity I wish some of it could be abstracted away somewhen. 😕

blattersturm avatar May 02 '23 10:05 blattersturm

I am currently running a FiveM server with QBCore and encountering an issue with the "CreatePed" native. Whenever players load in through the qb-multicharacter resource and select a character this error shows up (attached image) on client-side. If the player ignores this error and attempts to join the world anyway, the game crashes.

This is only an issue when a specific streamable resource is loaded (clothes resource), but anyhow it is still an error I would like to be able to determine the root cause of, so I can fix it properly.

Interestingly, this error does not occur if a player chooses a different character and then switches back to the original "problematic" ped. In such cases, the ped loads without any issues, and gameplay continues smoothly.

The problem seems to be specifically associated with the initial loading of the affected model. Any guidance or suggestions for resolving this issue would be greatly appreciated.

RequestModel(model) --# load custom model
while not HasModelLoaded(model) do
    Wait(0)
end
--# Model is loaded successfully
ped = CreatePed(2, model, -813.5, 176.22, 75.76, 0.0, false, true)
--# Crashes on CreatePed ^ even though the requested model was loaded.

image

Could you please help me better understand and address the root cause of the issue? Your assistance is greatly appreciated.

Have you fixed this yet ?

Kaizet1 avatar Dec 16 '23 15:12 Kaizet1

I am having this same problem, and I think it has something to do with the total number of ped meta files in the server. In my case this is happening when we have over 8 addon metas similar to the erroneous resource shared by the OP. I know for a fact that those models are not really the problem, but it feels like they are not loading fast enough for the qb-multicharacter. The Gods of Ped Designs, Respond lol......

Ezio121 avatar Dec 26 '23 08:12 Ezio121

Solution : Just do a RequestModel(mp_m_freemode_01),RequestModel(mp_f_freemode_01) and then a loop for Has_Model_Loaded() for the same, before calling the open menu in the qb-multicharacter has fixed the error and the crashes for me. Ping me if u need detailed code for the solution. But to the people on this thread I know they already know how to code it themselves.

Ezio121 avatar Jan 02 '24 13:01 Ezio121

Solution : Just do a RequestModel(mp_m_freemode_01),RequestModel(mp_f_freemode_01) and then a loop for Has_Model_Loaded() for the same, before calling the open menu in the qb-multicharacter has fixed the error and the crashes for me. Ping me if u need detailed code for the solution. But to the people on this thread I know they already know how to code it themselves.

Hi ! Can we have more detailed ? ^^

Cracc2A avatar Feb 12 '24 21:02 Cracc2A

Solution : Just do a RequestModel(mp_m_freemode_01),RequestModel(mp_f_freemode_01) and then a loop for Has_Model_Loaded() for the same, before calling the open menu in the qb-multicharacter has fixed the error and the crashes for me. Ping me if u need detailed code for the solution. But to the people on this thread I know they already know how to code it themselves.

Ezio21 I'm having the exact same issue. Where did you put that ? I'm running illeum appearance, and qb-mulitcharacter. do I put it in the server side? Please any help would be greatly appreciated.

JoshPlne avatar Feb 16 '24 14:02 JoshPlne

While I cannot seem to replicate this locally with only the resource (i.e., just erroneous-resource), the crash location does seem consistent with too many CModelInfoStreamingModule streaming dependencies. Would it be possible to provide the number of SHOP_PED_APPAREL_META_FILE's manifest entries you have on your server (and game build).

For reference, this seems to be the relevant qb-multicharacter snippet and see previous discussion on the forums.

gottfriedleibniz avatar Feb 16 '24 16:02 gottfriedleibniz

Solution : Just do a RequestModel(mp_m_freemode_01),RequestModel(mp_f_freemode_01) and then a loop for Has_Model_Loaded() for the same, before calling the open menu in the qb-multicharacter has fixed the error and the crashes for me. Ping me if u need detailed code for the solution. But to the people on this thread I know they already know how to code it themselves.

Hi, I'm now also having this issue. Could I please look over the detailed guide as i'm struggling with it by my lonesome. Thankyou!

Zachyboii avatar Feb 17 '24 13:02 Zachyboii