Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    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. Design Your Own Mission
      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
    1. Announcements

    2. Forum Support

    3. Suggestions

[BETA] GTAIV .Net ScriptHook


HazardX
 Share

Recommended Posts

 

Dude, that was A W E S O M E! Keep up the good work  wow.gif

I have to agree, I want to see the next episode NAO!!! lol.gif I thought it was f*cking hilarious!

 

I know this doesn't have anything to do with the scripthook but if anyone has resident evil 5 and wants to test my new item/money trainer drop me a PM, I'd post the link but it's probably against forum rules or something. I'm going to release it on GCW when I find out if it works for more than just me. wink.gifShifty41s_beerhatsmilie2.gif I hate having only 1 PC. cryani.gif

Link to comment
Share on other sites

Looks really good!

 

OT: I'm currently asking myself if you need a tool where you can search all models easily (so you don't need 20tabs of gtamodding), read all scripts without decompiling them, search for all natives and getting displayed all the scripts where they were used and how R* used them (so you donn't need to search trough all scripts for 1 native). Here's a little preview of a very early alpha:

 

user posted image

 

So please tell me if you need something like this.

Link to comment
Share on other sites

How do I stop cars spawning in alleys?

World.GetNextPositionOnStreet()?

But the alley is part of the street, that is what i'm using

 

Just Checking if this is all right

Code

 

public BulletTime()   {       string Lilmcnessy = Settings.Filename;       //Settings.Filename = Lilmcnessy;       Keys Bull = Settings.GetValueKey("KEYS", "BULLETTIME", Keys.P);       BindKey(Bull, new KeyPressDelegate(Time));       this.Tick += new EventHandler(this.Time_Tick);   }

 

 

And ini, which is named lilmcnessy.ini

 

[bULLETTIME]KEYS = T

 

Just quoting myself to see if anyonje can help

 

How can I delete cars in an area when my scripts loads

I tried GTA.Native.Function.Call("CLEAR_AREA_OF_CARS" straight after public, but it didn't work

I need this so that if the scripts are reloaded my spawned cars can be deleted

Link to comment
Share on other sites

 

How can I delete cars in an area when my scripts loads

I tried GTA.Native.Function.Call("CLEAR_AREA_OF_CARS" straight after public, but it didn't work

I need this so that if the scripts are reloaded my spawned cars can be deleted

I'm sure the native you're using would clear all the cars and not just the ones spawned with your script. It might not work because you could be specifying some incorrect parameters. I'd suggest to store the vehicles in a global variable, that way you can use them later at any time.

 

I don't know how you will detect that your script is being reloaded though, I don't think there's an event method for that. Too bad there isn't an overridable Dispose method that we can use when the scripts are terminated or crash to remove any and all resources used by the script. :hint.hint: moto_whistle.gif

Link to comment
Share on other sites

I tried this GTA.Native.Function.Call("CLEAR_AREA", -1622f, 813f, 29f, 250.0f, true);

but it only deleted ones that were there before not things I have spawned

 

How could I say this properly

 

(!GTA.Native.Function.Call<bool>("Has_Car_Been_Damaged_By_Car", carlist, pc)) 

 

(carlist is the listed vehicle and pc, player current vehicle)

Link to comment
Share on other sites

I tried this GTA.Native.Function.Call("CLEAR_AREA", -1622f, 813f, 29f, 250.0f, true);

but it only deleted ones that were there before not things I have spawned

 

How could I say this properly

 

(!GTA.Native.Function.Call<bool>("Has_Car_Been_Damaged_By_Car", carlist, pc)) 

 

(carlist is the listed vehicle and pc, player current vehicle)

mark things (vehicles,peds,objects whatever) as no longer needed

Link to comment
Share on other sites

 

I tried this GTA.Native.Function.Call("CLEAR_AREA", -1622f, 813f, 29f, 250.0f, true);

but it only deleted ones that were there before not things I have spawned

 

How could I say this properly

 

(!GTA.Native.Function.Call<bool>("Has_Car_Been_Damaged_By_Car", carlist, pc)) 

 

(carlist is the listed vehicle and pc, player current vehicle)

mark things (vehicles,peds,objects whatever) as no longer needed

I can't do that if the script crashes or it is reloaded

I think I found a way anyway -- it worked

I just used getpeds and getvehicles and then deleted them

 

what can I do about the carlist though

if I use this

 

for (int g = bansheelist.Count - 1; g > -1; g--)               {                   if (Exists(bansheelist[g]))                   {                       if (bansheelist[g].Health > 0)                       {                           if ((!GTA.Native.Function.Call<bool>("Has_Car_Been_Damaged_By_Car", bansheelist[g], pc)) ||                           (!GTA.Native.Function.Call<bool>("Has_Car_Been_Damaged_By_Char", bansheelist[g], p)))                           {                               Game.DisplayText("Test");                          }

It just crashes

Edited by lilmcnessy
Link to comment
Share on other sites

 

what can I do about the carlist though

Are you checking that pc Exists before calling the native? That's the only reason I can see it crashing.

 

I'm assuming p is Player.Character and if so then you don't have to check if it exists, but it's not a bad habit to get into. If it's another ped than you MUST check if it exists as well.

Link to comment
Share on other sites

 

what can I do about the carlist though

Are you checking that pc Exists before calling the native? That's the only reason I can see it crashing.

 

I'm assuming p is Player.Character and if so then you don't have to check if it exists, but it's not a bad habit to get into. If it's another ped than you MUST check if it exists as well.

Ah yes I what was wrong, I didn't check if ped was in a car

but the native (!GTA.Native.Function.Call<bool>("Has_Car_Been_Damaged_By_Char", bansheelist[g], p))

Doesn't look like it works properly

 

How could I make a ped stay at a location

eg He gets into combat but after the combat is finished he runs back to his spawned location

Edited by lilmcnessy
Link to comment
Share on other sites

Hi guys!

 

I haven't been active for a long time, and I just found out I still have a funny little mod sitting on my harddrive smile.gif.

 

It's basically my custom-made trainer, with some nice extra's:

-Settings file (INI)

-You can customize the settings from in-game

-Some basic trainer stuff (turbo boost, FPS counter, etc)

-Select peds is the main portion, though.

This doesn't mean "select" as in "select the model", no it actually means selecting specific peds. An example: you press the E key. A light shines around niko indicating you are in "ped-select mode". Now you simply aim at peds to select them. They will get a light shining under them, and a Blip attached to them.

 

Now for the fun part devil.gif You can select what to apply to the peds. This includes;

-Die

-Delete

-Forced Hands-Up

-Burn

-Force

-Enter/Exit vehicle

-Fight <----- Very buggy, DO NOT USE.

 

-Ring of Death (creates a red ring of light around niko. Any peds coming into the ring will die)

 

Anyway, it's a little project of mine, for my personal use. I'll never be able to bring it up to shape to release it in any form, but maybe it can inspire some of you guys to do something with it?

The source code is here: http://ruby.pastebin.com/f74965d6b\

 

EDIT:

There's still a lot of bugs in this thing, but maybe it helps someone wink.gif

Link to comment
Share on other sites

I've already implemented your "Ring of Death" into my superjump script (I call it "Final Judgement" though), very similar to yours infact, just never got around to finishing up the rest of the script for a release. It creates a light around niko (color is customizable ofc) and as the radius increases it kills all peds or vehicles within the radius. It's nice because it doesn't just kill everything at once, it actually kills the closer entities before the further entities. It also sends them flying in the opposite direction as if the "explosion" was coming from niko's position, plus in the air with some rotation to give a nice after effect. I love running around holding down the hotkeys, so much fun just watching everything explode 2 blocks away (or in the middle of a crowded intersection)! The only downside is you can't use it on all missions. sad.gif

 

I planned on implementing some of the ped functions into my teleport script, since it contains a function to warp all peds or vehicles around niko. I was going to make a cyclable feature to choose which action to do on the peds or vehicles but just didn't get around to it. I had other things I wanted to test that took up more time than I anticipated, so when I was done I had already forgotten about it.

 

I also created a Blox Launcher, that shoots those glowing blocks randomly. When I say randomly, I mean the block models and not direciton. Just aim with any gun and fire away.. you can knock cars back flying but if you shoot a ped they mostly do an animation instead of just ragdolling. Still fun though! colgate.gif I was going to use the poolballs but they don't do anything when you hit a car or ped, even with tons of force. confused.gif

Link to comment
Share on other sites

Haha, cool Compmstr!

 

My Ring of Death is very primitive smile.gif. It's a very small ring around Niko.

I tried it with a very large ring first, but that didn't go too well. When the ring get's too big (I let it keep on growing), you could actually see the peds getting spawned and killed in the distance. (+ the light doesn't work well at a large distance).

 

EDIT:

I'll check out your superjump script now. Bad thing about GTA is my FPS stays around 15-18 wow.gif Dammit.

Link to comment
Share on other sites

I wanted to replicate Alexander Blade's "damage in car" script for Alice in .NET or C++, but I pretty much only know two native functions. The idea of the script is to remove player health based on damage taken by your car. Would this be very simple to do, or does it involve some tricks? If it's very easy maybe one of you coding gurus could write something up real quick? Or just give some tips? Thanks for any help, and sorry for being a know-nothing noob.

Edited by AngryAmoeba
Link to comment
Share on other sites

 

I wanted to replicate Alexander Blade's "damage in car" script for Alice in .NET or C++, but I pretty much only know two native functions. The idea of the script is to remove player health based on damage taken by your car. Would this be very simple to do, or does it involve some tricks? If it's very easy maybe one of you coding gurus could write something up real quick? Or just give some tips? Thanks for any help, and sorry for being a know-nothing noob.

Well if I remember correctly, the normal health of cars is 1000. So you just divide this by 10 and then set players health to it. Or was the mod relative, I mean if you entered a damaged vehicle was your health instantly set to the vehicles health or did it just changed as soon as the vehicle got damaged? If so, you can save the health the car had when entered and subtract the current health and divide this by 10 and then subtract it from player health. Hope you understand that wink.gif

Link to comment
Share on other sites

 

I wanted to replicate Alexander Blade's "damage in car" script for Alice in .NET or C++, but I pretty much only know two native functions. The idea of the script is to remove player health based on damage taken by your car. Would this be very simple to do, or does it involve some tricks? If it's very easy maybe one of you coding gurus could write something up real quick? Or just give some tips? Thanks for any help, and sorry for being a know-nothing noob.

Here is my interpretation of A.Blade's 'Damage in Car ' Script...

http://oinkoink.pastebin.com/f6dba8701

...I was a lil bit pixilated while writing this snippet, maybe there's a better way.

 

 

Hey, i've been trying to access the console, but i don't have a US keyboard with the ~ key. So how will i do it?

I'm not sure (I got a german keyboard), but I think it's always the key under the 'esc' key, above the 'tab' key, on the left side of the '1' key.

 

Greetz! Shifty41s_beerhatsmilie2.gif

Link to comment
Share on other sites

I am working on a ini file again

I can make it get a value but I don't know why I can't get a key

How can I change the name of ini file?

Edited by lilmcnessy
Link to comment
Share on other sites

 

Hey, i've been trying to access the console, but i don't have a US keyboard with the ~ key. So how will i do it?

I'm not sure (I got a german keyboard), but I think it's always the key under the 'esc' key, above the 'tab' key, on the left side of the '1' key.

 

Greetz! Shifty41s_beerhatsmilie2.gif

that button works on me in other games like CoD4 but not on IV cryani.gif

 

EDIT: ok i got it working now, i needed to press "ö"

Edited by Kuppih
Link to comment
Share on other sites

 

I am working on a ini file again

I can make it get a value but I don't know why I can't get a key

How can I change the name of ini file?

Here is a lil example how to load another ini file and how to get the key value...

 

    public class ToggleConsole : Script   {       private SettingsFile Ini;       private Keys ConsoleKey;       public ToggleConsole()       {           GeneralInfo = "ToggleConsole Script...";           Ini = SettingsFile.Open(Game.InstallFolder + "\\scripts\\ToggleConsole.ini");           Ini.Load();           ConsoleKey = Ini.GetValueKey("ConsoleKey", "Config", Keys.F12);           this.KeyDown += new GTA.KeyEventHandler(this.OpenConsole);           BindConsoleCommand("CloseConsole", new ConsoleCommandDelegate(this.CloseConsole), "- Close Console");       }       private void OpenConsole(object sender, GTA.KeyEventArgs e)       {           if (e.Key == ConsoleKey)           {               Game.Console.Open();           }       }       private void CloseConsole(ParameterCollection Parameter)       {           Game.Console.Close();       }   }

 

...and here is the ini content...

 

[Config]ConsoleKey = F9

 

...you can also use key-codes.

That snippet is also a 'detour' solution for Kuppih's prob, but it's already solved.

 

@Kuppih: Good to know that it's working now and I think 'ö' is ok...strange but ok.

No one would use that key for script binding. wink.gif

 

Greetz!

 

Link to comment
Share on other sites

Thanks a lot for the Damage in Car scripts. I saved CoMPMStR's revision to a file and it doesn't seem to need any more revision, works perfectly. I just changed the divisor of the car damage from 15 to 10 to make it a little less forgiving. Thanks again, you did all the work!

 

EDIT: Bullet damage to the car hurts the player. Is there any way to distinguish between collisions and bullets?

Edited by AngryAmoeba
Link to comment
Share on other sites

How can I add GPS tracking to created coords-blip? ( solved )

 

EDIT:

Value of Vehicle.Speed is in what unit? m/s ?

 

EDIT:

 

When I trying to edit WindowExample.cs with designer it throws me error: The base class 'GTA.Forms.Form' could not be loaded". I have Visual Studio 2008.

 

EDIT:

lolz, when I created new "script" from plain project now ScriptHook doesn't recognize it. I've set net framework 2.0 in project properties, but it isn't it. ;/ ( solved, output name was different that what scripthook respects smile.gif )

Edited by Kofel
Link to comment
Share on other sites

 

How can I add GPS tracking to created coords-blip?

 

EDIT:

Value of Vehicle.Speed is in what unit? m/s ?

 

EDIT:

 

When I trying to edit WindowExample.cs with designer it throws me error: The base class 'GTA.Forms.Form' could not be loaded". I have Visual Studio 2008.

 

EDIT:

lolz, when I created new "script" from plain project now ScriptHook doesn't recognize it. I've set net framework 2.0 in project properties, but it isn't it. ;/

I don't think GPS tracking is yet available for the coord blips, what I did was use an invisible ped instead. Just create a ped at the same location with the visible property set to false and attach a blip to it, then do what you want with the blip from there. You can optionally use the native ("SET_CHAR_COLLISION", ped, enabled) to disable the ped collision so you don't have an invisible ped blocking the way. wink.gif Also don't forget to freeze the ped's position. biggrin.gif

 

I almost certain that the game units are in meters so speed and such should be m/s, sorry if I'm wrong.

 

You can't edit any GTA.Forms.Form from VS, you will have to add the controls manually with code or use my visual dialog designer I posted a few pages back (I forgot which page). We are still waiting for Hazard to implement visual form design from VS so when he does you won't get this error anymore.

 

In your new script, did you add Inherits Script directly beneath the Class declaration. For example:

 

Public Class MyScriptInherits Script...

 

 

For C# it would be something like:

 

public class MyScript : Script...

 

 

 

@AngryAmoeba: You can try the native ("HAS_CAR_BEEN_DAMAGED_BY_WEAPON", vehicle, weapon) and use the weapon enum Misc_AnyWeapon. I'm not sure if the native ("CLEAR_CAR_LAST_WEAPON_DAMAGE", vehicle) will be of any use but it's there as well for a reason. lol.gif

Link to comment
Share on other sites

 

How can I add GPS tracking to created coords-blip?

 

EDIT:

Value of Vehicle.Speed is in what unit? m/s ?

 

EDIT:

 

When I trying to edit WindowExample.cs with designer it throws me error: The base class 'GTA.Forms.Form' could not be loaded". I have Visual Studio 2008.

 

EDIT:

lolz, when I created new "script" from plain project now ScriptHook doesn't recognize it. I've set net framework 2.0 in project properties, but it isn't it. ;/

I don't think GPS tracking is yet available for the coord blips, what I did was use an invisible ped instead. Just create a ped at the same location with the visible property set to false and attach a blip to it, then do what you want with the blip from there. You can optionally use the native ("SET_CHAR_COLLISION", ped, enabled) to disable the ped collision so you don't have an invisible ped blocking the way. wink.gif Also don't forget to freeze the ped's position. biggrin.gif

 

I almost certain that the game units are in meters so speed and such should be m/s, sorry if I'm wrong.

 

You can't edit any GTA.Forms.Form from VS, you will have to add the controls manually with code or use my visual dialog designer I posted a few pages back (I forgot which page). We are still waiting for Hazard to implement visual form design from VS so when he does you won't get this error anymore.

 

In your new script, did you add Inherits Script directly beneath the Class declaration. For example:

 

Public Class MyScriptInherits Script...

 

 

For C# it would be something like:

 

public class MyScript : Script...

 

 

 

@AngryAmoeba: You can try the native ("HAS_CAR_BEEN_DAMAGED_BY_WEAPON", vehicle, weapon) and use the weapon enum Misc_AnyWeapon. I'm not sure if the native ("CLEAR_CAR_LAST_WEAPON_DAMAGE", vehicle) will be of any use but it's there as well for a reason. lol.gif

I found how to add gps tracking for coords-blip.

Blip b = Blip.AddBlip( Vector3( 0.0f, 0.0f, 0.0f ) );b.RouteActive = true;

have fun.

 

Ahh, I used your designer but when I load a form object scripthook throws: "System.NullReferenceException: Object reference not set to an instance of an object. at GTA.ScriptThread.LoadScriptNow()"

 

I created new project but doesn't called output like test.net.dll, but test.dll smile.gif fixed.

 

 

EDIT:

 

I developing a Bus Mod. With this mod we are able to drive by stops. There is not only one "line". Now I only have to make a GUI smile.gif ( does somebody have nice speedometer with source code created in c# ? )

Edited by Kofel
Link to comment
Share on other sites

 

@AngryAmoeba: You can try the native ("HAS_CAR_BEEN_DAMAGED_BY_WEAPON", vehicle, weapon) and use the weapon enum Misc_AnyWeapon. I'm not sure if the native ("CLEAR_CAR_LAST_WEAPON_DAMAGE", vehicle) will be of any use but it's there as well for a reason. lol.gif

I put that native in the script like this:

 

 

if (GTA.Native.Function.Call("HAS_CAR_BEEN_DAMAGED_BY_WEAPON", pv, "Misc_AnyWeapon")){   CarHealth = pv.Health;   break;}

 

 

The console tells me it "cannot implicitly convert type 'void' to 'bool'." If this function doesn't return anything, what is it good for? Did I do something wrong?

Link to comment
Share on other sites

Try it like this...

 

if (!GTA.Native.Function.Call<bool>("HAS_CAR_BEEN_DAMAGED_BY_WEAPON", pv, (int)Weapon.Misc_AnyWeapon)){        cHealth = (CarHealth - cHealth) / 15;        pc.Health -= cHealth;        CarHealth = pv.Health;}

 

...I didn't tested it, but it should work...

 

Edit//-->

Tested it and it works so far, but if you crash and get shot at the same time your health will not decrease.

Needs a lil bit more tweaking...

...http://oinkoink.pastebin.com/f2abd6de1

 

Greetz!

 

Edited by oinkoink
Link to comment
Share on other sites

@AngryAmoeba: You can try the native ("HAS_CAR_BEEN_DAMAGED_BY_WEAPON", vehicle, weapon) and use the weapon enum Misc_AnyWeapon. I'm not sure if the native ("CLEAR_CAR_LAST_WEAPON_DAMAGE", vehicle) will be of any use but it's there as well for a reason. lol.gif

I put that native in the script like this:

 

 

if (GTA.Native.Function.Call("HAS_CAR_BEEN_DAMAGED_BY_WEAPON", pv, "Misc_AnyWeapon")){   CarHealth = pv.Health;   break;}

 

 

The console tells me it "cannot implicitly convert type 'void' to 'bool'." If this function doesn't return anything, what is it good for? Did I do something wrong?

 

GTA.Native.Parameter[] par = new GTA.Native.Parameter[2];par[0] = pv;par[1] = Weapon.Misc_AnyWeapon;GTA.Native.Function.Call("HAS_CAR_BEEN_DAMAGED_BY_WEAPON", par);if( (bool) GTA.Native.Pointer ){//If returns trueCarHealth = pv.Health;break;}

 

 

I don't know does it will work, but when because I only looked into Object Browser for that smile.gif

Link to comment
Share on other sites

 

Try it like this...

 

if (!GTA.Native.Function.Call<bool>("HAS_CAR_BEEN_DAMAGED_BY_WEAPON", pv, (int)Weapon.Misc_AnyWeapon)){        cHealth = (CarHealth - cHealth) / 15;        pc.Health -= cHealth;        CarHealth = pv.Health;}

 

...I didn't tested it, but it should work...

 

Edit//-->

Tested it and it works so far, but if you crash and get shot at the same time your health will not decrease.

Needs a lil bit more tweaking...

Thanks again! Man, my first guess looks pretty dumb now. Anyway the crash + get shot bug doesn't seem too bad, so I'll leave it because I can't think of any way to fix it. I just added a threshold so minor crashes don't hurt.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

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