I decided to put something up using the DotNet Scripthook. Well, everything is working quite well, except one issue I keep running into.
One of my scripting threads loops through all vehicles around the player and eventually sets the engine health to "0f" for some of them. That normally works totally fine and there isn't really anything in the code that might fail there. But since several days I keep getting a "AccessViolationException", which then obviously crashes the script. Last time that error stayed for two days and went away after several attemps of changing code, clearing settings, etc. Everything was working for some time now, but suddenly, without any change it the code it came back.
Full stack trace:
at NativeInvoke.Invoke<int,int,bool,bool>(SByte* name, Int32 p1, Boolean p2, Boolean p3)
at Scripting.?A0x8c04474b.SetCarEngineOn(Int32 , Boolean , Boolean )
at GTA.Vehicle.set_EngineHealth(Single value)
at --.--.Tick_Main(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
As you can see it tries to enable the car engine somewhy (while I'm only changing the engine health). I asume this is the way, the DotNet script hook changes the health there after looking into its managed source.
I'm somewhere lost here and I hope somebody with experience can help me here.