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

    1. Red Dead Redemption 2

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

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

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

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

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

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

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

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

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    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
    1. News

    2. Forum Support

    3. Site Suggestions

gtaVmod

Weird exception

Recommended Posts

gtaVmod

First time i caught an exception and very weird one, look at the code:

    DWORD           PlaneModel = GAMEPLAY::GET_HASH_KEY("CUBAN800");    DWORD           PlanePilotModel = GAMEPLAY::GET_HASH_KEY("player_two");    // create pilot    if (STREAMING::IS_MODEL_IN_CDIMAGE(PlanePilotModel) && STREAMING::IS_MODEL_VALID(PlanePilotModel))        STREAMING::REQUEST_MODEL(PlanePilotModel);    if (STREAMING::HAS_MODEL_LOADED(PlanePilotModel)) {        Notification("HAS_MODEL_LOADED = 1");              <<<<< THIS LINE IS EXECUTED    }    while (!STREAMING::HAS_MODEL_LOADED(PlanePilotModel)) { WAIT(100);  }        <<<<< EXCEPTION HERE

It occurs when last line is executed (while statement), if i comment it program goes OK.

 

Notification("HAS_MODEL_LOADED = 1") is executed, so call to STREAMING::HAS_MODEL_LOADED(PlanePilotModel) is not a cause of error.

 

But there is only WAIT() left to blame? WTF!?

Edited by gtaVmod

Share this post


Link to post
Share on other sites
whorse

Try setting it to WAIT(0) rather than WAIT(100).

 

Also, if you are not looking for one particular pilot model, you can just use this:

Ped CREATE_RANDOM_PED_AS_DRIVER(Vehicle vehicle, BOOL returnHandle)

It creates a driver that matches the vehicle, so army jeeps get marines, civilian planes get captains, crop-dusters get hillbillies, trucks get truckers etc.

 

I'm pretty sure it is the default function the game uses to spawn drivers in free-roam traffic.

 

EDIT: nevermind, I just saw you are trying to spawn trevor, disregard that part about the native.

Edited by whorse

Share this post


Link to post
Share on other sites
GeorgeZhang

Try setting it to WAIT(0) rather than WAIT(100).

 

Also, if you are not looking for one particular pilot model, you can just use this:

Ped CREATE_RANDOM_PED_AS_DRIVER(Vehicle vehicle, BOOL returnHandle)

It creates a driver that matches the vehicle, so army jeeps get marines, civilian planes get captains, crop-dusters get hillbillies, trucks get truckers etc.

 

I'm pretty sure it is the default function the game uses to spawn drivers in free-roam traffic.

 

EDIT: nevermind, I just saw you are trying to spawn trevor, disregard that part about the native.

Thanks for the comment!! I didn't know that the native does that, I thought it might create a coast guard in the jet so I request my desired model instead. Now I'll give this a try:)

Share this post


Link to post
Share on other sites
gtaVmod

Try setting it to WAIT(0) rather than WAIT(100).

It was WAIT(0), i just copied this pilot generating code from the same file i'm developing and placed it in anoher place (close to main()).

 

Also, if you are not looking for one particular pilot model, you can just use this:

Ped CREATE_RANDOM_PED_AS_DRIVER(Vehicle vehicle, BOOL returnHandle)
It creates a driver that matches the vehicle, so army jeeps get marines, civilian planes get captains, crop-dusters get hillbillies, trucks get truckers etc.

 

I'm pretty sure it is the default function the game uses to spawn drivers in free-roam traffic.

 

EDIT: nevermind, I just saw you are trying to spawn trevor, disregard that part about the native.

 

I used trevor model as pilot for another plane in the same source file without any issues.

 

I essentially just copied working piece of code and placed it in another place in the same file and it broke.

I have no explanation other than this action somehow triggered error somewhere...

Alone calls to HAS_MODEL_LOADED() or WAIT() does not trigger this error.

Some fking mystery.

Share this post


Link to post
Share on other sites
Alexander Blade

show

Notification code

Share this post


Link to post
Share on other sites
gtaVmod

 


void Notification(char * msg) {
UI::_SET_NOTIFICATION_TEXT_ENTRY("STRING");
UI::_ADD_TEXT_COMPONENT_STRING(msg);
UI::_DRAW_NOTIFICATION(FALSE, FALSE);
}

 

Share this post


Link to post
Share on other sites
gtaVmod

removed

Edited by gtaVmod

Share this post


Link to post
Share on other sites
gtaVmod

New info:

I didn't noticed before (because i was always dynamically reloading script in game with Ctrl-R) but after i moved spawning code to the begining of my program game stoppped loading at all (before moving code, it was called by pressing a key usually when the game is fully loaded). As soon as I commented spawning code it is back no normal.

Only conclusion from this behavior is game engine is not ready to serve requests at the time asi-loader starts asi script, and this can be fixed either by asi-loader or inside asi script itself (if possible).

Edited by gtaVmod

Share this post


Link to post
Share on other sites
leftas

By saying mainloop you also including functions called in it ?

By the way, are you creating thread and not registering by asi loader ?

And talking about begin of program, you call it in registered function ?

scriptRegister([in]hModule, [in]function);

All the best,

Paul.

Edited by leftas

Share this post


Link to post
Share on other sites
gtaVmod

I don't create anything. I'm writing asi-script which is loaded by AB's asi-loader.

I used a Alexander's NativeTraner source as template and wrote code inside main() func.

Edited by gtaVmod

Share this post


Link to post
Share on other sites
leftas

If you making an conclusion and now knowing that you need to register your function/dll to ScriptHook(which register your function as GTA V scripts' function) then please, know the facts.

You still didn't answer two questions of mine(forgot to put question marks, edited now) :)

 

All the best,

Paul.

Edited by leftas

Share this post


Link to post
Share on other sites
gtaVmod

I can hardly understand what you are talking. It is either your english level or a way you think.

As i said i used NativeTrainer as template and it already have registering functions, so i believe there is no other action required from my side.

Share this post


Link to post
Share on other sites
leftas

I can hardly understand what you are talking. It is either your english level or a way you think.

As i said i used NativeTrainer as template and it already have registering functions, so i believe there is no other action required from my side.

Sure.

Can you answer, when you saying inside the loop, you also including functions called by main loop ? If not, then from where you calling it from another thread ?

 

All the best,

Paul.

Share this post


Link to post
Share on other sites
gtaVmod

All mine code i'm talking about is executed from main() func, which in turn is called from ScriptMain().

 

The only difference is WHEN it is executed.

If it is called by pressing a key while game is already loaded there is no errors.

But if same code is called right after main() gains control, it crashes.

 

E.g.:

 

1. DllMain()

 

2. scriptRegister(hInstance, ScriptMain)

 

3.

void ScriptMain()
{
srand(GetTickCount());
main();
}

 

4. main()

(main have a infinite loop)

 

5. my code inside main()

main() {spawn_vehicle();    <<<<< THIS BREAKS PROGRAMwhile(1){  ...  if(key_pressed) spawn_vehicle();    <<<<< THIS IS OK  ...  }}
Edited by gtaVmod

Share this post


Link to post
Share on other sites
gtaVmod

Alexander, are you able to reproduce/confirm this issue?

Edited by gtaVmod

Share this post


Link to post
Share on other sites
leftas

If I'm not wrong, Alex's scripthook load scripts as soon as the call has been made into scripthook. So one more question, does it crash only when the game is loading(start menu) or even after you do reload scripts in GTA V. If it crashes only when the game is starting then the issue would be that the world haven't been initialized and you want to create a vehicle :)

 

All the best,

Paul.

Share this post


Link to post
Share on other sites
gtaVmod

there are 2 cases, this line:

while (!STREAMING::HAS_MODEL_LOADED(PlanePilotModel)) { WAIT(0); }

crahes while reloading in-game (Ctrl+R) if called right after main(), but if you modify it a bit:

while (!STREAMING::HAS_MODEL_LOADED(PlanePilotModel)) { ; }WAIT(100);

it is OK to reload in-game, but will stop program from loading if you do full restart of GTA5.

 

the world haven't been initialized and you want to create a vehicle

 

That's what i suggested earlier. But it is loader's responsibility not to start asi script while the engine is not ready IMHO.

Share this post


Link to post
Share on other sites
leftas

This

while (!STREAMING::HAS_MODEL_LOADED(PlanePilotModel)) { ; }

Makes an infinite loop for game's script thread(They initialize all the world), and you always need to put Wait, because game uses coop multi-thread.

 

About world initialization - you should check for player's entity existence, also check if player is visible :) And about starting asi script. It's really dependent on scripts type, some need a loooong initialization, so they should start before the game start. On the other hand, there are scripts like yours, but you can use some methods, I mentioned before, but there plenty others methods, to check if game have initialized :)

 

All the best,

Paul.

Share this post


Link to post
Share on other sites
gtaVmod

when i put WAIT(0) there it crashes (exception). see the first post of this thread.

Share this post


Link to post
Share on other sites
leftas

Before model streaming, like I said, you need to be sure of world intilization. Check if player ped exists, player is visible and so on...

 

All the best,

Paul.

Edited by leftas

Share this post


Link to post
Share on other sites
gtaVmod

 

About world initialization - you should check for player's entity existence, also check if player is visible :) And about starting asi script. It's really dependent on scripts type, some need a loooong initialization, so they should start before the game start. On the other hand, there are scripts like yours, but you can use some methods, I mentioned before, but there plenty others methods, to check if game have initialized :)

 

 

Your theory is wrong, i put debug comands right under main() and restarted GTA5:

main() startedDOES_PLAYER_EXIST(): 1DOES_PLAYER_VISIBLE(): 1IS_PLAYER_CONTROL_ON(): 1

Share this post


Link to post
Share on other sites
Alexander Blade

do something like wait for 5 seconds before u start messing with streaming

Share this post


Link to post
Share on other sites
leftas

What about trying world to screen ?

 

All the best,

Paul.

Edited by leftas

Share this post


Link to post
Share on other sites
gtaVmod

what??

Share this post


Link to post
Share on other sites
Alexander Blade

Upload your sources somewhere plz

Share this post


Link to post
Share on other sites
gtaVmod

Will do tomorrow

Share this post


Link to post
Share on other sites
whorse

I've never had a problem with executing any natives within the scope of the main() method, but if I try to use a native to instantiate a class-wide script.cpp variable, I get an exception (usually the error code contains in it the hash of the native that crashed the game). I learned the lesson to keep all my native-calls within the main() method, or - if I could - to only use them within the while(true) loop inside the main() method. Avoid using any other loops before the main while(true) loop starts, if you can

Share this post


Link to post
Share on other sites
gtaVmod

I fixed this error, was my mistake, sorry for wasting your time guys

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.
Note: Your post will require moderator approval before it will be visible.

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.