Quantcast

Jump to content

» «
Photo

[BETA] GTAIV .Net ScriptHook

2,945 replies to this topic
MulleDK19
  • MulleDK19

    1337 Programmer

  • Members
  • Joined: 30 May 2009
  • Denmark

#2461

Posted 16 December 2010 - 10:23 PM

QUOTE (iriedreadlock23 @ Dec 16 2010, 21:08)
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.

LMS
  • LMS

    Punk-ass Bitch

  • Members
  • Joined: 30 Jun 2005

#2462

Posted 16 December 2010 - 10:31 PM

I'll investigate that.

MulleDK19
  • MulleDK19

    1337 Programmer

  • Members
  • Joined: 30 May 2009
  • Denmark

#2463

Posted 17 December 2010 - 05:08 PM Edited by MulleDK19, 17 December 2010 - 07:37 PM.

QUOTE (MulleDK19 @ Dec 16 2010, 22:23)
QUOTE (iriedreadlock23 @ Dec 16 2010, 21:08)
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....ception_Bug.wmv

isInVehicle() also throws it sometimes.

FrozenFlame931
  • FrozenFlame931

    Player Hater

  • Members
  • Joined: 05 Dec 2010

#2464

Posted 19 December 2010 - 05:32 AM

yo man when will this be updated for 1.0.0.4?

Threepwood
  • Threepwood

    Calm like a bomb.

  • Members
  • Joined: 13 Jul 2008

#2465

Posted 20 December 2010 - 10:14 AM

QUOTE (sjaak327 @ Nov 25 2010, 10:21)
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.

iriedreadlock23
  • iriedreadlock23

    Dr. Frankenstein

  • Members
  • Joined: 14 Jan 2009

#2466

Posted 20 December 2010 - 04:13 PM

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.

FrozenFlame931
  • FrozenFlame931

    Player Hater

  • Members
  • Joined: 05 Dec 2010

#2467

Posted 21 December 2010 - 09:17 AM

Cmon man pls update for 1.0.0.4 =(

shadow85
  • shadow85

    Rat

  • Members
  • Joined: 02 Dec 2008

#2468

Posted 22 December 2010 - 09:47 AM

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.

MulleDK19
  • MulleDK19

    1337 Programmer

  • Members
  • Joined: 30 May 2009
  • Denmark

#2469

Posted 23 December 2010 - 03:05 PM

QUOTE (iriedreadlock23 @ Dec 20 2010, 16:13)
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:
CODE
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.

MulleDK19
  • MulleDK19

    1337 Programmer

  • Members
  • Joined: 30 May 2009
  • Denmark

#2470

Posted 23 December 2010 - 03:06 PM

QUOTE (FrozenFlame931 @ Dec 21 2010, 09:17)
Cmon man pls update for 1.0.0.4 =(

1.0.0.4? That sounds extremely out-dated.

HazardX
  • HazardX

    pedestrian mangler

  • Members
  • Joined: 13 Dec 2008

#2471

Posted 23 December 2010 - 03:37 PM Edited by HazardX, 23 December 2010 - 04:00 PM.

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.

Threepwood
  • Threepwood

    Calm like a bomb.

  • Members
  • Joined: 13 Jul 2008

#2472

Posted 23 December 2010 - 04:38 PM

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

monster875.
  • monster875.

    Li'l G Loc

  • Members
  • Joined: 02 Aug 2010

#2473

Posted 23 December 2010 - 06:05 PM

QUOTE (Threepwood @ Dec 23 2010, 16:38)
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

Threepwood
  • Threepwood

    Calm like a bomb.

  • Members
  • Joined: 13 Jul 2008

#2474

Posted 24 December 2010 - 01:03 PM

Light on/off test does not work for Hakumai.
And, btw, anyone abled to get the code working I posted on the previous site?

algrn912005
  • algrn912005

    Player Hater

  • Members
  • Joined: 19 Jan 2009

#2475

Posted 25 December 2010 - 03:59 AM

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.

CODE

       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.

kris192
  • kris192

    Player Hater

  • Members
  • Joined: 25 Dec 2010

#2476

Posted 25 December 2010 - 08:32 PM

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

monster875.
  • monster875.

    Li'l G Loc

  • Members
  • Joined: 02 Aug 2010

#2477

Posted 25 December 2010 - 10:08 PM

QUOTE (kris192 @ Dec 25 2010, 20:32)
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!

kris192
  • kris192

    Player Hater

  • Members
  • Joined: 25 Dec 2010

#2478

Posted 26 December 2010 - 08:00 AM

oh ok sorry

4c1d
  • 4c1d

    Player Hater

  • Members
  • Joined: 14 Apr 2010

#2479

Posted 28 December 2010 - 04:14 PM

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

HazardX
  • HazardX

    pedestrian mangler

  • Members
  • Joined: 13 Dec 2008

#2480

Posted 28 December 2010 - 04:45 PM

QUOTE (4c1d @ Dec 28 2010, 17:14)
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.

4c1d
  • 4c1d

    Player Hater

  • Members
  • Joined: 14 Apr 2010

#2481

Posted 28 December 2010 - 08:20 PM

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

motorsport71
  • motorsport71

    newbie modder

  • Members
  • Joined: 20 Oct 2009

#2482

Posted 29 December 2010 - 04:50 AM

@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

MulleDK19
  • MulleDK19

    1337 Programmer

  • Members
  • Joined: 30 May 2009
  • Denmark

#2483

Posted 29 December 2010 - 09:18 AM

QUOTE (HazardX @ Dec 23 2010, 15:37)
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.

iriedreadlock23
  • iriedreadlock23

    Dr. Frankenstein

  • Members
  • Joined: 14 Jan 2009

#2484

Posted 29 December 2010 - 02:27 PM

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.

SupahDOnkeh
  • SupahDOnkeh

    Player Hater

  • Members
  • Joined: 30 Dec 2010

#2485

Posted 30 December 2010 - 01:24 AM

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.

Donny78
  • Donny78

    Zombie

  • Members
  • Joined: 18 Jul 2008

#2486

Posted 30 December 2010 - 02:02 PM

Do you have the files in the EFLC folder ?

My setup is like so:

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

tgp1994
  • tgp1994

    Wastelander

  • Members
  • Joined: 17 Apr 2008

#2487

Posted 30 December 2010 - 04:16 PM

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.

Donny78
  • Donny78

    Zombie

  • Members
  • Joined: 18 Jul 2008

#2488

Posted 30 December 2010 - 11:14 PM

QUOTE (tgp1994 @ Dec 30 2010, 16:16)
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.

tgp1994
  • tgp1994

    Wastelander

  • Members
  • Joined: 17 Apr 2008

#2489

Posted 30 December 2010 - 11:25 PM

QUOTE (Donny78 @ Dec 30 2010, 23:14)
QUOTE (tgp1994 @ Dec 30 2010, 16:16)
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.

Donny78
  • Donny78

    Zombie

  • Members
  • Joined: 18 Jul 2008

#2490

Posted 31 December 2010 - 12:56 AM

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.




2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users