Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

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

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

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

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

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

      1. Documentation
    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. Design Your Own Mission
      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. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

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

    2. Forum Support

    3. Suggestions

[BETA] GTAIV .Net ScriptHook


HazardX
 Share

Recommended Posts

If i start my game, the Nethook doesnt load any scripts, i have 3 or 4 scripts inside the scripts folder, but the hook doesnt load them. Reloadscripts doesnt work.

Does the ScriptHook start at all? If yes, whats the content of the "ScriptHookDotNet.log" file?

Link to comment
Share on other sites

 

Quick question: how do call native functions again? I need to read the stats, but i dont want to use the enum...

Native.Function.Call would be the method to use. There is a sample script that shows how to do this in more detail. wink.gif

Link to comment
Share on other sites

Quick question: how do call native functions again? I need to read the stats, but i dont want to use the enum...

CoMPMStR is correct. But why do you want to use a native call for it? Enums are just named integer values, thus you can assign any integer value to it instead if you want to.

Link to comment
Share on other sites

 

Quick question: how do call native functions again? I need to read the stats, but i dont want to use the enum...

CoMPMStR is correct. But why do you want to use a native call for it? Enums are just named integer values, thus you can assign any integer value to it instead if you want to.

Hm.. When i do Game.GetFloatStatictic(id);

 

i get:

': cannot convert from 'short' to 'GTA.FloatStatistic'

Link to comment
Share on other sites

KingBulleT 8747
If i start my game, the Nethook doesnt load any scripts, i have 3 or 4 scripts inside the scripts folder, but the hook doesnt load them. Reloadscripts doesnt work.

Does the ScriptHook start at all? If yes, whats the content of the "ScriptHookDotNet.log" file?

This.

 

 

2009-07-29 16:10:02 - Initializing ScriptHookDotNet v0.891 BETA (GTA IV version 1.0.4.0)2009-07-29 16:11:38 - Direct3D device created!2009-07-29 16:11:39 - Error during ScriptDomain.Create:                     System.InvalidCastException: Der transparente Proxy kann nicht in den Typ "GTA.RemoteScriptDomain" umgewandelt werden.                        bei GTA.ScriptDomain.Create()2009-07-29 16:13:18 - Error during ScriptDomain.Create:                     System.InvalidCastException: Der transparente Proxy kann nicht in den Typ "GTA.RemoteScriptDomain" umgewandelt werden.                        bei GTA.ScriptDomain.Create()2009-07-29 16:13:46 - Error during ScriptDomain.Create:                     System.InvalidCastException: Der transparente Proxy kann nicht in den Typ "GTA.RemoteScriptDomain" umgewandelt werden.                        bei GTA.ScriptDomain.Create()2009-07-29 16:17:41 - Direct3D device lost!2009-07-29 16:17:59 - Direct3D device created!2009-07-29 16:19:20 - Direct3D device lost!2009-07-29 16:19:37 - Direct3D device created!2009-07-29 16:23:15 - Error during ScriptDomain.Create:                     System.InvalidCastException: Der transparente Proxy kann nicht in den Typ "GTA.RemoteScriptDomain" umgewandelt werden.                        bei GTA.ScriptDomain.Create()2009-07-29 16:44:41 - Direct3D device lost!2009-07-29 16:44:57 - Direct3D device created!2009-07-29 16:45:32 - Direct3D device lost!2009-07-29 16:46:04 - Direct3D device created!2009-07-29 17:15:14 - Direct3D device lost!

 

 

I think you can read it, because you are German (too)

Link to comment
Share on other sites

 

Hm.. When i do Game.GetFloatStatictic(id);

 

i get:

': cannot convert from 'short' to 'GTA.FloatStatistic'

C# doesn't allow implicit conversion. You have to an explicit conversion from integer to FloatStatistic:

 

 

Game.GetFloatStatistic((FloatStatistic)id);

 

 

 

@KingBulleT 8747 : Do you have an old version of the scripthook lying around somewhere in your main folder or in the "plugins" subfloder? Delete it! Renaming it isn't sufficient. This is the only possible reason i could imagine for this error message right now.

Edited by HazardX
Link to comment
Share on other sites

KingBulleT 8747
@KingBulleT 8747 : Do you have an old version of the scripthook lying around somewhere in your main folder or in the "plugins" subfloder? Delete it! Renaming it isn't sufficient. This is the only possible reason i could imagine for this error message right now.

I only had 0.88 and 0.89 installed, and now i have 0.891, i overwrited it. Maybe thats the problem?

Link to comment
Share on other sites

 

Just wanted to tell you that the problem with the key's not being registered still happens sad.gif

 

Simple Native Trainer kinda died with this.

Are you sure? I was able to replicate the problem in the old version of the hook with Sajaak's simple trainer, but in the new version everything runs smoothly for me.

 

@Black Patriot: Yes, GTA.Forms has a serious performance impact ATM. The problem is that DirectX runs in the main thread of the hook, while each script has an own thread. Thus each draw call (each line and box) needs to be passed to the other thread in a rather complicated way. However, the whole system has lots of room left for optimization. I just didn't optimize it yet to get it finished fast and FPS aren't that important while using a window.

 

@DACK 23: greetings, federal state mate. Shifty41s_beerhatsmilie2.gif The NeonScript needs to be changed for the new version. I'll take a look at it.

Yes, I'm completely sure.

 

I'll list down the mods I have if you want to try replicate the problem

 

- YAASIL (Not Alexander Blades)

- File Check Fix

- G4M Hook

- Godmode Plus

- Netkick (Sneaky Janitor)

- Scripthook.dll (Your .net version)

- TeleportMod

- Sjaak's Simple Native Trainer 3.9

- Vehicle Selector

 

Everything goes fine when I revert back to the old C++ hook.

 

Please try to help me, I really do enjoy your grabscript; and I want to try the Tuning Mod.

Link to comment
Share on other sites

Hazard: Is there any performance issue with using the ScreenUnits scaling function? (e.Graphics.Scaling = ScreenUnits)? After switching to that in my script, the script slows down after about 3 minutes and becomes unplayable.

Link to comment
Share on other sites

 

Hazard: Is there any performance issue with using the ScreenUnits scaling function? (e.Graphics.Scaling = ScreenUnits)? After switching to that in my script, the script slows down after about 3 minutes and becomes unplayable.

It sounds more like a memory leak of some kind. The scaling can't be the root of the problem. Could you send me a copy of your script for further investigation? It can be already complied to a DLL, i do not need the source to look at where in the hook it is leaking. I'm guessing that the problem is related to items being stored in the Metadata database again and again.

 

[EDIT] downloaded v2.2 of your mod now. does it suffer from the problem?

[EDIT2] okay, i just noticed this version is not compatible with the current hook.

[EDIT3] found v2.1.1 now, which is the version for the current hook

[EDIT4] okay, found the problem after a second of testing. You are creatig a new font every frame. This is a very bad idea, since fonts are created in Direct3D and currently stay loaded until the end. I am now adding dispose functionality that will remove the font from the Direct3D device when it is not required anymore, but it is still VERY slow to create a new font every frame.

Edited by HazardX
Link to comment
Share on other sites

Player.Model's set accessor has serious issue - when you change to player model game crashes when you enter a bike and put on helmet. Solution:

 

       void ChangePlayerModel(string name)       {           Model m = new Model(name);           if (m.isPed)           {               Room r = Player.Character.CurrentRoom;               if (!Function.Call<bool>("HAS_MODEL_LOADED", new Parameter(m)))               {                   Function.Call("REQUEST_MODEL", new Parameter(m));                   while (!Function.Call<bool>("HAS_MODEL_LOADED", new Parameter(m)))                   {                       Wait(1);                   }               }               Function.Call("CHANGE_PLAYER_MODEL", new Parameter(Player), new Parameter(m));               Player.Character.CurrentRoom = r;           }       }

 

 

HazardX, I hope this will be fixed in update smile.gif

 

Also, new scripthook doesn't raise KeyDown or KeyUp on mouse clicks. Now I have to call GetAsyncKeyState instead sad.gif

Edited by _hax
Link to comment
Share on other sites

 

Player.Model's set accessor has serious issue - when you change to player model game crashes when you enter a bike and put on helmet. Solution:

 

...

 

 

HazardX, I hope this will be fixed in update smile.gif

 

Also, new scripthook doesn't raise KeyDown or KeyUp on mouse clicks. Now I have to call GetAsyncKeyState instead sad.gif

This is exactly what the scripthook does on a player model change already right now. It is strange that you get a crash on entering a bike. I just tried it several times with different skins and everything was fine.

 

There are extra MouseDown and MouseUp events for the mouse buttons.

Link to comment
Share on other sites

Hazard: Is there any performance issue with using the ScreenUnits scaling function? (e.Graphics.Scaling = ScreenUnits)? After switching to that in my script, the script slows down after about 3 minutes and becomes unplayable.

It sounds more like a memory leak of some kind. The scaling can't be the root of the problem. Could you send me a copy of your script for further investigation? It can be already complied to a DLL, i do not need the source to look at where in the hook it is leaking. I'm guessing that the problem is related to items being stored in the Metadata database again and again.

 

[EDIT] downloaded v2.2 of your mod now. does it suffer from the problem?

[EDIT2] okay, i just noticed this version is not compatible with the current hook.

[EDIT3] found v2.1.1 now, which is the version for the current hook

[EDIT4] okay, found the problem after a second of testing. You are creatig a new font every frame. This is a very bad idea, since fonts are created in Direct3D and currently stay loaded until the end. I am now adding dispose functionality that will remove the font from the Direct3D device when it is not required anymore, but it is still VERY slow to create a new font every frame.

Ah, so it is better to create the font outside of the frame?

Link to comment
Share on other sites

 

Ah, so it is better to create the font outside of the frame?

Look at my posting in your thread. The current system how fonts are handled is bad because it isn't obvious that changing font height and other values results in a new Direct3D font being generated in background. In the next version of the hook changing those values will not be possible anymore after first construction of the font. This way you have to create a new font to change the values and thus it is more obvious that doing so has some overhead.

 

At the moment you should create the fonts and set all font settings on script startup. define multiple fonts if you need different font heights.

Link to comment
Share on other sites

Read your post after I posted in here, lol. I've now defined seperate fonts for each of the 3 gauges I'm using. That way no fonts are changed in the Drawing method. I didn't realise that editing the font aspects resulted in a new font being generated. Really I should of done, considering I'm studying games programming, lol.

Link to comment
Share on other sites

Hazard, I know you're working tirelessly on things..

 

I've had some errors and not sure what they relate to but there are several and some look like this

 

 

Error during ScriptDomain.PerFrameDrawing:                     System.NullReferenceException: Object reference not set to an instance of an object.                        at GTA.Forms.RemoteMouse.SetValues(Boolean Enabled, PointF Position, PointF Movement, MouseButtons Buttons)                        at GTA.RemoteScriptDomain.SetInfos(Boolean isConsoleActive, Boolean MouseEnabled, PointF MousePosition, PointF MouseMovement, MouseButtons MouseButtons, Int32 LocalOpenFormsCount)                        at GTA.RemoteScriptDomain.SetInfos(Boolean isConsoleActive, Boolean MouseEnabled, PointF MousePosition, PointF MouseMovement, MouseButtons MouseButtons, Int32 LocalOpenFormsCount)                        at GTA.ScriptDomain.PerFrameDrawing()                        at GTA.NetHook.Draw()

 

 

What I have is my Friends trainer and OH (overhaul vehicle tracker).

 

Update: the above error was legit but the serious issue I had w/ terrible lag, was a software issue on my pc, I had mistaken it for the mention of your hook causing some slow down .. sorry Hazard.. :: fixt ::

Edited by Costar
Link to comment
Share on other sites

I'm not trying to add insult to injury with all the bug reports, but I have a little problem too. moto_whistle.gif

 

I'm messing around with the World.GetAllObjects method and it seems to stop working after a short time. If I call it more than once, the objects in the array it returns don't exist. I also tried just calling it once when the script first loads, it works for a little bit this way using a global variable but after a few minutes the objects in the array don't exist anymore. confused.gif What is the correct way to use this method, or does it need some fixin'?

 

GetAllPeds and GetAllVehicles seem to work fine. The only problem is that GetAllPeds doesn't work for any ped performing a task; for example fleeing, putting their hands up, conversating, sitting or standing against a wall or railing.

 

Also, is there any way to add the mouse wheel delta for use in the base.Mouse class? I'm sure it would make some things work much better, like console scrolling. biggrin.gif

Edited by CoMPMStR
Link to comment
Share on other sites

Thank you so much for updating this, it is very appreciated

also, it seems the scripthook.dll that comes with this conflicts with the scripthook for GTAIV Native trainer 3.9

I can't imagine there is anything you can do about this.. I just figured I'd let you know

but again thank you very much

Link to comment
Share on other sites

I'm not trying to add insult to injury with all the bug reports, but I have a little problem too. moto_whistle.gif

 

I'm messing around with the World.GetAllObjects method and it seems to stop working after a short time. If I call it more than once, the objects in the array it returns don't exist. I also tried just calling it once when the script first loads, it works for a little bit this way using a global variable but after a few minutes the objects in the array don't exist anymore. confused.gif What is the correct way to use this method, or does it need some fixin'?

 

GetAllPeds and GetAllVehicles seem to work fine. The only problem is that GetAllPeds doesn't work for any ped performing a task; for example fleeing, putting their hands up, conversating, sitting or standing against a wall or railing.

I haven't done anything with World.GetAllObjects yet and thus can't share any oservations. But it has to check around 1500 objects on validity which is extremely slow. You should try to avoid this function as much as possible.

 

Are you sure about GetAllPeds ? It reads the Peds directly from ingame memory, thus should get ALL of them, no matter who they are or what they do.

 

 

Link to comment
Share on other sites

Ok, you're right. I forgot to replace a method with the new one so GetAllPeds does work for all peds, EXCEPT any ped that's sitting. Once the ped gets up, it will work but while they're sitting it doesn't. I tried this in the park with those peds sitting on the benches.

Link to comment
Share on other sites

 

Player.Model's set accessor has serious issue - when you change to player model game crashes when you enter a bike and put on helmet. Solution:

 

...

 

 

HazardX, I hope this will be fixed in update smile.gif

 

Also, new scripthook doesn't raise KeyDown or KeyUp on mouse clicks. Now I have to call GetAsyncKeyState instead sad.gif

This is exactly what the scripthook does on a player model change already right now. It is strange that you get a crash on entering a bike. I just tried it several times with different skins and everything was fine.

 

There are extra MouseDown and MouseUp events for the mouse buttons.

@EDIT:

I tried it once again and it crashed with native call, sorry my bad - but it worked yesterday (how wired)

 

Back to the mouse events: why have you changed it? You made one of my mods not working and it took some time to find the issue. Please write more detailed changelog for scripters next time, where you could include such details as adding those mouse events, or moving LoadEnvoromentNow from Game to World object (just examples)

Edited by _hax
Link to comment
Share on other sites

Back to the mouse events: why have you changed it? You made one of my mods not working and it took some time to find the issue. Please write more detailed changelog for scripters next time, where you could include such details as adding those mouse events, or moving LoadEnvoromentNow from Game to World object (just examples)

I do not care for backwards compatibility. Having a consistent scripthook library has a higher priority for me. That's why it is still called "BETA". Also the MouseUp and MouseDown events were there for a long time already. That KeyUp and KeyDown do not throw mouse events anymore was a sideeffect of the key-blocking-bugfix and wasn't intended. But maybe i'll try to reactivate this functionality to make sure that users of scripts are able to redefine mousebuttons instead of keys if they want to.

Link to comment
Share on other sites

Im trying to create a circle for 'force'. Like this:

user posted image

 

I tried:

 

car.ApplyForce(Vector3.Normalize(car.Position - Player.Charactor.Position) * 10.0f);

 

 

But thats not really it...

 

Anyone have some idea's?

Link to comment
Share on other sites

 

Im trying to create a circle for 'force'. Like this:

...

 

But thats not really it...

Anyone have some idea's?

Your vector calculation is correct. But ApplyForce does not take world coordinates but object coordinates instead, as far as i know. I do not know how to switch the APPLY_FORCE_TO_CAR native to take world coordinates (but i'm sure it is possible). I would then include two functions: ApplyForce (for world coordinates) and ApplyRelativeForce (for object coordinates)

Edited by HazardX
Link to comment
Share on other sites

 

Im trying to create a circle for 'force'. Like this:

...

 

But thats not really it...

Anyone have some idea's?

Your vector calculation is correct. But ApplyForce does not take world coordinates but object coordinates instead, as far as i know. I do not know how to switch the APPLY_FORCE_TO_CAR native to take world coordinates (but i'm sure it is possible). I would then include two functions: ApplyForce (for world coordinates) and ApplyRelativeForce (for object coordinates)

Yeah thats what i thought, World <> object. I read in some other thread a while ago, that one of the bool parameters of ApplyForce is that absolute/relative option... Ill test this out, hope i can find it smile.gif

 

So the script (AF) needs World coords yes?

Link to comment
Share on other sites

KingBulleT 8747

 

HazardX, did you found something for my problem? Net Scripthook is starting, but loading no scripts.

Link to comment
Share on other sites

Yeah thats what i thought, World <> object. I read in some other thread a while ago, that one of the bool parameters of ApplyForce is that absolute/relative option... Ill test this out, hope i can find it smile.gif

 

So the script (AF) needs World coords yes?

Okay, found it already. smile.gif Your script is actually fine as it is. In the next version of the hook (this weekend) the ApplyForce method should behave as expected.

Link to comment
Share on other sites

 

Yeah thats what i thought, World <> object. I read in some other thread a while ago, that one of the bool parameters of ApplyForce is that absolute/relative option... Ill test this out, hope i can find it smile.gif

 

So the script (AF) needs World coords yes?

Okay, found it already. smile.gif Your script is actually fine as it is. In the next version of the hook (this weekend) the ApplyForce method should behave as expected.

'Should' ? You mean it was two options then? tounge.gif

 

Anyway thanks biggrin.gif

Link to comment
Share on other sites

How about Player.Character.Position - vector3 in world coordinates. That will give you an offset relative to object/car/ped

Link to comment
Share on other sites

 

How about Player.Character.Position - vector3 in world coordinates. That will give you an offset relative to object/car/ped

Indeed, what would be nice. Or Player.Character.Position.GetOffset(vector);

I know there must be something like that, but i always forget where it is, so i guess its not logical biggrin.gif

 

I cleaned up a TASK:

 

TASK_SHOOT_AT_CHAR(Ped From, Ped To, Int Duration, Int Modes)

 

Modes:

0 only aim

1 single bullit

2 single bullit but keep aim

3 burst fire

4 continous ?

5 continous ?

 

Fun biggrin.gif

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 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.