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. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

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

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    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 IV 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 SA Mods
    10. GTA Vice City

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

      1. Guides & Strategies
      2. Help & Support
      3. GTA III 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

jitsuin

Yeah i think there is a limit to the amount of peds added to the array.

 

Try pulling an array and adding the specific peds from the array you want to a List

 

A list is an array too but you choose what gets added to it smile.gif

 

The object parameter is closestVehicle i think

 

edit: Now that I think about it, Lists actually might now work since the problem is pulling from the array in the first place...sorry i was dumb there. Maybe you should narrow the type of ped u want to find or is it u want everyone no matter what type of ped?

Edited by jitsuin

Share this post


Link to post
Share on other sites
Symbiote

GetAllPeds() won't actually return all peds, because not all peds are really "peds". Some of them are just dummy peds, like LOD models. Thanks to MulleDK for this info. wink.gif

 

How to get the car of a ped as an object: Ped.CurrentVehicle

 

To get the nearest car that isn't your car, maybe something like this:

 

// Vector3.Around() gets a random coord around the given coord, within the given rangeVehicle theVehicle = World.GetClosestVehicle(Player.Character.Position.Around(10.0F), 5.0F);if (Player.Character.CurrentVehicle != theVehicle) {   // Do stuff}

 

 

Edit: Forgot the range argument for GetClosestVehicle()

Edited by AngryAmoeba

Share this post


Link to post
Share on other sites
jitsuin

thanks AA!

 

ah so GetClosestVehicle needs to be defined Vehicle and not as a Model...my bad blush.gif

 

edit: AHA! dummy peds, makes sense, thanks for the tip oh and to MulleDK19 too

Edited by jitsuin

Share this post


Link to post
Share on other sites
ahatius

There's a function to get the targeted ped. Is there also one for vehicles? Or is there a workaround to get the targeted car?

Share this post


Link to post
Share on other sites
nm69

I have a problem.

I am on patch 4 i.e., 1.0.4 and the problem is, i can bring up the console and all, but when i type spawn Addedcarname it says "Script not found" And "Model Invalid"

i know i have added the cars correctly and double checked everything.

Is there an older version of dotnet for p4?

 

this is what my logfile says:

 

2012-01-14 04:58:58 - Initializing ScriptHookDotNet v1.7.1.4 BETA (GTA IV version 1.0.4.0)2012-01-14 05:00:35 - Direct3D device created!2012-01-14 05:00:37 - SEARCHING FOR SCRIPTS...2012-01-14 05:00:37 - DONE! No DotNet script found!2012-01-14 05:00:37 - Error during GetPhoneNumber (Phone checks will be disabled):                     System.Exception: Accessing Globals failed! Invalid Memory Address!                        at unmanaged.MemoryAccess.GetGlobalAddress(Int32 index)                        at unmanaged.MemoryAccess.GetPhoneNumber()                        at GTA.NetHook.CheckPhone()2012-01-14 05:11:50 - Direct3D device lost!

 

Share this post


Link to post
Share on other sites
MulleDK19

 

That's what I don't want tounge.gif

 

When I'm driving a car, then the closest car, is my car. But I'd like to get the car which is the closest to my car. smile.gif

 

 

/// <summary>/// Gets the closest vehicle, ignoring the exception./// </summary>/// <param name="position">The position.</param>/// <param name="radius">The radius.</param>/// <param name="exception">The vehicle to ignore.</param>/// <returns></returns>private Vehicle GetClosestVehicleExcept(Vector3 position, float radius, Vehicle exception){   Vehicle closestVehicle = null;   float closestDistance = float.MaxValue;   foreach (Vehicle vehicle in World.GetAllVehicles())   {       if (vehicle == exception)       {           continue;       }       float distance = vehicle.Position.DistanceTo(position);       if (distance < closestDistance)       {           closestVehicle = vehicle;           closestDistance = distance;       }   }   return closestVehicle;}

 

 

 

Edit2: How do I get an ped out of a vehicle?

ped.Task.LeaveVehicle / ped.Task.LeaveVehicleImmediately

 

 

Edit3: And another question: How do I create input fields or menus, so I can choose between things, like in a car spawner.

GTA.Forms

Edited by MulleDK19

Share this post


Link to post
Share on other sites
YossiBz

How I do Timer with function?

Share this post


Link to post
Share on other sites
AlbertKARR

Hi!

 

I want to know how I can implement a function using 2 keys.

For example if player, inside of a car press T+1(Normal, not numpad), How i have to write that at VB?

 

Thanks in advance smile.gif

Share this post


Link to post
Share on other sites
MorphMan

Hi Guys!

How do you get a vehicle to follow another?

 

Ive tried the 'driveto' and 'goto'

but it always seems to want to drive a random route instad of following confused.gif

 

Thanks smile.gif

 

Share this post


Link to post
Share on other sites
jitsuin

 

Hi!

 

I want to know how I can implement a function using 2 keys.

For example if player, inside of a car press T+1(Normal, not numpad), How i have to write that at VB?

 

Thanks in advance smile.gif

this is C# but should be close to same

 

 

this.BindKey(Keys.D1, false, false, true, callHandle);

 

 

you can use shift, alt , control modifier through bool parameters, i think i set control to true for modifier, i dont remember the bool order

 

Oh you want T+1, sorry!! You need to use KeyDown, but im not sure the exact process blush.gif

 

Andrew explains here but im not understanding 100%:

 

http://www.gtaforums.com/index.php?showtopic=401577

Edited by jitsuin

Share this post


Link to post
Share on other sites
jitsuin

I am having trouble with BindPhoneNumber on 1.7.1.7 Beta, can someone help, here is my example that i get no answer just a busy signal. Method is not called and I see no text displayed when i dial "1234567890" on the phone.

 

 

using System;using GTA;public class GTA : Script{   public GTA()   {       this.BindPhoneNumber("1234567890", new PhoneDialDelegate(WrongNumber));   }   private void WrongNumber()   {       Game.DisplayText("Wrong Number Bitch");   }}

 

Edited by jitsuin

Share this post


Link to post
Share on other sites
mickdef00

do it is for the xbox 360

 

smile.gif

Share this post


Link to post
Share on other sites
mickdef00

Do it for the xbox 360?

 

smile.gif

Share this post


Link to post
Share on other sites
mickdef00
Excellent Job! This is going to bring great power to GTAIV now!!

 

Is it possible to change the ammo for each gun? I'd like a shotgun that shoots molotovs at highspeed

 

like:

 

Dim weap As Weapon = Weapon.Shotgun

weap.SetAmmoType(MolotovProjectile)

Do it for the xbox 360?

 

Share this post


Link to post
Share on other sites
jitsuin

do it for the ps3 x 1000

Share this post


Link to post
Share on other sites
YossiBz

SendScriptCommand what its do?

and how i turn this?

Share this post


Link to post
Share on other sites
xX SAMZZ1 Xx

i have V 6.o mods and i got to hot swop it every time i go to play it but i cant play it for more than 5 min. with out it getting disk error can anyone tell me something that can help plzzzz

 

 

Share this post


Link to post
Share on other sites
dualemperor

Is there maybe some tutorial on how to use this? Sorry, I'm really noob at this.

Share this post


Link to post
Share on other sites
Areppon

Can someone please tell me what I'm missing? I'm trying to figure out how to use windows by studying the WindowExampleScript. I wrote directly based on the example script and everything is fine except for one vital piece. What is that piece? I have (I believe) written everything like I'm supposed to, I checked the references in the solution explorer against the original project file (they match), and my using statements also match. So What the French Toast am I gone stupid about? The error from the scripthook log says

2012-02-08 11:45:21 - 9 Errors in script 'C:\Save\Games\GTA4\GAME\Grand Theft Auto IV\scripts\WindowFormTest.cs':

                       in Line 21: 'KOMv17.WindowFormTest' does not contain a definition for 'Controls' and no extension method 'Controls' accepting a first argument of type 'KOMv17.WindowFormTest' could be found (are you missing a using directive or an assembly reference?)

There are (as stated) 8 others (but since all 9 errors are identical it's unnecessary to write it 9x yeah).

 

Here's my code:

using System;using System.Drawing;using System.Windows.Forms;using System.Collections.Generic;using GTA;namespace KOMv17{   public class WindowFormTest : Script   {       private GTA.Forms.Label TitleLbl;       private GTA.Forms.Button Button1;       public WindowFormTest()       {           int Y = 8;           TitleLbl = new GTA.Forms.Label();           TitleLbl.Location = new Point(8, Y);           TitleLbl.Size = new Size(96, 16);           TitleLbl.Text = "Spawn Test";           this.Controls.Add(TitleLbl);           Y += 16;           Button1 = new GTA.Forms.Button();           Button1.Location = new Point(8, Y);           Button1.Size = new Size(96, 16);           Button1.Text = "Car Spawn";           Button1.Click += new GTA.MouseEventHandler(Button1_Click);           this.Controls.Add(Button1);           this.Text = "Window Test";           this.StartPosition = GTA.FormStartPosition.Fixed;           this.Size = new Size(96 + 16, Y + 8 + this.TitleSize);           this.Opened += new EventHandler(WindowFormTest_Opened);       }       private void Button1_Click(object sender, GTA.MouseEventArgs e)       {           Game.DisplayText("WHAT THE FRENCH TOAST!?");       }       private void WindowFormTest_Opened(System.Object sender, System.EventArgs e)       {           Vehicle v = Game.LocalPlayer.Character.CurrentVehicle;           if (v == null)           {               Button1.BackColor = Color.Black;           }       }   }   public class WindowTestScript : GTA.Forms.Form   {       WindowFormTest Window;       public WindowTestScript()       {           Window = new WindowFormTest();           BindKey(Keys.F12, new KeyPressDelegate(ShowWindow));       }       private void BindKey(Keys keys, KeyPressDelegate keyPressDelegate)       {           ShowWindow();       }       private void ShowWindow()       {           if (Game.LocalPlayer.Character.isSittingInVehicle()) { Game.DisplayText("Please leave your vehicle and enter the marker before continuing"); return; }           Game.Console.Close();           Window.Location = new Point(420, 420);           Window.Show();       }   }}

 

I've given up several times in the past in studying this because of this pain in the arse. But I'm tired of giving up.

Edited by Areppon

Share this post


Link to post
Share on other sites
Symbiote

@Areppon

 

On line 8, your WindowFormTest class should inherit GTA.Forms.Form.

 

// Incorrectpublic class WindowFormTest : Script// Correctpublic class WindowFormTest : GTA.Forms.Form

 

Also, on line 29, "text" should be capitalized.

Share this post


Link to post
Share on other sites
sbabiy

I would like to second the issue that jitsuin posted regarding the phone number handling. Is there anyway we can get this to work?

 

Thanks

Share this post


Link to post
Share on other sites
Areppon

Thank you AngryAmoeba. What else do you know about using window forms? Can you tell me anything else about errors in my code? the [this] statements need to be rewritten but I have no idea how. Am I going about this backwards? What are the minimum required bits of code to get a window to show ingame?

Share this post


Link to post
Share on other sites
Symbiote

I've only messed with window forms a little bit, and I copied the example code pretty much exactly. I haven't touched it in a while; I remember having trouble making a TextBox and giving up. tounge.gif

Share this post


Link to post
Share on other sites
razi192

hello there. I have a question:

 

I want to play with my friends on LAN and use this trainer to make gang wars with bodyguards etc etc. The thing is - you can't do this in free mode coz in free mode all of us are considered as "teammates" so the bodyguards dont fight etc etc. In the description of the scripthook it says that it is supposed to block the mod ONLY on rated modes but it blocks when i play with my friends on LAN and definitely we are not on a RATED match. In the end, we can use it on free mode but cant on LAN deathmatch...

 

Does somebody have a solution for this? i really want to make a use of capabilities of this mod with my friends.

Share this post


Link to post
Share on other sites
motorsport71

Hello all,

I've been searching the forum but i can't find out if there is a way to write to an INI in .net scripthook? using v1.7.1.7...

Share this post


Link to post
Share on other sites
lindsayslorach

@motorsport71: "Settings.Write***();" is probably what you need.

Share this post


Link to post
Share on other sites
thaCURSEDpie

Regarding the phone-number binding:

If I recall correctly, HazardX had a lot of trouble getting it to work in a stable manner. In the end, the phonenumber-binding held up the release of the Scripthook for v1070 (or was it 1040, I dunno.), so he chose not to include it.

 

All the peeps wanting xbox360 / ps3 support:

Is there such a thing as .Net 4.0 for these consoles? (honest question)

Anyways, if you want to mod, just get the game on PC.

 

razi192:

Seems .Net scripthook checks if GameMode == Free Mode. If not, it doesn't work. So that way is just closed-shut.

 

However, the bodyguard mod could support multiplayer. The modcreator should iterate through the list of all networked players and set tham as hated targets for the bodyguards. Contact the author smile.gif.

 

 

Share this post


Link to post
Share on other sites
motorsport71

Hey again, i'm trying to get a pedestrian count but i cannot figure out how to use ".count"

I'm using

 

dim peds as ped() = world.getpeds(player.character.position, 100.0f)for each ped as ped in peds

 

to find them, but i don't know how make "ped.count". I've been reading the BaseCollection<> and ReadOnlyCollection<> constructors and such but i'm doing a lot of head scratching and would rather ask then spend hours on trial and error whatsthat.gif

 

thanks

 

Update

i didn't figure out the .net solution btw, but i did do this and it works, i dunno if it's what i should have done in the first place...

 

Dim pedcount As IntegerIf exists(ped) AndAlso ped.isalive = True Then                   pedcount = pedcount + 1                   game.displaytext("Living Peds " & pedcount)               End If

 

 

thanks again

Edited by motorsport71

Share this post


Link to post
Share on other sites
Vintage88

Is there somewhere I can find download links to older versions of this? Thanks!

Share this post


Link to post
Share on other sites
MulleDK19
Hey again, i'm trying to get a pedestrian count but i cannot figure out how to use ".count"

I'm using

 

dim peds as ped() = world.getpeds(player.character.position, 100.0f)for each ped as ped in peds

 

to find them, but i don't know how make "ped.count". I've been reading the BaseCollection<> and ReadOnlyCollection<> constructors and such but i'm doing a lot of head scratching and would rather ask then spend hours on trial and error whatsthat.gif

 

thanks

 

Update

i didn't figure out the .net solution btw, but i did do this and it works, i dunno if it's what i should have done in the first place...

 

Dim pedcount As IntegerIf exists(ped) AndAlso ped.isalive = True Then                   pedcount = pedcount + 1                   game.displaytext("Living Peds " & pedcount)               End If

 

 

thanks again

VB:

 

Dim peds As Ped() = World.GetAllPeds()Dim totalPeds As Integer = peds.LengthDim existingPeds As Integer = 0Dim livingPeds As Integer = 0Dim deadPeds As Integer = 0For Each ped As Ped In pedsIf Not Game.Exists(ped) Then Continue ForEnd IfexistingPeds += 1If ped.isAlive Then livingPeds += 1Else deadPeds += 1End IfNextGame.DisplayText("There are " & totalPeds.ToString() & " peds. " & existingPeds.ToString() & " of those exist. " & livingPeds.ToString() & " alive, " & deadPeds.ToString() & " dead.")

 

 

C#:

 

Ped[] peds = World.GetAllPeds();int totalPeds = peds.Length;int existingPeds = 0;int livingPeds = 0;int deadPeds = 0;foreach (Ped ped in peds){if (!Game.Exists(ped)) continue;existingPeds += 1;if (ped.isAlive) livingPeds += 1;else deadPeds += 1;}Game.DisplayText("There are " + totalPeds.ToString() + " peds. " + existingPeds.ToString() + " of those exist. " + livingPeds.ToString() + " alive, " + deadPeds.ToString() + " dead.");

 

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.
Note: Your post will require moderator approval before it will be visible.

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.