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

    1. GTANet.com

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

      1. St Andrews Cathedral
    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 Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

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

      1. Guides & Strategies
      2. Help & Support
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
    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

      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. 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. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

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

    1. Announcements

    2. Support

    3. Suggestions

HazardX

[BETA] GTAIV .Net ScriptHook

Recommended Posts

LMS

There's a good reason why you no longer can catch AccessViolationExceptions. They often lead to crashes and you should really avoid them.

Share this post


Link to post
Share on other sites
MulleDK19

 

There's a good reason why you no longer can catch AccessViolationExceptions. They often lead to crashes and you should really avoid them.

The .NET ScriptHook catches them just fine.

 

And even if I have a thousand != null and Exists, and sh*t, I still get AccessViolationExceptions, when calling certain natives.

 

LeaveVehicleImmediatly causes an AccessViolationException 90% of the time.

Share this post


Link to post
Share on other sites
iriedreadlock23

I figured out the same LMS. I agree that the best is to prevent them from happening. However I placed the Native code calls in static/shared method in separate instance of small class. Its replaced with the new one when it can't be used anymore. So, if native turns to be wrong, it does not stop other scripts but only instance of this class. And I didn't see any performance issues by doing it this way.

Share this post


Link to post
Share on other sites
_Charger_

can u help me pls. i have a problem with the ini fiels. allways i get compiler errors when trying to read from ini (getvalueinteger)

 

and all helpfiles didn't help me -.-

Share this post


Link to post
Share on other sites
LMS

Maybe you should post your code and the error?

Share this post


Link to post
Share on other sites
_Charger_

here it is

 

    public class RageIV_Startup : Script   {       public RageIV_Startup()       {           float x = 1602.33f;           float y = -105.20f;           float z = 14.57f;           //set spawn coordinates           Vector3 spawnPos = new Vector3(x, y, z);           Game.FadeScreenOut(3000);           Player.Character.Position = spawnPos;           World.LoadEnvironmentNow(spawnPos);           Game.FadeScreenIn(3000);                     this.PerFrameDrawing += new GraphicsEventHandler(textDraw);       }       GTA.SettingsFile.GetValueInteger("BUILD", "SETTINGS", 100), new int Build;       public void textDraw(object sender, GraphicsEventArgs e)       {           e.Graphics.DrawText("Vice Rage IV DEV BETA", 0.5f, 0.5f, System.Drawing.Color.FromArgb(200, 250, 100, 250));           e.Graphics.DrawText("Build: " + Build, 1.0f, 1.0f, System.Drawing.Color.FromArgb(200, 250, 100, 250));           return;       }   }}

 

 

i only need to know how i can set the GetValueInteger to the int variable Build biggrin.gif

Edited by _Charger_

Share this post


Link to post
Share on other sites
LMS

Seriously?

 

 

int build = Settings.GetValueInteger("BUILD", "SETTINGS", 100);

 

Share this post


Link to post
Share on other sites
_Charger_

i tested that yesterday:

 

Fehler	1	Für das nicht statische Feld, die Methode oder die Eigenschaft "GTA.Script.Settings.get" ist ein Objektverweis erforderlich.

 

 

sry its in german i copied error code

 

 

EDIT: got it working thnx

Edited by _Charger_

Share this post


Link to post
Share on other sites
LMS

You should learn the basics of C# before. Anyway german is no problem for me smile.gif

 

Simply use Settings instead of GTA.SettingsFile.

Edit: Oh and place it in a function and not in the class of course.

Share this post


Link to post
Share on other sites
_Charger_

i made a simple mistake. thnx for the help tounge.gif

 

 

EDIT: now script works, but doesn't load from ini, it only shows default value (100)

Edited by _Charger_

Share this post


Link to post
Share on other sites
MulleDK19
i made a simple mistake. thnx for the help tounge.gif

Simple? You managed to invent a completely new syntax, lol...

Share this post


Link to post
Share on other sites
maxpower02

can anyone tell me why the hell my gta iv crashes after the load screen when i'm using .net script hook?

 

my gta is version 1.0.4.0, and yes, i'm already using Aru's C++ scripthook.dll (that came with a trainer - ver. 0.4.0)

Share this post


Link to post
Share on other sites
_Charger_

i have a problem. i want to read an integer value from ini

[sETTINGS]BUILD = 105[CHANGELOG]

 

 

with this code

 public void textDraw(object sender, GraphicsEventArgs e)       {           int build = Settings.GetValueInteger("BUILD", "SETTINGS", 100);           int resY = Game.Resolution.Height;           e.Graphics.DrawText("Vice Rage IV DEV BETA", 5.0f, 5.0f, System.Drawing.Color.FromArgb(200, 250, 100, 250));           e.Graphics.DrawText(("Build: " + build), 5.0f, resY - 25.0f, System.Drawing.Color.FromArgb(200, 250, 100, 250));           return;       }

 

but allways the default value is shown ingame.

 

EDIT: can anybody help?

Edited by _Charger_

Share this post


Link to post
Share on other sites
motorsport71

I placed

 

Private Position as Vector3Private Radius as SinglePublic Function GetRandomPed(ByVal Position As Vector3, ByVal Radius As Single) As Ped       Dim ped As New Native.Pointer(GetType(Ped))       Native.Function.Call("BEGIN_CHAR_SEARCH_CRITERIA")       Native.Function.Call("END_CHAR_SEARCH_CRITERIA")       Native.Function.Call("GET_RANDOM_CHAR_IN_AREA_OFFSET_NO_SAVE", Position.X - Radius, Position.Y - Radius, Position.Z - Radius, Radius * 2.0F, Radius * 2.0F, Radius * 2.0F, ped)       Return ped   End Function   Public Sub ClosestPedAsBodyGuard_KeyDown(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyDown       If e.Key <> Keys.N Then Return       Dim ped As ped = world.GetRandomPed(player.character.position, 20.0F)

 

 

and when i first entered the radius wrong on the "world.GetRandomPed" line it notified me, of course, in the console. It also told me then that it was implementing the function from within the script, not Scripthook anymore by the error "Public Function Get Random Ped...". Once i corrected that everything was perfectly fine.

 

There are several lists of gta native functions, and i've seen a couple of mods that use this listed Native Function "TASK_SET_IGNORE_WEAPON_RANGE_FLAG". From what i can tell it's not implemented in .Net Scripthook yet.

 

Is there anyway to access this Native Function by setting up it's own custom block? Modifying

the aforementioned Public Function didn't matter, as i wasn't expecting it to.

 

 

Share this post


Link to post
Share on other sites
Intosia
i made a simple mistake. thnx for the help tounge.gif

 

 

EDIT: now script works, but doesn't load from ini, it only shows default value (100)

Than it cant find the ini file..

Share this post


Link to post
Share on other sites
_Charger_
i made a simple mistake. thnx for the help tounge.gif

 

 

EDIT: now script works, but doesn't load from ini, it only shows default value (100)

Than it cant find the ini file..

but its placed correctly in scripts folder

Share this post


Link to post
Share on other sites
GingerHairHater

Does anyone know why my scripthook makes my whole map disappear? in the log it says 'Direct3D device lost'. i was wondering if that had anything to do with it. and pardon my newbish brain tounge.gif

Share this post


Link to post
Share on other sites
sjaak327
i made a simple mistake. thnx for the help tounge.gif

 

 

EDIT: now script works, but doesn't load from ini, it only shows default value (100)

Than it cant find the ini file..

but its placed correctly in scripts folder

Did you try and putting it in the IV main directory, and if so does it read the value when place there ?

 

 

Share this post


Link to post
Share on other sites
simon1790

Hi!

 

I got problem with .Net Scripthook.

 

I try on clen Gta Iv version with no savegames(folder from my documents not created yet) and with savegames. But i cant use any version of GTAIV .Net Script Hook because when i got it and start game (using patch 1.0.4.0 for enb) crashig in save loading. I tested all version of asi loader, scripthook and .net Scripthook but still not working. I normal whant to use simple native trainer but it not working(as i say before)even on stock,clean version on gta IV witch patch 1.0.4.0. Plz help.

Edited by simon1790

Share this post


Link to post
Share on other sites
_Charger_

 

i made a simple mistake. thnx for the help tounge.gif

 

 

EDIT: now script works, but doesn't load from ini, it only shows default value (100)

Than it cant find the ini file..

but its placed correctly in scripts folder

Did you try and putting it in the IV main directory, and if so does it read the value when place there ?

 

EDIT 2: got it working now biggrin.gif thanks for help

Edited by _Charger_

Share this post


Link to post
Share on other sites
Gramps

Can someone help me to get the scripts working ?

I can't use any @ all sad.gif I'm using patch v1.0.4.0

 

 

2011-03-24 01:24:30 - Initializing ScriptHookDotNet v1.7.1.7 BETA (on GTA IV version 1.0.4.0 with C++ Hook version 0.5.1)

 

2011-03-24 01:24:30 - WARNING: Your C++ ScriptHook version 0.5.1 and GTA IV version 1.0.4.0 are NOT known to be compatible! Use C++ ScriptHook version 0.4.0 or the newest version of the game AND the C++ ScriptHook instead!

2011-03-24 01:25:46 - Direct3D device created!

 

2011-03-24 01:25:47 - SEARCHING FOR SCRIPTS...

2011-03-24 01:25:47 - Loading scripts in Assembly 'scripts\CarShop.net.dll' ...

2011-03-24 01:25:47 -  ...found script 'CarShopCS.CarShop'!

2011-03-24 01:25:47 -  ...found script 'CarShopCS.KeyCheck'!

2011-03-24 01:25:47 -  ...found script 'CarShopCS.Menus'!

2011-03-24 01:25:47 - Loading scripts in Assembly 'scripts\DriveFelony.net.dll' ...

2011-03-24 01:25:47 -  ...found script 'DriveFelony.DriveFelonyScript'!

2011-03-24 01:25:47 - Loading scripts in Assembly 'scripts\TrafficControlSystem.net.dll' ...

2011-03-24 01:25:47 -  ...found script 'TrafficControlCS.TrafficControl'!

2011-03-24 01:25:47 - DONE! 5 valid scripts found!

 

2011-03-24 01:25:47 - STARTING SCRIPTS...

2011-03-24 01:25:48 - INFO: Phone number checks are not available!

2011-03-24 01:25:48 -  ...successfully started script 'TrafficControlCS.TrafficControl'!

2011-03-24 01:25:48 -  ...successfully started script 'DriveFelony.DriveFelonyScript'!

2011-03-24 01:25:48 -  ...successfully started script 'CarShopCS.Menus'!

2011-03-24 01:25:48 - Error during NetHook.Tick:

                      System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

                        at unmanaged.NativeContext3.Invoke(Int32 nameptr, Byte[] args, Int32 argnum, NativeContext3* cxt)

                        at GTA.ScriptDomain.RemoteEvent(RemoteEventArgs ev)

                        at GTA.ScriptDomain.ProcessRemoteEvents()

                        at GTA.ScriptDomain.Tick()

                        at GTA.NetHook.Tick()

 

Share this post


Link to post
Share on other sites
MulleDK19
Can someone help me to get the scripts working ?

I can't use any @ all sad.gif I'm using patch v1.0.4.0

 

 

2011-03-24 01:24:30 - Initializing ScriptHookDotNet v1.7.1.7 BETA (on GTA IV version 1.0.4.0 with C++ Hook version 0.5.1)

 

2011-03-24 01:24:30 - WARNING: Your C++ ScriptHook version 0.5.1 and GTA IV version 1.0.4.0 are NOT known to be compatible! Use C++ ScriptHook version 0.4.0 or the newest version of the game AND the C++ ScriptHook instead!

2011-03-24 01:25:46 - Direct3D device created!

 

2011-03-24 01:25:47 - SEARCHING FOR SCRIPTS...

2011-03-24 01:25:47 - Loading scripts in Assembly 'scripts\CarShop.net.dll' ...

2011-03-24 01:25:47 -  ...found script 'CarShopCS.CarShop'!

2011-03-24 01:25:47 -  ...found script 'CarShopCS.KeyCheck'!

2011-03-24 01:25:47 -  ...found script 'CarShopCS.Menus'!

2011-03-24 01:25:47 - Loading scripts in Assembly 'scripts\DriveFelony.net.dll' ...

2011-03-24 01:25:47 -  ...found script 'DriveFelony.DriveFelonyScript'!

2011-03-24 01:25:47 - Loading scripts in Assembly 'scripts\TrafficControlSystem.net.dll' ...

2011-03-24 01:25:47 -  ...found script 'TrafficControlCS.TrafficControl'!

2011-03-24 01:25:47 - DONE! 5 valid scripts found!

 

2011-03-24 01:25:47 - STARTING SCRIPTS...

2011-03-24 01:25:48 - INFO: Phone number checks are not available!

2011-03-24 01:25:48 -  ...successfully started script 'TrafficControlCS.TrafficControl'!

2011-03-24 01:25:48 -  ...successfully started script 'DriveFelony.DriveFelonyScript'!

2011-03-24 01:25:48 -  ...successfully started script 'CarShopCS.Menus'!

2011-03-24 01:25:48 - Error during NetHook.Tick:

                      System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

                         at unmanaged.NativeContext3.Invoke(Int32 nameptr, Byte[] args, Int32 argnum, NativeContext3* cxt)

                         at GTA.ScriptDomain.RemoteEvent(RemoteEventArgs ev)

                         at GTA.ScriptDomain.ProcessRemoteEvents()

                         at GTA.ScriptDomain.Tick()

                         at GTA.NetHook.Tick()

 

It's right there, in the log:

 

2011-03-24 01:24:30 - WARNING: Your C++ ScriptHook version 0.5.1 and GTA IV version 1.0.4.0 are NOT known to be compatible! Use C++ ScriptHook version 0.4.0 or the newest version of the game AND the C++ ScriptHook instead!

Share this post


Link to post
Share on other sites
xxLiannexx
is the list of objects/variables going to be extended to all of the same things that the c++ hook covers?

even those in the scriptingdirty.h (eventually)

Well yes, the target is to get full GTA4 scripting functionality with this. At the moment the amount of classes and contained functions is still limited. It takes alot of time to implement those functions into a easy-to-use class structure. however, the main problem is that a lot of stuff is still unknown/undocumented, whcih makes it very hard to implement those.

can you upload 1.0.4.0 scripthook nothing working not even the latest and the link to it :'(

Share this post


Link to post
Share on other sites
_Charger_

hey. need some help, i don't understand console command binding and GTA.base.Console.

 

 

BindConsoleCommand("vrivchangelog", new ConsoleCommandDelegate(logCom));

 

 

public void logCom(GTA.Script sender, GTA.ObjectCollection Parameter){        int lines = Settings.GetValueInteger("lines", "CHANGELOG", 0);        for (int i = 0; i < lines; i++)        {                                   string change = Settings.GetValueString("line" + Convert.ToString(i), "CHANGELOG", "No Changelog availible");                                   [email protected](change);        }         }

 

Share this post


Link to post
Share on other sites
MulleDK19
hey. need some help, i don't understand console command binding and GTA.base.Console.

 

 

BindConsoleCommand("vrivchangelog", new ConsoleCommandDelegate(logCom));

 

 

public void logCom(GTA.Script sender, GTA.ObjectCollection Parameter){        int lines = Settings.GetValueInteger("lines", "CHANGELOG", 0);        for (int i = 0; i < lines; i++)        {                                   string change = Settings.GetValueString("line" + Convert.ToString(i), "CHANGELOG", "No Changelog availible");                                   [email protected](change);        }         }

 

 

BindConsoleCommand("vrivchangelog", logCom);

 

 

 

public void logCom(ParameterCollection parameters)

 

Share this post


Link to post
Share on other sites
_Charger_
hey. need some help, i don't understand console command binding and GTA.base.Console.

 

 

BindConsoleCommand("vrivchangelog", new ConsoleCommandDelegate(logCom));

 

 

public void logCom(GTA.Script sender, GTA.ObjectCollection Parameter){        int lines = Settings.GetValueInteger("lines", "CHANGELOG", 0);        for (int i = 0; i < lines; i++)        {                                   string change = Settings.GetValueString("line" + Convert.ToString(i), "CHANGELOG", "No Changelog availible");                                   [email protected](change);        }         }

 

 

BindConsoleCommand("vrivchangelog", logCom);

 

 

 

public void logCom(ParameterCollection parameters)

 

thanks worked biggrin.gif

Share this post


Link to post
Share on other sites
TheGrim

Can someone help me with a sequencetask?

 

I wrote a script that spawns a ped then he will enter the closest vehicle, then drive to me.

 

The command I'm using is:

 

Driver.Task.DriveTo(Car, Player, 130.0F, False, True)

 

I've set ObeyTrafficLaws to false and AllowToDriveRoadsWrongWay to true.

 

 

But the problem is:

 

1.) The ped still drives on the road like everyone else, he don't drive on grass etc.

 

2.) When something gets in-front of him or if he crashes with the vehicle, then takes it again and something is in-front, like a wall, he just stay there like an idiot doing nothing. ( I made a function that checks if the ped is in a vehicle every second, if it's true, then the ped makes the tasksequence so there's nothing wrong with the code what i can see...)

Share this post


Link to post
Share on other sites
L0uNGeR

Hi there.

Nice work on this!

 

I've been away from GTA IV modding for a while but I want to get back into it now.

I used to have all my mods and tests in ScriptHook for 1.0.1.0 but since that doesn't work anymore and I really don't feel like porting it to a newer ScriptHook version, I decided to go with this hook and port all my mods to C# for some really easy coding.

 

It's just that I can't get it to work for some reason.

Here's everything I got:

 

GTA IV folder

 

[scripts]dsound.dll            --> AB's Asi Loader v1.0.2.0bScriptHook.dll        --> Aru's ScriptHook v0.5.1.0ScriptHookDotNet.asi  --> Hazard's .Net ScriptHook v1.7.1.7

 

asilog.txt

 

// -- GTA IV ASI LOADER LOG -- ////-- © Alexander Blade 2008 -- //C:\Windows\system32\dsound.dll is loaded, address 0x70A10000Hooking dsound proc named "DirectSoundCreate""DirectSoundCreate" hooked, address 0x70A17E3DHooking dsound proc named "DirectSoundEnumerateA""DirectSoundEnumerateA" hooked, address 0x70A5D993Hooking dsound proc named "DirectSoundEnumerateW""DirectSoundEnumerateW" hooked, address 0x70A5D9B0Hooking dsound proc named "DllCanUnloadNow""DllCanUnloadNow" hooked, address 0x70A441BBHooking dsound proc named "DllGetClassObject""DllGetClassObject" hooked, address 0x70A17792Hooking dsound proc named "DirectSoundCaptureCreate""DirectSoundCaptureCreate" hooked, address 0x70A5D2C5Hooking dsound proc named "DirectSoundCaptureEnumerateA""DirectSoundCaptureEnumerateA" hooked, address 0x70A5D9CDHooking dsound proc named "DirectSoundCaptureEnumerateW""DirectSoundCaptureEnumerateW" hooked, address 0x70A5D9EAHooking dsound proc named "GetDeviceID""GetDeviceID" hooked, address 0x70A5D160Hooking dsound proc named "DirectSoundFullDuplexCreate""DirectSoundFullDuplexCreate" hooked, address 0x70A5D429Hooking dsound proc named "DirectSoundCreate8""DirectSoundCreate8" hooked, address 0x70A4DE69Hooking dsound proc named "DirectSoundCaptureCreate8""DirectSoundCaptureCreate8" hooked, address 0x70A5D371Loading ASI D:\_WIN7\GTA 4\Grand Theft Auto IV\ScriptHookDotNet.asiASI loaded : D:\_WIN7\GTA 4\Grand Theft Auto IV\ScriptHookDotNet.asi, Address 0x00000000

 

I guess 0x00000000 can't be all that good, but I may be wrong.

 

With this setup, the .Net ScriptHook doesn't seem to work at all, I don't get any log, console or any change in-game whatsoever.

I've tested several script in the script folder: Plain C# script from the sample, a successfully compiled C# script from the sample, it makes no difference.

 

Anyone know what's going on?

Share this post


Link to post
Share on other sites
sjaak327

The asi loads with an exception address, so indeed that can't be good.

 

- Microsoft .Net Framework 4 - DOWNLOAD

- Microsoft Visual C++ 2010 Redistributable Package (x86) - DOWNLOAD (Make sure to install the linked x86 version, even on x64 systems!)

 

 

This from the OP, make sure you got those two covered.

 

 

Share this post


Link to post
Share on other sites
L0uNGeR

 

ASI loaded : D:\_WIN7\GTA 4\Grand Theft Auto IV\ScriptHookDotNet.asi, Address 0x67180000
`2011-04-17 16:14:00 - Initializing ScriptHookDotNet v1.7.1.7 BETA (on GTA IV version 1.0.7.0 with C++ Hook version 0.5.1)

 

Whoah I feel so stupid now...

I was missing the VC++2010 Redist.

 

Thanks for the heads up man wink.gif

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.


  • 2 Users Currently Viewing
    0 members, 0 Anonymous, 2 Guests

×
×
  • Create New...

Important Information

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