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

    1. GTANet.com

    1. GTA Online

      1. The Cayo Perico Heist
      2. The Diamond Casino Heist
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

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

    1. Red Dead Redemption 2

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

    1. Grand Theft Auto Series

    2. GTA VI

      1. St. Andrews Cathedral
    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. Guides & Strategies
      2. Help & Support
    6. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    7. GTA III

      1. Guides & Strategies
      2. 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. 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
    3. Gangs

    1. Announcements

    2. Support

    3. Suggestions

HazardX

[BETA] GTAIV .Net ScriptHook

Recommended Posts

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
motorsport71

@MulleDK19

Thanks man, i appreciate it smile.gif

Share this post


Link to post
Share on other sites
Bloodhowl21

Hi there! I have a question regarding ScriptHook , ASIloader , Xliveless etc. Do they all require an original copy of GTA 4? I'm new here and I'm sorry if this will offend you , but why is it only for the retail version? Thanks.

Share this post


Link to post
Share on other sites
Symbiote

@Bloodhowl21

I don't know if it's against the rules to tell you this, but everything you mentioned works with illegal copies of the game.

Edited by AngryAmoeba

Share this post


Link to post
Share on other sites
daimyo21

So I just made my first script through a tutorial, I have looked at other peoples script to understand C# more yet I been having a universal problem.

 

I have the 0.4.0 Developer SDK and am thinking that this is the problem.

 

 

using GTA.base;

 

 

puts a red line under base even though I have included the scripthookdotnet in the references...

everytime I use base.Blah.Blah.Blah it says unidentified error: 'base' is not a keyword

 

when I type using GTA. (it brings up all the options and base is @base, which doesnt work).

 

 

 

Any thoughts? Is there a later developer kit?

 

Much help would be greatly appreciated.

 

 

EDIT: Just referenced the latest one (not 0.4.0)

 

The one from this thread in "For Developers" folder and GTA.base is still showing up as error

Edited by daimyo21

Share this post


Link to post
Share on other sites
Symbiote

Sorry for my ignorance, but what is GTA.base? What do you need it for?

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.