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

    1. Red Dead Redemption 2

      1. Gameplay
      2. Missions
      3. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Arena War
      2. After Hours
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA Next

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

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

    2. Forum Support

    3. Site Suggestions

HazardX

[BETA] GTAIV .Net ScriptHook

Recommended Posts

boomer678
this question was for HazardX, but thanks anyway.

 

I asked is there a way to push/apply force to any created object with HazardX's ScriptHook library, or with any Native function. So objects actually fall from the sky.

Ah .... there might be a native. you would have to look.

Share this post


Link to post
Share on other sites
SlingShotUK

Hi Hazard,

 

Could the console reload problem be affecting normal game reloading?

 

I only ask because I installed the hook for the first time tonight along with a single mod - the super spawner script.

 

This works fine but as soon as I load up a save game GTA crashes. As soon as I removed the .NET hook it worked fine again.

 

Any ideas?

Share this post


Link to post
Share on other sites
CoMPMStR

Are there any examples on how to utilize the console commands yet? I'm trying to print some strings to the console but I don't know how the method is called. I already tried calling GTA.Console and I also tried assigning it to a variable, but I don't know what to assign to the variable so it isn't null.

Share this post


Link to post
Share on other sites
HazardX

 

Could the console reload problem be affecting normal game reloading?

Sadly, yes. confused.gif I'm working hard to fix it, but no luck yet. There is a very nasty conflict between the unmanged threads and the .Net Garbage Collector.

 

@iriedreadlock23: You could change the Velocity of the Object. ApplyForce is already included, but i can't release a new version until the crashing problem is solved. sad.gif

 

@CoMPMStR: use the existing console. it's Game.Console . Use Game.Console.Print to write text to the console window and Game.Console.SendCommand to send a console command by script. If you want to catch console commands in your script you have to override the "ConsoleCommand" method in your script class.

Edited by HazardX

Share this post


Link to post
Share on other sites
SlingShotUK
Could the console reload problem be affecting normal game reloading?

Sadly, yes. confused.gif I'm working hard to fix it, but no luck yet. There is a very nasty conflict between the unmanged threads and the .Net Garbage Collector.

No problem at all Hazard - thanks for confirming the problem. I know you will fix this so I'm happy to wait. Just good to know that it's not a problem with my config.

 

Was exciting to try the mods last night.. I'm really getting into the idea of making my own.

 

The main thing I'd like to learn though is how to do menu's etc (like used on the in game trainer mod). Would love to see some code examples on how to achieve this kind of effect if possible..

Share this post


Link to post
Share on other sites
CoMPMStR

After I got the console to print (thanks hazard smile.gif ), I ran across another little problem. This time I'm messing around with the PerFrameDrawing method. I put a line to draw a rectangle, in the center, but it doesn't show anything.

 

 

Graphics.DrawRectangle(Game.Resolution.Width / 2, Game.Resolution.Height / 2, 100, 100, Drawing.Color.Blue)

 

 

This is how you'd do it right? When I go ingame, there's no rectangle there.

Just so you know, I added the references and imports for System.Drawing which is why I don't know why it's not working. Thanks in advance. biggrin.gif

 

 

EDIT: I'm not only talking to HazardX. Anyone who know's what's the problem, or how to solve this is more than welcome to post the solution. cookie.gif <---- For the one who comes forward with the answer. biggrin.gif

Edited by CoMPMStR

Share this post


Link to post
Share on other sites
diryboy

hi, hazard, i think adding these methods into Script class would be cool:

 

 

 protected void BindKey(Keys key, Action action); 

 

and

 

 protected void RegisterCheatCode(string code, Action action); 

 

 

Action is a delegate:

 

 

 public delegate void Action(); 

 

 

doing that enable us to write the script in a more descriptive way, we can call these two methods in the constructor like:

 

 

public MyScript(){   BindKey(Keys.O, SpawnCar);   RegisterCheatCode("GiveMeChicks", GiveMeChicks);}

 

 

then we could write the private method to implement SpawnCar and GiveMeChicks instead of playing with the switch blocks.

 

it's also convient to override OnKeyDown method to provide our own logic, but providing these two common feature would be absolutely free the developer from dealing with the input in most common occasion.

 

maybe it's possible to do this with a Dictionary<Keys, Action> and a Queue<char> internally. i hope you can include these features in the next version.

 

ps: i love the console, it's great! smile.gif

Edited by diryboy

Share this post


Link to post
Share on other sites
Indi

Can anyone go through with me on how to change your character?

Share this post


Link to post
Share on other sites
Phnx

Could someone provide a script to center the camera behind Niko when unarmed and when in a car center it behind the car (not Niko)? That would be awesome! smile.gif

Share this post


Link to post
Share on other sites
pwd

I'm trying to play around with peds that attack. I'm using the script in TestScripts as a base.

 

Here is what I have done(basic modifacations):

 

Public Class AttackScript  Inherits Script  Private FleeTask As New TaskSequence  Protected Overrides Sub Startup()     ' Add tasks to the TaskSequence     FleeTask.AddTask.SwapWeapon(Weapon.Handgun_Glock)       FleeTask.AddTask.FightAgainst(Player, -1)       'FleeTask.AddTask.FleeFromChar(Player, False, 5000)       'FleeTask.AddTask.Die()  End Sub  Protected Overrides Sub KeyDown(ByVal key As Keys)     If key <> Keys.K Then Return     Dim p As Ped = World.CreatePed(Player.Character.Position.Around(3.0F))     p.CurrentRoom = Player.Character.CurrentRoom     p.Weapons.Glock.Ammo = 1000       p.Task.PerformSequence(FleeTask)       p.Health = 500  End SubEnd Class

 

 

Bassically I would like to have a random ped spawn then attack forever. The -1 seems to work, but it always crashes after a while of playing. I like this idea because I like being chased in a car(the spawned ped does, most of the time, hop in a car). I'm assumeing if I spawn a ped with a submachine gun, they will attack from the car? Is there a way to spawn an attacking ped without a task sequence? i'd appreciate some help. Thanks!

Share this post


Link to post
Share on other sites
CoMPMStR

 

I'm trying to play around with peds that attack. I'm using the script in TestScripts as a base.

 

Here is what I have done(basic modifacations):

 

submitted code

 

 

Bassically I would like to have a random ped spawn then attack forever. The -1 seems to work, but it always crashes after a while of playing. I like this idea because I like being chased in a car(the spawned ped does, most of the time, hop in a car). I'm assumeing if I spawn a ped with a submachine gun, they will attack from the car? Is there a way to spawn an attacking ped without a task sequence? i'd appreciate some help. Thanks!

This is how I'd do it:

 

 

    Protected Overrides Sub KeyDown(ByVal key As Keys)       If key = Keys.K Then           Dim p As Ped = World.CreatePed(World.GetGroundPosition(Player.Character.Position.Around(3.0F)))           If Exists(p) Then               p.CurrentRoom = Player.Character.CurrentRoom               p.Health = 500               p.Weapons(Weapon.Handgun_Glock).Ammo = 1000               p.Weapons(Weapon.Handgun_Glock).Select()               p.Task.FightAgainst(Player.Character, Integer.MaxValue)           End If       End If   End Sub

 

 

I hope it helps. smile.gif

Share this post


Link to post
Share on other sites
pwd

That works great! Thanks alot CoMPMStR.

Share this post


Link to post
Share on other sites
Canada505

Hello yesterday I installed .Net ScriptHook by Hazard to play with Compmaster SuperSpawn script.

 

When I try to run GTA I hear only some ERROR sound and nothing happens.

 

From Alexander Blade ASI loader I get this code:

 

 

....Loading ASI C:\Program Files\Rockstar Games\Grand Theft Auto IV\PlayerSelector.asiASI loaded : C:\Program Files\Rockstar Games\Grand Theft Auto IV\PlayerSelector.asi, Address 0x036D0000[b]Loading ASI C:\Program Files\Rockstar Games\Grand Theft Auto IV\ScriptHookDotNet.asi[/b]

 

 

and nothing.

 

Tryed with:

NET Framework 2.0, 3.5

Alexander Blade ASI loader

YAASIL loader

GTA IV version 1.0.2.0 (original)

 

 

When I close my PC I get "Microsoft Visual ... Error" - after trying this mod.

 

Can someone help me ?

 

Share this post


Link to post
Share on other sites
pwd

Hmm, so are you able to load a saved game or does it just crash when you start GTA? Did you check the log file in the GTA folder?

Share this post


Link to post
Share on other sites
Canada505

It crash when I start GTA.

 

My full ASI log:

 

 

// -- GTA IV ASI LOADER LOG -- ////-- © Alexander Blade 2008 -- //C:\WINDOWS\system32\dsound.dll is loaded, address 0x73EA0000Hooking dsound proc named "DirectSoundCreate""DirectSoundCreate" hooked, address 0x73EA473BHooking dsound proc named "DirectSoundEnumerateA""DirectSoundEnumerateA" hooked, address 0x73EC708DHooking dsound proc named "DirectSoundEnumerateW""DirectSoundEnumerateW" hooked, address 0x73EC70AAHooking dsound proc named "DllCanUnloadNow""DllCanUnloadNow" hooked, address 0x73ECBE61Hooking dsound proc named "DllGetClassObject""DllGetClassObject" hooked, address 0x73EB09C5Hooking dsound proc named "DirectSoundCaptureCreate""DirectSoundCaptureCreate" hooked, address 0x73EC68BBHooking dsound proc named "DirectSoundCaptureEnumerateA""DirectSoundCaptureEnumerateA" hooked, address 0x73EC70C7Hooking dsound proc named "DirectSoundCaptureEnumerateW""DirectSoundCaptureEnumerateW" hooked, address 0x73EC70E4Hooking dsound proc named "GetDeviceID""GetDeviceID" hooked, address 0x73EC6D42Hooking dsound proc named "DirectSoundFullDuplexCreate""DirectSoundFullDuplexCreate" hooked, address 0x73EC6A32Hooking dsound proc named "DirectSoundCreate8""DirectSoundCreate8" hooked, address 0x73EC67F5Hooking dsound proc named "DirectSoundCaptureCreate8""DirectSoundCaptureCreate8" hooked, address 0x73EC696FLoading ASI C:\Program Files\Rockstar Games\Grand Theft Auto IV\Alice.asiASI loaded : C:\Program Files\Rockstar Games\Grand Theft Auto IV\Alice.asi, Address 0x033B0000Loading ASI C:\Program Files\Rockstar Games\Grand Theft Auto IV\Car Bomber.asiASI loaded : C:\Program Files\Rockstar Games\Grand Theft Auto IV\Car Bomber.asi, Address 0x034F0000Loading ASI C:\Program Files\Rockstar Games\Grand Theft Auto IV\God Mode.asiASI loaded : C:\Program Files\Rockstar Games\Grand Theft Auto IV\God Mode.asi, Address 0x03640000Loading ASI C:\Program Files\Rockstar Games\Grand Theft Auto IV\Guards.asiASI loaded : C:\Program Files\Rockstar Games\Grand Theft Auto IV\Guards.asi, Address 0x03680000Loading ASI C:\Program Files\Rockstar Games\Grand Theft Auto IV\PlayerSelector.asiASI loaded : C:\Program Files\Rockstar Games\Grand Theft Auto IV\PlayerSelector.asi, Address 0x036D0000Loading ASI C:\Program Files\Rockstar Games\Grand Theft Auto IV\ScriptHookDotNet.asi

 

Share this post


Link to post
Share on other sites
algrn912005

try using the xliveless asi loader

Share this post


Link to post
Share on other sites
Canada505

Thx you algrn912005 now it works smile.gif !

Share this post


Link to post
Share on other sites
CoMPMStR

 

Thx you algrn912005 now it works smile.gif !

Hmm that's weird that Hazard's own ASI loader doesn't work with his compiled ASI. confused.gif I use xliveless though, so I've never had problems. biggrin.gif

Share this post


Link to post
Share on other sites
algrn912005

is it possible to create new lines with the Game.DisplayText function? When I use \n is doesn't work and is still on the same line.

Share this post


Link to post
Share on other sites
loczek47

Hey HazardX, what's the .p for glock weapon? I mean, this is for MP5: p.Weapons.SMG_MP5.Ammo = 30000; and what is for Glock? (the black pistol with 17 bullets in magazine)

Share this post


Link to post
Share on other sites
Donny78

 

 

Graphics.DrawRectangle(Game.Resolution.Width / 2, Game.Resolution.Height / 2, 100, 100, Drawing.Color.Blue)

 

 

 

I think the screen is from 0.0 to 1.0 so try:

 

 

Graphics.DrawRectangle( 0.5, 0.5, 0.1, 0.1, Drawing.Color.Blue)

 

 

That should make a box at the center of the screen which is 80x60 pixels based off an 800x600 canvas or maybe I'm wrong about the 80x60 but it shouldn't be that big on your screen.

 

Share this post


Link to post
Share on other sites
loczek47
Hey HazardX, what's the .p for glock weapon? I mean, this is for MP5: p.Weapons.SMG_MP5.Ammo = 30000; and what is for Glock? (the black pistol with 17 bullets in magazine)

Bump, because I'm afraid hazardX won't read previous page biggrin.gif

Share this post


Link to post
Share on other sites
Donny78

 

Hey HazardX, what's the .p for glock weapon? I mean, this is for MP5: p.Weapons.SMG_MP5.Ammo = 30000; and what is for Glock? (the black pistol with 17 bullets in magazine)

Bump, because I'm afraid hazardX won't read previous page biggrin.gif

It would be Glock wouldn't it ?

 

 

p.Weapons.Glock.

 

Share this post


Link to post
Share on other sites
loczek47

Nah I don't think so, but I will check it out. I don't think so because most of weapons have realy long names "Assault_Rifle_M4" etc.

EDIT: It works, thank You.

Edited by loczek47

Share this post


Link to post
Share on other sites
Intosia

Why is 'Model.name' property not working? It says in not in the final build? Or something? Tobad, would be usefull.

Share this post


Link to post
Share on other sites
HazardX

Please excuse my silence, i've been visiting Brussels (in Belgium, very interesting city BTW) in the last days and thus haven't been to the boards.

 

@loczek47: It is indeed just "Glock". I thought the name was obvious enough by itself. It is best to use Visual Studio to edit the scripts, it will show you exactly which names are available.

 

@CoMPMStR: Screen coordinates are always in range 0.0 to 1.0 , just as Donny78 said.

 

@diryboy: Your BindKey and RegisterConsoleCommand suggestions would be great additions. I guess i'll implement them.

 

@Intosia: I never tried it. Just included it because the related native function sounded fitting. The problem is that models are given as hash-codes of the name. Turning the hashcode into the full name again is not possible unless the game provides such a function for known model names.

Edited by HazardX

Share this post


Link to post
Share on other sites
iriedreadlock23

How could i set object velocity? I am trying to get information from the function, GET_OBJECT_VELOCITY, but i get long number from it... 12395813... something like this... i will try now if setting velocity will work... let me know if you know tested way to set velocity.. Thanks

Share this post


Link to post
Share on other sites
Phnx
Could someone provide a script to center the camera behind Niko when unarmed and when in a car center it behind the car (not Niko)? That would be awesome! smile.gif

No way to do it?! sad.gif

Share this post


Link to post
Share on other sites
SlingShotUK
Please excuse my silence, i've been visiting Brussels (in Belgium, very interesting city BTW) in the last days and thus haven't been to the boards.

Hey great city to visit. We went there for the first time last July. Some nice architecture although I much preferred visiting the many cool bars and indulging (or is that over-indulging) on lovely Belgium fruit beers.. wink.gif

 

Did you do a lot while you were there?

Share this post


Link to post
Share on other sites
algrn912005
is it possible to create new lines with the Game.DisplayText function? When I use \n is doesn't work and is still on the same line.

lol my post got buried... so can anyone answer?

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.


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