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

After I install this, I try to start up the game and I get an error message.

 

"Runtime Error!

 

Program: E:...

 

R6030

-CRT not initialized."

 

Any idea what's wrong? Is the fact that my main drive is named E: and not C: screwing it up? It's caused some installation issues with other things before.

Link to comment
Share on other sites

Alright, sorry for the double post. My game starts now, but it crashes when I load into the game world. None of the ASI loaders work. It just gives me a "GTA IV has encountered an error and needs to close" error. Any ideas?

Link to comment
Share on other sites

 

  <snip>

Hmm i had this idea. I think you could use. player.character.currentvehicle.speed = storedspeed.

 

if e.key = keys.e then

stored speed = player.character.currentvehicle.speed

something = true

then in a timer

if something = true then

player.character.currentvehicle.speed = storedspeed

 

 

But tweak it ( tahts just the basic concept , That i think will work( im not sure )

* just say if u want more code( because thast not whole thing )

Thanks for your reply! I've been working on it for a bit, you can look at it here:

http://wordpress.pastebin.com/m6407de20

 

It's in C#.

 

What it does now:

1.When the player presses the key, cruise control is activated.

2. When the player presses the key again, or presses W,S or Space, or exits the car, the cruisecontrol is de-activated.

3. The current car speed is set to be the saved carspeed each tick, but not when the car is in the air.

 

But it's still not complete. The car can keep ramming into walls and you get a massive speedboost when you get back on the ground from a jump.

 

EDIT:

I want to say again: using SendKeys.SendWait(string) will freeze the game!

Edited by thaCURSEDpie
Link to comment
Share on other sites

  <snip>

Hmm i had this idea. I think you could use. player.character.currentvehicle.speed = storedspeed.

 

if e.key = keys.e then

stored speed = player.character.currentvehicle.speed

something = true

then in a timer

if something = true then

player.character.currentvehicle.speed = storedspeed

 

 

But tweak it ( tahts just the basic concept , That i think will work( im not sure )

* just say if u want more code( because thast not whole thing )

Thanks for your reply! I've been working on it for a bit, you can look at it here:

http://wordpress.pastebin.com/m6407de20

 

It's in C#.

 

What it does now:

1.When the player presses the key, cruise control is activated.

2. When the player presses the key again, or presses W,S or Space, or exits the car, the cruisecontrol is de-activated.

3. The current car speed is set to be the saved carspeed each tick, but not when the car is in the air.

 

But it's still not complete. The car can keep ramming into walls and you get a massive speedboost when you get back on the ground from a jump.

 

EDIT:

I want to say again: using SendKeys.SendWait(string) will freeze the game!

Great... so did my code sample help

 

Link to comment
Share on other sites

Great... so did my code sample help

Yes, it made me use Wait() a bit, and that worked good. With my latest version, the car doesn't instantaniously go up to the saved speed, it goes a bit gradually.

 

Currently, I'm working on something totally different. Fireworks. Ped-Fireworks devil.gif . Everything works beautifully, I just need a way to create smoke...

Link to comment
Share on other sites

Sweet im gonna release my mod soon. Im just making a launcher.exe. Which you can configure settings,keys,view highscores for speedbomb, uhh launch gta, oh and download custom teleport spots biggrin.gif

Link to comment
Share on other sites

Hazard how do you use settings? i tried settings.load and settings.new but i couldnt get it to work.. Plz give a small example

got it

Nevermind tounge.gif

Edited by boomer678
Link to comment
Share on other sites

Alright, so I found a link to an older version of the scripthook (.82 I believe) and it works ok, although the scripts I use often crash. When I use the latest version, it freezes as soon as I load my savegame. So somewhere between .82 and .86, something changed that my copy of GTA:IV apparently doesn't appreciate very much.

Link to comment
Share on other sites

Alright, so I found a link to an older version of the scripthook (.82 I believe) and it works ok, although the scripts I use often crash. When I use the latest version, it freezes as soon as I load my savegame. So somewhere between .82 and .86, something changed that my copy of GTA:IV apparently doesn't appreciate very much.

It is most likely a problem with the scripts. Most scripts are not yet updated for version 0.86, but the version has some breaking changes that require each script to be updated for it.

Link to comment
Share on other sites

Alright, so I found a link to an older version of the scripthook (.82 I believe) and it works ok, although the scripts I use often crash.  When I use the latest version, it freezes as soon as I load my savegame.  So somewhere between .82 and .86, something changed that my copy of GTA:IV apparently doesn't appreciate very much.

It is most likely a problem with the scripts. Most scripts are not yet updated for version 0.86, but the version has some breaking changes that require each script to be updated for it.

Thanks, you are correct. I deleted the SuperSpawner script and now it starts. I'll just have to wait for a new version. Thanks again!

Link to comment
Share on other sites

I have a little issue with the console parameters. Why is the \ char omitted out of the param string? I wanted to give my construct save and load functions the ability of choosing specific folders to store and retrieve their data files. Instead of having a preset directory defined, I thought it'd be better to let them choose what folder to use by manually specifying in the filename string. I was receiving errors in my script when testing this feature, and I found out that that char wasn't being included in the output string. Anyway to fix this? Also, I think \t is considered a space in a console param. confused.gif

 

@The0: I'm steadily working on the update and should have it up within the next few days.

Link to comment
Share on other sites

I have a little issue with the console parameters. Why is the \ char omitted out of the param string? I wanted to give my construct save and load functions the ability of choosing specific folders to store and retrieve their data files. Instead of having a preset directory defined, I thought it'd be better to let them choose what folder to use by manually specifying in the filename string. I was receiving errors in my script when testing this feature, and I found out that that char wasn't being included in the output string. Anyway to fix this? Also, I think \t is considered a space in a console param. confused.gif

 

@The0: I'm steadily working on the update and should have it up within the next few days.

\ is a conrol character, just as in C# or C++. Thus you get a tab on \t or a new line on \n. to use the actual symbol, just write it down twice: "my\\test\\filename.xyz" as a parameter in console will return my\test\filename.xyz

Link to comment
Share on other sites

---

 

EDIT:

why does this not work:

 

Game.isGameKeyPressed(GameKey.MoveForward) = true;

 

How should this be done?

Edited by thaCURSEDpie
Link to comment
Share on other sites

Got some questions regarding the Ped.Task functions. When I set a task ie DriveTo. Does this block the script from running until the ped has reached that position?

 

edit, I'll just explain what I'm doing.

 

I have a two functions. MobileRefuelHandler() which the mobile number "MOB 555 0100" is bound to, so when I dail the number that function is called. The basic idea of this, is to create a vehicle and ped, and put the ped in the vehicle and drive the vehicle to the players position(that works fine, the vehicle creates and the ped drives to player and stops) At the very end of the function it is a boolean value (mobileCalled) to true.

 

The other function is MobileRefuel() which is called within the Tick loop. This function checks if the boolean value (mobileCalled) is true, if it is. It checks if the ped's vehicle is near the players (within a 10.0f radius) if it is, it sets the hazard lights to true and enables the player to refill the car.

 

That never worked, it seemed as though the mobileCall value was never being set or reached. So I changed it to before the task order, and it didn't make any difference. I changed the mobileRefuel to explode the peds vehicle if mobileCall was ever set to true.

 

Any ideas?

 

Heres the code for the functions

MobileRefuelHandler()

 

//get a random position within float 70 of the player           randomPos = Player.Character.Position.Around(70.0f);           //create a petrol tanker           petTank = World.CreateVehicle(new Model("PACKER"), World.GetNextPositionOnStreet(randomPos));                      //give tanker a marker so we know where it is           petTank.AttachBlip();           //make the tanker invincible           petTank.CanBeDamaged = false;             //create a ped to drive the tanker           tankDriver = World.CreatePed(randomPos.Around(2.0f), Gender.Male);           //Give the ped the order to drive tanker to the player           mobileCalled = true;           tankDriver.Task.WarpIntoVehicle(petTank, VehicleSeat.Driver);           tankDriver.Task.DriveTo(petTank, Player.Character.Position, 20.0f, false, true);

 

 

mobileRefuel()

 

if (mobileCalled == true)           {               petTank.Explode();               //check if the petrolTanker is near the player               if (this.isInArea(Player.Character.Position, tankDriver.Position, 15.0f) == true)               {                   //add a temporary fuel station so we can refuel                   addFuelStation(tankDriver.Position, 100, 10.0f, "Mobile");                   petTank.HazardLightsOn = true;                   atMobileStation = true;                                    }               //check if player has left area only if they were previsouly at the station               if (atMobileStation == true)               {                   if (this.isInArea(Player.Character.Position, tankDriver.Position, 25.0f) == false)                   {                       //remove the station                       removeFuelStation("Mobile");                       //tell the drive to drive away and cruise                       petTank.SoundHorn(50);                       tankDriver.Task.CruiseWithVehicle(petTank, 20.0f, true);                       //check that the tank driver is now further away from the player                       if (this.isInArea(Player.Character.Position, tankDriver.Position, 45.0f) == false)                       {                           //mark as no longer needed                           petTank.NoLongerNeeded();                           //reset the at mobile station flag and the mobile called                           atMobileStation = false;                           mobileCalled = false;                       }                   }               }                          }

 

 

Note: it should be running the mobileRefuel() method all the time, as it is before displaying some text in the tickloop. And that displays / upates fine.

Edited by Gangsta Killa
Link to comment
Share on other sites

 

---

 

EDIT:

why does this not work:

 

Game.isGameKeyPressed(GameKey.MoveForward) = true;

 

How should this be done?

Because it is readonly. There is no way to set it.

 

@Gangsta Killa: No, it doesn't block the script. I also don't know a way to check if a task is completed, unless you check for some criterias yourself (like the distance to the target). Use a Tasksequence if you want to execute serveral tasks in order.

[EDIT] I'm not sure about Explode. I heard it doesn't trigger the explosion in some situations. I'd rather pack several calls to Game.DisplayText into the code, always with a higher number (like "TEST1", "TEST2", etc.). Depending on wich text is visible (and thus was last called) you can clearly identify how far the script came.

Edited by HazardX
Link to comment
Share on other sites

Ah, might try that and see if it is actually reaching it. Currently I only have two tasks for the ped. WarpIntoVehicle and DriveTo. Should that be done as a sqeunce?

 

Edit: is there anyway of when spawning a model, to ensure it has the extras I want?

Edited by Gangsta Killa
Link to comment
Share on other sites

Ah, might try that and see if it is actually reaching it. Currently I only have two tasks for the ped. WarpIntoVehicle and DriveTo. Should that be done as a sqeunce?

 

Edit: is there anyway of when spawning a model, to ensure it has the extras I want?

WarpIntoVehicle seems to run immediately, so it MAY be okay. I'm not sure. The official scripts use TeskSequences for everything that contains more than one task in a row.

 

VehicleExtras are not yet supported, but you may use this:

 

   private void ToggleExtra(Vehicle vehicle, int ExtraID, bool TurnOn) {     Native.Function.Call("TURN_OFF_VEHICLE_EXTRA", Vehicle, ExtraID, !TurnOn);  }

 

But don't ask what the ExtraIDs are, i have no clue. Any information on this would be much appreciated. colgate.gif

Link to comment
Share on other sites

Ah, might try that and see if it is actually reaching it. Currently I only have two tasks for the ped. WarpIntoVehicle and DriveTo. Should that be done as a sqeunce?

 

Edit: is there anyway of when spawning a model, to ensure it has the extras I want?

WarpIntoVehicle seems to run immediately, so it MAY be okay. I'm not sure. The official scripts use TeskSequences for everything that contains more than one task in a row.

 

VehicleExtras are not yet supported, but you may use this:

 

   private void ToggleExtra(Vehicle vehicle, int ExtraID, bool TurnOn) {     Native.Function.Call("TURN_OFF_VEHICLE_EXTRA", Vehicle, ExtraID, !TurnOn);  }

 

But don't ask what the ExtraIDs are, i have no clue. Any information on this would be much appreciated. colgate.gif

Cheers Hazard, I'll look into the extra ids. Oh it was calling and setting the mobileCalled varible, its my position checking that doesnt seem to work. Yet it works fine for the petrol stations, and its the exact same code confused.gif

Link to comment
Share on other sites

Cheers Hazard, I'll look into the extra ids. Oh it was calling and setting the mobileCalled varible, its my position checking that doesnt seem to work. Yet it works fine for the petrol stations, and its the exact same code confused.gif

What exactly is "isInArea" checking? the distance? You can do it this way:

 

 

if (Player.Character.Position.DistanceTo(petTank.Position) < 15.0f) { your stuff here } 

 

Link to comment
Share on other sites

Ah, I've got custom function that lepoard gave me, it takes 2 positions and then works out the distance between them. It works well for the petrol stations. I'll see if that works for the mobile refueling.

Link to comment
Share on other sites

Is it possible to run scripts to affect peds created by other scripts?

 

I made the following using one of the examples and it actually affects group members created by another script, so I'm wondering... will this always work as long as there are valid members in Player.Group?

 

 

Public Class BGHealingScript   Inherits Script   Private Group As Group = Player.Group   Public Sub New()       Me.Interval = 5000   End Sub   Private Sub BasicTickExample_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Tick       For Each Member As Ped In Group           If Not Member.Exists() Then Return           With Member               .MaxHealth = 999               .Health = 999               .Armor = 100               .Weapons.RemoveAll() ' Used this just to check if the group members were affected           End With       Next    End SubEnd Class

 

Link to comment
Share on other sites

Is it possible to run scripts to affect peds created by other scripts?

 

I made the following using one of the examples and it actually affects group members created by another script, so I'm wondering... will this always work as long as there are valid members in Player.Group?

yes, it doesn't matter who created them.

 

if you want to make sure that you created them, set local metadata on each ped after creation:

 

p.SetMetadata(Of Boolean)("CreatedByMe", False, True)

 

Boolean is the datatype here, "CreatedByMe" is the name of the metadata (whatever you want), False means here that the metadata in only readable and writable by your script and True is the actual value stored as metadata.

 

Later, check like this if it was created by you:

 

If p.GetMetadata(Of Boolean)("CreatedByMe", False) Then  ' yes, it is mineEnd If

 

Link to comment
Share on other sites

So it's like having a signature when creating peds? Awesome!

 

And if I'm seeing it right, this can also be used to affect individual group members.

 

I'm sure this will come in handy, thanks for your help! icon14.gif

Link to comment
Share on other sites

Hi, i´ve got a problem, I want to make a door locker, but it doesn´t works...

 

Part of The Code:

 

 

Public Sub DoorLocked()

        Player.Character.CurrentVehicle.DoorLock = 1

        Game.DisplayText("Doors Locked")

    End Sub

 

The other parts of the code work perfect...

 

I tried "= +1" too, but it doesn´t works sad.gif ...

 

Can you help me with that part?...

 

Thanks biggrin.gif ...

Link to comment
Share on other sites

You should set Player.Character.CurrentVehicle.DoorLock = 4. That worked for me.

In C++:

 

Vehicle v;GetCarCharIsUsing(c, &v);CloseAllCarDoors(v);LockCarDoors(v, 4);

 

If you want to unlock all doors you should do:

Player.Character.CurrentVehicle.Doorlock = NULL;

Link to comment
Share on other sites

I use:

 

 

Ped ped; 	Car car; 	u32 playerIndex = ConvertIntToPlayerIndex(GetPlayerId()); 	GetPlayerChar(playerIndex, &ped); 	 	if ((IsCharSittingInAnyCar(ped) == 1)&&(Car_DoorsLock==false)) 	{ 	GetCarCharIsUsing(ped, &car); 	LockCarDoors(car,4); 	Car_DoorsLock=true; 	PrintStringWithLiteralStringNow("STRING", "Car Doors Locked",5000,1);

 

 

in C++ and have changed the function's second parameter to u32 instead of doing enum, but any value greater then 0 seems to work for lock, unlocking indeed is simply 0 for second parm.

 

Not sure how it would work in this scripthook, but must assume it's similar.

Link to comment
Share on other sites

Yes,

 

Player.Character.CurrentVehicle.DoorLock = 4

 

to lock and

 

Player.Character.CurrentVehicle.DoorLock = 0

 

to unlock. Does anyone know what the other locks are for? I'll turn Vehicle.DoorLock to a Boolean value if they are not really required.

Link to comment
Share on other sites

Well, when the lock status is 4, I am unable to enter the car (Niko doesn't even try to break the window).

 

It might be that a lower lock status makes the doors locked, but enables the car stealing. But I haven't tested it yet.

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

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

×
×
  • Create New...

Important Information

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