Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTA Online

      1. The Diamond Casino Heist
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Red Dead Online

      1. Frontier Pursuits
      2. Find Lobbies & Outlaws
      3. Help & Support
    3. Crews

      1. Events
    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

    2. GTA 6

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA SA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA VC Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA III Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    3. Gangs

    1. News

    2. Forum Support

    3. Site Suggestions

GeorgeZhang

Model Request Timed Out Everytime

Recommended Posts

GeorgeZhang

I'm trying to spawn some props, but it sometimes crashes my script, the error says it's about model requesting and it timed out.

Reloading scripts doesn't fix the issue.

Funny things is, if I restart the game and then try again, it will work perfectly. How to fix this?

World.CreateProp(new Model(701173564), showCoords, false, false);

Edit: the code is similar to this, though there are 10 of them.

Edited by GeorgeZhang

Share this post


Link to post
Share on other sites
GeorgeZhang

Ok, I don't think it would be a great solution, but I ended up using Function.Call to call those native myself. It works for now, sort of.

    public Model RequestModel(int hash)    {        if (Function.Call<bool>(Hash.IS_MODEL_IN_CDIMAGE, hash) && Function.Call<bool>(Hash.IS_MODEL_VALID, hash))        {            int counter = 0;            do            {                //model.Request();                Function.Call(Hash.REQUEST_MODEL, hash);                Yield();                counter++;            } while (!Function.Call<bool>(Hash.HAS_MODEL_LOADED, hash) && counter < 20000); //^this part is from Guad's source            var model = new Model(hash);            return model;        }        else        {            UI.ShowSubtitle("Please Report Invalid Model Hash: ~r~" + hash.ToString(), 10000);            return null;        }    }

Share this post


Link to post
Share on other sites
bilago

I'm trying to spawn some props, but it sometimes crashes my script, the error says it's about model requesting and it timed out.

Reloading scripts doesn't fix the issue.

Funny things is, if I restart the game and then try again, it will work perfectly. How to fix this?

World.CreateProp(new Model(701173564), showCoords, false, false);

Edit: the code is similar to this, though there are 10 of them.

 

 

Did you try using:

int timeOut = 5000;Model prop = new Model(701173564);if(prop.Request(timeOut))    World.CreateProp(prop, showCoords, false, false);else    //model failed to load

Share this post


Link to post
Share on other sites
GeorgeZhang

Sure, see the second comment.

Share this post


Link to post
Share on other sites
GeorgeZhang

Just found out that some of the models I request are SOMETIMES IN CDIMAGE and SOMETIMES not. I'm very much confused. Whether it is in cdimage or not depends on my luck? It's just ridiculous. That way,there might be no solution to it, is there?

Share this post


Link to post
Share on other sites
bilago

Sure, see the second comment.

 

The second comment is nothing like the code I suggested? Sure, I see you have .Request() commented out, but thats not using the built in timeout overload which does exactly what your second post accomplishes, without all the bulky code to go along with it.

Share this post


Link to post
Share on other sites
GeorgeZhang

Ok I see. Now the problem is some models will return not in cdimage sometimes, which is weird.

Share this post


Link to post
Share on other sites
whorse

Why do you need to check if the model is in the CDImage at all? I published a traffic-replacer mod (for increased traffic variety) that honestly only checks STREAMING::IS_MODEL_A_VEHICLE() on the model hash before it requests it/spawns it, and I have not experienced any errors caused by putting in incorrect vehicle model hashes in the INI file (bad ones just wont be requested). Nor have I heard of any such problems from any of the people who've downloaded it. I purposefully made it that way because I wanted users to be able to request any model so long as it was considered a valid vehicle model at run-time -- even if it was not a default game model (which is what I assume is what CDImage is checking for?).

 

Has it just kind of become common convention, to check if its in CDimage before spawning a model? Or is there a really good reason to use it that I'm missing?

Share this post


Link to post
Share on other sites
GeorgeZhang

Why do you need to check if the model is in the CDImage at all? I published a traffic-replacer mod (for increased traffic variety) that honestly only checks STREAMING::IS_MODEL_A_VEHICLE() on the model hash before it requests it/spawns it, and I have not experienced any errors caused by putting in incorrect vehicle model hashes in the INI file (bad ones just wont be requested). Nor have I heard of any such problems from any of the people who've downloaded it. I purposefully made it that way because I wanted users to be able to request any model so long as it was considered a valid vehicle model at run-time -- even if it was not a default game model (which is what I assume is what CDImage is checking for?).

 

Has it just kind of become common convention, to check if its in CDimage before spawning a model? Or is there a really good reason to use it that I'm missing?

The reason I checked it is not for spawning, but I want to know what is wrong with it not loading, and I need the model to spawn, because my script needs that model. It can't work the way in which I let the script ignore it if it's invalid. Thanks for the reply.

 

Edit: I have a acceptable solution: use another model instead. Before this is solved, that's the only way.

Edited by GeorgeZhang

Share this post


Link to post
Share on other sites
whorse

 

The reason I checked it is not for spawning, but I want to know what is wrong with it not loading, and I need the model to spawn, because my script needs that model. It can't work the way in which I let the script ignore it if it's invalid. Thanks for the reply.

 

Edit: I have a acceptable solution: use another model instead. Before this is solved, that's the only way.

 

I thought you said it was not loading because it was sometimes reported as not being in the CDImage (even though it should be), which causes your function to abort the request? What happens if you remove the CDimage-check before requesting, and only check whether it is a valid model? Admittedly, all the vehicle models in that traffic mod are reported as being in CDImage when I do a check on them, but I'd still like to know what happens if you go through with a request for a valid model that is (for some reason) not said to be in CDimage

Edited by whorse

Share this post


Link to post
Share on other sites
GeorgeZhang

 

The reason I checked it is not for spawning, but I want to know what is wrong with it not loading, and I need the model to spawn, because my script needs that model. It can't work the way in which I let the script ignore it if it's invalid. Thanks for the reply.

 

Edit: I have a acceptable solution: use another model instead. Before this is solved, that's the only way.

 

I thought you said it was not loading because it was sometimes reported as not being in the CDImage (even though it should be), which causes your function to abort the request? What happens if you remove the CDimage-check before requesting, and only check whether it is a valid model? Admittedly, all the vehicle models in that traffic mod are reported as being in CDImage when I do a check on them, but I'd still like to know what happens if you go through with a request for a valid model that is (for some reason) not said to be in CDimageThe models I request are rare objects which I think is the major problem.

I check it so that I can understand why it doesn't/ can't request, it didn't request before I added the "cdimage check", therefore, removing the check wouldn't make it spawn, would it? The problem is that it just won't request, not that it's not reporting it's in cdimage, and checking if it's in cdimage is just what I did to find out what's wrong with it not requesting.

Share this post


Link to post
Share on other sites
nordi

Does anyone have a solution ? I'm experiencing the same issue: depending on my position on the map my props will load or not ...

Share this post


Link to post
Share on other sites
nordi

post code

Model ship = new Model("des_shipsink_01");            ship.Request(8000);            //while (!ship.IsLoaded) Script.Wait(5);            Prop my_prop = new Prop(1);             my_prop = World.CreateProp(ship, myPOS, true, false);

Share this post


Link to post
Share on other sites
gtaVmod

Make bare project and put only this code into it.

Share this post


Link to post
Share on other sites
nordi

does any one else have another solution ?

Share this post


Link to post
Share on other sites
GeorgeZhang

I don't know what's happening. Some players are having issue with my mod not spawning peds. In my game it works fine. But in some players' game, the models just wouldn't load, for no reason. I'm losing my mind.

Share this post


Link to post
Share on other sites
Fireboyd78

Post your ped spawning code so we can look for possible solutions.

  • Like 1

Share this post


Link to post
Share on other sites
AHK1221

Maybe not enough memory? You should use model.MarkAsNoLongerNeeded to save memory.

Share this post


Link to post
Share on other sites
GeorgeZhang

Maybe not enough memory? You should use model.MarkAsNoLongerNeeded to save memory.

Yes I did use that.

 

Post your ped spawning code so we can look for possible solutions.

 

Here:

Model pmodel = new Model(gang.Models[(int)PedClass]);pmodel.Request(300);if (pmodel.IsInCdImage && pmodel.IsValid)   while (!pmodel.IsLoaded) Wait(100);else   return;var ped =  Function.Call<Ped>(Hash.CREATE_PED, 26, pmodel.Hash, spawn.X, spawn.Y, spawn.Z, 0f, false, false);pmodel.MarkAsNoLongerNeeded();

Again, most of the time it works. If you notice anything wrong please point it out I'll be very grateful!

Edited by GeorgeZhang

Share this post


Link to post
Share on other sites
Fireboyd78

What's in "gang.Models"? And honestly you should spit out a notification when it fails to load something instead of just returning. People would be able to report bugs for you much easier!

Share this post


Link to post
Share on other sites
GeorgeZhang

What's in "gang.Models"? And honestly you should spit out a notification when it fails to load something instead of just returning. People would be able to report bugs for you much easier!

gangs is a "Gang". And "Gang" is a class implemented by me, to handle ally/enemy gangs in my mod.

 

btw I've noticed that the while loop will crash the game if model is not loaded. Here's new code:

Model pmodel = new Model(gang.Models[(int)PedClass]);            do            {                pmodel.Request();                Yield();                counter++;            } while (!pmodel.IsLoaded && counter < 20000);            var ped =  Function.Call<Ped>(Hash.CREATE_PED, 26, pmodel.Hash, spawn.X, spawn.Y, spawn.Z, 0f, false, false);            pmodel.MarkAsNoLongerNeeded();

Actually, I saw this in Guad's NOoSE source code. Thanks Guad!

Edited by GeorgeZhang

Share this post


Link to post
Share on other sites
AHK1221

 

Maybe not enough memory? You should use model.MarkAsNoLongerNeeded to save memory.

 

Yes I did use that.

 

Post your ped spawning code so we can look for possible solutions.

 

Here:

 

Model pmodel = new Model(gang.Models[(int)PedClass]);pmodel.Request(300);if (pmodel.IsInCdImage && pmodel.IsValid)   while (!pmodel.IsLoaded) Wait(100);else   return;var ped =  Function.Call<Ped>(Hash.CREATE_PED, 26, pmodel.Hash, spawn.X, spawn.Y, spawn.Z, 0f, false, false);pmodel.MarkAsNoLongerNeeded();
Again, most of the time it works. If you notice anything wrong please point it out I'll be very grateful! Dude, just use World.CreatePed without any of the requesting! I use it and it works ALL the time. No need to go through that. Never did it not spawn a ped

Share this post


Link to post
Share on other sites
GeorgeZhang

 

 

Maybe not enough memory? You should use model.MarkAsNoLongerNeeded to save memory.

Yes I did use that.

 

Post your ped spawning code so we can look for possible solutions.

Here:

 

Model pmodel = new Model(gang.Models[(int)PedClass]);pmodel.Request(300);if (pmodel.IsInCdImage && pmodel.IsValid)   while (!pmodel.IsLoaded) Wait(100);else   return;var ped =  Function.Call<Ped>(Hash.CREATE_PED, 26, pmodel.Hash, spawn.X, spawn.Y, spawn.Z, 0f, false, false);pmodel.MarkAsNoLongerNeeded();
Again, most of the time it works. If you notice anything wrong please point it out I'll be very grateful!
Dude, just use World.CreatePed without any of the requesting! I use it and it works ALL the time. No need to go through that. Never did it not spawn a ped

 

That works for me too. But it just won't work in some people's game. I'm using the most simple code now : model.Reqest(5000) and World.CreatePed

Share this post


Link to post
Share on other sites
jedijosh920

The World.CreatePed() function should work on all legitimate and updated versions of the game. You really should stop supporting the pirated versions of the game.

Share this post


Link to post
Share on other sites
GeorgeZhang

The World.CreatePed() function should work on all legitimate and updated versions of the game. You really should stop supporting the pirated versions of the game.

You sure it's because of that? If so, than i'll just leave them alone then.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.