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

MulleDK19
In my opinion, it's always better to use Native functions if you know how to use them. If that works, create your own implementation class for blips using Natives. It's straightforward solution, its GTA4 native language, after all. There is a lots of function to use, even though many are still not documented well. We can't expect HazardX to do it all 100% by himself. But thanks to his migthty ScripHookDotNet, and Native class, everything is very easy.

It's all native. ScriptHook is just a wrapper.

 

It's simply a bug with the implementation of the new NonExistingObjectException in the new version.

 

 

If I wanted to use natives for everything, I would have just used the C++ hook.

Share this post


Link to post
Share on other sites
LMS

I'll investigate that.

Share this post


Link to post
Share on other sites
MulleDK19

 

In my opinion, it's always better to use Native functions if you know how to use them. If that works, create your own implementation class for blips using Natives. It's straightforward solution, its GTA4 native language, after all. There is a lots of function to use, even though many are still not documented well. We can't expect HazardX to do it all 100% by himself. But thanks to his migthty ScripHookDotNet, and Native class, everything is very easy.

It's all native. ScriptHook is just a wrapper.

 

It's simply a bug with the implementation of the new NonExistingObjectException in the new version.

 

 

If I wanted to use natives for everything, I would have just used the C++ hook.

Just made a small video.

 

I made excessive use of Exists() here, to prove that the object indeed does exist: http://www.treesoft.dk/gtaiv/GTAIV_ScriptH...ception_Bug.wmv

 

isInVehicle() also throws it sometimes.

Edited by MulleDK19

Share this post


Link to post
Share on other sites
FrozenFlame931

yo man when will this be updated for 1.0.0.4?

 

Share this post


Link to post
Share on other sites
Threepwood
You can use a normal native to see if someone brakes:

 

if (IsControlPressed(1,41))

 

41=brakekey.

Might sound dumb, but could you please do a short working example with it?

VC2010 Express refuses to let me use that in any way I could find.

Share this post


Link to post
Share on other sites
iriedreadlock23

MulleDK19 .. I have checked your video. It seems that ReturnAllBlipsOfType is giving you invalid handle. You should try not using Blip.Exists in first logic loop, but instead only Game.Exists or !=Null. Let me know if it helps. Also put that native DOES_BLIP_EXIST, and see if it helps.

Share this post


Link to post
Share on other sites
FrozenFlame931

Cmon man pls update for 1.0.0.4 =(

Share this post


Link to post
Share on other sites
shadow85

yes this is what I am looking for, 1.0.0.4.

 

I have tried it on many other versions and it works but not on 1.0.0.4.

Share this post


Link to post
Share on other sites
MulleDK19
MulleDK19 .. I have checked your video. It seems that ReturnAllBlipsOfType is giving you invalid handle. You should try not using Blip.Exists in first logic loop, but instead only Game.Exists or !=Null. Let me know if it helps. Also put that native DOES_BLIP_EXIST, and see if it helps.

It doesn't matter how I retrieve the handle.

 

This will fail too:

 

Blip blp = Player.Character.AttachBlip();Wait(3000);blp.Delete(); //Exception

 

 

And like I said, I get the exception sometimes, on other things like Player.Character.CurrentVehicle, and even isInVehicle() throws it.

Share this post


Link to post
Share on other sites
MulleDK19
Cmon man pls update for 1.0.0.4 =(

1.0.0.4? That sounds extremely out-dated.

Share this post


Link to post
Share on other sites
HazardX

Okay, youl'll get your christmas present one day early. If you feel traditional don't open the archive until christmas eve. tounge.gif

 

 

NEW VERSION:

 

GTAIV .Net Script Hook v1.7.1.7 BETA

 

Changes in v1.7.1.7 BETA:

- Fixed Blip.Delete always causing an exception.

- Added Vehicle.LightsOn property to determine whether the front lights are turned on. (by LMS)

- Changed Vehicle.FixTire to also restore the correct tire model. (by LMS)

- Some more NonExistingObjectException checks.

 

 

 

[EDIT] On the topic of NonExistingObjectExceptions: Injecting code into a game is always a nasty and sometimes very instable thing to do. GTA4 has proven to be especially bitchy in several ways. There has always been many problems with objects dying off inexpectedly, be it due to the lack of checks in the script code or due to some sneaky actions of the game itself. This led to some very strange behavior and confusing sporadic error messages. The new NonExistingObject checks make sure that every object being used in your code is checked for it's existence once when it is first accessed each frame. This way the hook can determine situations that would have previously caused a serious mess-up and throw a NonExistingObjectException instead.

 

You should always make regular use of Exists() to check for object existence. But if you can't seem to get smooth results without NonExistingObjectExceptions being thrown occasionally then you should wrap up logical blocks of your code into try blocks that catch only NonExistingObjectExceptions. If any object inside the block dies off inexpectedly the try block will catch it and the script can continue to run after the block.

Edited by HazardX

Share this post


Link to post
Share on other sites
Threepwood

YES!!

 

xD Sadly I have no time the next days, but if everything goes right, I can release EPM 1.3 for new years day with proper flip up lights triggered by lights on/off =)

Take that, Hakumai tounge.gif

 

Thx a lot, Hazard, frohe Weihnacht wink.gif

Share this post


Link to post
Share on other sites
monster875.

 

YES!!

 

xD Sadly I have no time the next days, but if everything goes right, I can release EPM 1.3 for new years day with proper flip up lights triggered by lights on/off =)

Take that, Hakumai tounge.gif

 

Thx a lot, Hazard, frohe Weihnacht wink.gif

i can't wait till' u release V1.3 biggrin.gif, then my RX-7 headlights can be fullfilled

 

HazardX: nice update, thumpsup wink.gif

Share this post


Link to post
Share on other sites
Threepwood

Light on/off test does not work for Hakumai.

And, btw, anyone abled to get the code working I posted on the previous site?

Share this post


Link to post
Share on other sites
algrn912005

Ok I need some help with my script here please:

 

I want to draw a red rectangle in the top corner of the screen when a certain boolean variable is true. The problem is, when I set that variable to true, the variable inside the event stays the same false value. Here is an example of this script.

 

 

       Boolean isArmed = false;       public ShowArmed() {           this.PerFrameDrawing += new GraphicsEventHandler(this.ShowArmed_PerFrameDrawing);       }       public void setArmed(Boolean armStatus) {           isArmed = armStatus;       }       private void ShowArmed_PerFrameDrawing(object sender, GraphicsEventArgs e) {           if(isArmed){               e.Graphics.Scaling = FontScaling.ScreenUnits;               RectangleF armRect = new RectangleF(0F, 0F, 0.05F, 0.05F);               e.Graphics.DrawRectangle(armRect, armedNotice);           }       }

 

 

In another script, isArmed is set to true by running the setArmed function.

Now, when it is set to true, the rectangle does not show up.

Using some debugging techniques, when I show the value of isArmed right after the setArmed function is run, it returns the correct boolean value.

Now, using another debugging technique, I binded a key to show me the value of isArmed. When I press the key, it always shows false no matter if it was set as true;

It's as if the isArmed value reverts back to its original set value of false--it never stays at true when it is set as that.

Does anyone have a solution to this problem?

 

Thanks in advance.

Share this post


Link to post
Share on other sites
kris192

can one of you guys make a car spawn point script (if possible and not a car spawn script) please?

Share this post


Link to post
Share on other sites
monster875.
can one of you guys make a car spawn point script (if possible and not a car spawn script) please?

use the IV Coding request topic instead of using another ones topic!

Share this post


Link to post
Share on other sites
kris192

oh ok sorry

Share this post


Link to post
Share on other sites
4c1d

Hey I have some problems, allot of .NET scripts don't work for me, when I load a savegame it says in the upper left corner something with error and the name of the mod that couldn't load here is my screipthookdotnet.log

 

I have: GTA IV 1.0.7.0 / .NET Framework 4 / Scripthook 0.5.1.0 / Newest Xliveless asi loader

 

2010-12-28 14:59:08 - Initializing ScriptHookDotNet v1.7.1.7 BETA (on GTA IV version 1.0.7.0 with C++ Hook version 0.5.1)

2010-12-28 15:00:06 - Direct3D device created!

 

2010-12-28 15:00:08 - SEARCHING FOR SCRIPTS...

2010-12-28 15:00:09 - Loading scripts in Assembly 'scripts\GrabScript.net' ...

2010-12-28 15:00:09 - ...found script 'GrabScript.EveryoneGrabMeScript'!

2010-12-28 15:00:09 - ...found script 'GrabScript.GrabScript'!

2010-12-28 15:00:09 - Loading scripts in Assembly 'scripts\umbrella.net.dll' ...

2010-12-28 15:00:09 - ...found script 'umbrellaCS.umbrella'!

2010-12-28 15:00:09 - ...found script 'umbrellaCS.ManualFuncton'!

2010-12-28 15:00:09 - DONE! 4 valid scripts found!

 

2010-12-28 15:00:09 - STARTING SCRIPTS...

2010-12-28 15:00:09 - INFO: Phone number checks are not available!

2010-12-28 15:00:09 - ...successfully started script 'umbrellaCS.ManualFuncton'!

2010-12-28 15:00:10 - Error in constructor of script 'GrabScript.GrabScript':

System.MissingMethodException: Method not found: 'Void GTA.Script.set_RequiredVersion(Single)'.

at GTA.ScriptThread.LoadScriptNow()

2010-12-28 15:00:10 - Error in constructor of script 'GrabScript.EveryoneGrabMeScript':

System.MissingMethodException: Method not found: 'Void GTA.Script.set_RequiredVersion(Single)'.

at GTA.ScriptThread.LoadScriptNow()

2010-12-28 15:00:12 - ...successfully started script 'umbrellaCS.umbrella'!

2010-12-28 15:00:22 - Direct3D device lost!

2010-12-28 15:00:22 - SCRIPTS TERMINATED!

 

PLEASE HELP

Share this post


Link to post
Share on other sites
HazardX
2010-12-28 15:00:10 - Error in constructor of script 'GrabScript.GrabScript':

System.MissingMethodException: Method not found: 'Void GTA.Script.set_RequiredVersion(Single)'.

at GTA.ScriptThread.LoadScriptNow()

2010-12-28 15:00:10 - Error in constructor of script 'GrabScript.EveryoneGrabMeScript':

System.MissingMethodException: Method not found: 'Void GTA.Script.set_RequiredVersion(Single)'.

You are using an outdated version of the GrabScript.

Share this post


Link to post
Share on other sites
4c1d

but it happens allso to other mods, so mods that don't work are outdated and some might not work at all because there is no new version?

 

sorry for my weak english

Share this post


Link to post
Share on other sites
motorsport71

@HazardX

 

I can't get your Documentation file .chm to read directly from my desktop. Every selection i pick says "no page displayed." I'm learning to code off your examples in the SHDN download, but some views on available tasks, loops, native functions would help expand me my miniscule knowledge of spawning peds, bodyguards, vehicles, and combinations thereof. I'm working on a mod now, topic is on coding forum, and some additional examples / instruction would be spectacular. Thanks smile.gif

Share this post


Link to post
Share on other sites
MulleDK19
Okay, youl'll get your christmas present one day early. If you feel traditional don't open the archive until christmas eve. tounge.gif

 

 

NEW VERSION:

 

GTAIV .Net Script Hook v1.7.1.7 BETA

 

Changes in v1.7.1.7 BETA:

- Fixed Blip.Delete always causing an exception.

- Added Vehicle.LightsOn property to determine whether the front lights are turned on. (by LMS)

- Changed Vehicle.FixTire to also restore the correct tire model. (by LMS)

- Some more NonExistingObjectException checks.

 

 

 

[EDIT] On the topic of NonExistingObjectExceptions: Injecting code into a game is always a nasty and sometimes very instable thing to do. GTA4 has proven to be especially bitchy in several ways. There has always been many problems with objects dying off inexpectedly, be it due to the lack of checks in the script code or due to some sneaky actions of the game itself. This led to some very strange behavior and confusing sporadic error messages. The new NonExistingObject checks make sure that every object being used in your code is checked for it's existence once when it is first accessed each frame. This way the hook can determine situations that would have previously caused a serious mess-up and throw a NonExistingObjectException instead.

 

You should always make regular use of Exists() to check for object existence. But if you can't seem to get smooth results without NonExistingObjectExceptions being thrown occasionally then you should wrap up logical blocks of your code into try blocks that catch only NonExistingObjectExceptions. If any object inside the block dies off inexpectedly the try block will catch it and the script can continue to run after the block.

Yay, thank you biggrin.gif

 

 

 

Btw. There seems to be problems with the handling of tasks.

 

After having set a number of tasks, they simply break, and no matter how many or what kind of peds I spawn, and no matter what task I give them or how I give it to them, they just won't move. However, going native works just fine, it seems.

 

So I always have to reload the game world after 10 minutes of play.

Share this post


Link to post
Share on other sites
iriedreadlock23

MulleDK. I had the same issue, I also, solved it by using natives. Unfortunatelly, i came to the same conclusion, that TaskSequence can't hold too many tasks, as i needed over 100 tasks.

Share this post


Link to post
Share on other sites
SupahDOnkeh

Hi man, having some troubles with this. For some reason, it simply wont work. Im on the latest patch (EFLC) My asi loader works fine, got the lates C++ updates, everything you said you would need, but it simply wont work, its like it hasnt been installed.

 

This DOES work in GTA IV original, but I would like to use it in eflc for ambient wars (which was confirmed to work in eflc).

 

Thanks man.

Share this post


Link to post
Share on other sites
Donny78

Do you have the files in the EFLC folder ?

 

My setup is like so:

 

 

Program files (x86)/Rockstar Games/   Grand Theft Auto IV/       ScriptHook.dll       ScriptHookDotNet.asi       scripts/           mods here....    EFLC/       ScriptHook.dll       ScriptHookDotNet.asi       scripts/           mods here....

 

 

The scripthook.log will say "using game version (number)" if it's standard IV else it will say "using game version EFLC (number)" for EFLC.

 

A seperate log file will be in each game versions root.

Share this post


Link to post
Share on other sites
tgp1994

I was just reading the OP... will the project included support VS 2008 as well as '10? I have VS 2008 Pro (free for students @ dreamspark.com), and I just don't see the need of getting the next version.

Share this post


Link to post
Share on other sites
Donny78
I was just reading the OP... will the project included support VS 2008 as well as '10? I have VS 2008 Pro (free for students @ dreamspark.com), and I just don't see the need of getting the next version.

Use the express version, that's what I use.

Share this post


Link to post
Share on other sites
tgp1994
I was just reading the OP... will the project included support VS 2008 as well as '10? I have VS 2008 Pro (free for students @ dreamspark.com), and I just don't see the need of getting the next version.

Use the express version, that's what I use.

Still more downloading :\ Are you sure the project files aren't backwards compatible? Sure Microsoft must have been thinking ahead.

Share this post


Link to post
Share on other sites
Donny78

I assumed that the project would be compiled in 10 so I'd have to use 10, to be honest dude I've never checked.

 

You can always write it out in 08 then put the .cs file into the "scripts" folder, this way compatibility won't be an issue (I assume) as it's just like a txt script (not compiled). Saying that though if it's in need of a namespace which the 08 runtime or whatever doesn't have it may kick off.

 

Sorry for my pretty usless reply, I'd just test it out.

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.