overextended / ox_lib

A FiveM resource and script library for Lua and JS.
https://overextended.dev/ox_lib
GNU Lesser General Public License v3.0
282 stars 378 forks source link

[Question/Bug] lib.requestModel() not loading model due to IsModelValid #596

Closed lexinor closed 4 days ago

lexinor commented 2 weeks ago

Hi, I just don't know where to put this one, not sure if it's a bug with ox_lib or simply the Native Function but my issue is the following:

Describe the bug I'm creating a gamemode and I'm using lib.requestModel() to load my player character. The issue here is that even though I'm passing a proper model name as string, the function triggers an error when reaching IsModelValid() and I'm not able to load my model at all. To test my model, I decided to use the old way using the following and it worked properly:

code example that load the model fine:

  if not HasModelLoaded(modelHash) and IsModelInCdimage(modelHash) then
          RequestModel(modelHash)

          while not HasModelLoaded(modelHash) do
              Wait(0)
          end
  end

To Reproduce Steps to reproduce the behavior:

  1. I've created a blank server and I'm using: set sv_enforceGameBuild 3095
  2. Create a function server side that trigger a player spawn callback on the client
  3. Trigger that function when the player as joined the server
  4. In that function put a lib.requestModel() and request for a model: _g_m_y_famfor01 is the one I use (I tried multiple ones)

If you guys think that is not an issue feel free to tell me and I'll close it. I simply wanted to bring this error to your attention in case you have any further insights

lexinor commented 4 days ago

Thanks for your answer :)