Quantcast

Jump to content

» «
Photo

[TUT] How to create VB.Net scripts

62 replies to this topic
julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#1

Posted 02 November 2012 - 10:51 PM Edited by julionib, 07 September 2013 - 07:31 AM.

I will post here my tutorials about scripting, hope that this will help someone smile.gif


Basic tools to start scripting

Creating the first script

Getting targeted "things", my new method

XBox control support - Using Native methods, XNA and SlimDX

Playing game/external sounds

Creating an "Cool 3D" HUD for targets

INI Files, saving and reading settings

PTFX (Particle effects) Start, trigger, evolve and update offsets/rotation smile.gif




Using NAudio dll to simultaneous play wave files smile.gif

Classes

Some ped flight ideas

Animations - All that i know about

Drawing things on screen (lines, rectangles, images, game images, etc.)

Simple menu class (Used in Iron Man IV and my mods menu so far)

 

Simple camera tutorial


Nevitro
  • Nevitro

    Modder

  • Members
  • Joined: 31 Mar 2009

#2

Posted 04 November 2012 - 08:40 PM

Good work! Really!
I watched video with PTFX effects. Just simple online compilator to C# and some things i will try in c#! smile.gif

Mayby together we can make tutorials - i just will 'translate' Your mods in C#? smile.gif

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#3

Posted 05 November 2012 - 01:55 AM

QUOTE (Nevitro @ Sunday, Nov 4 2012, 20:40)
Good work! Really!
I watched video with PTFX effects. Just simple online compilator to C# and some things i will try in c#! smile.gif

Mayby together we can make tutorials - i just will 'translate' Your mods in C#? smile.gif

thx man, feel free to use/translate it

hardsty1e
  • hardsty1e

    RIP Yeardley Diamond

  • Members
  • Joined: 02 May 2009
  • Philippines

#4

Posted 05 November 2012 - 06:28 AM Edited by hardsty1e, 12 November 2012 - 11:16 PM.

nice idea nevitro but I still would like to see some C# tutorials if not to much work. Shifty41s_beerhatsmilie2.gif impressive work julionib!

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#5

Posted 07 November 2012 - 01:58 AM

new video added: Get targeted ped, vehicle, object or ground

Tori_95
  • Tori_95

    PHD Guy

  • Members
  • Joined: 02 Jan 2012

#6

Posted 07 November 2012 - 02:24 AM

COOOOOL, thanks bro biggrin.gif inlove.gif inlove.gif

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#7

Posted 12 November 2012 - 10:57 PM

added tut about Ghost rider script and groups

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#8

Posted 22 December 2012 - 03:37 PM

Creating rockets (and start kidding with custom class):


Deadly Target
  • Deadly Target

    Rat

  • Members
  • Joined: 12 Apr 2010

#9

Posted 22 December 2012 - 07:43 PM

Thanks for these tutorials! All your scripts are very useful.

Is it possible to create a vb.net script that makes Niko say something with the push of a button? I know simple native trainer can do this, but I'd rather have a simple script for it instead.

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#10

Posted 02 January 2013 - 01:45 AM

QUOTE (Deadly Target @ Saturday, Dec 22 2012, 19:43)
Is it possible to create a vb.net script that makes Niko say something with the push of a button? I know simple native trainer can do this, but I'd rather have a simple script for it instead.

i know that its possible to make him say game speech, with different voices too, but i tryed some exaples with no success, maybe im missing some details

Pie015
  • Pie015

    6 STAR VETERAN

  • Members
  • Joined: 11 Jun 2010

#11

Posted 12 January 2013 - 01:59 PM Edited by Pie015, 12 January 2013 - 02:46 PM.

Hey Julio, I watched your tutorials and subscribed, your a great help but I ran into some trouble with the "GetNearestPed" function. Everytime I press F10 the script has an error! FYI: The script is supposed to make the closest ped drive your car to the waypoint, originally meant for helicopter because Simple Native Trainer drivers don't support helicopters.

CODE

Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports GTA
Public Class HeliDriverScript
   Inherits Script
   Private myPed As Ped
   Private myVeh As Vehicle
   Private InVehicle As Boolean = True

   Public Sub New()
       Me.Interval = 10
   End Sub

   Private Sub HeliDriverScript_KeyUp(sender As Object, e As GTA.KeyEventArgs) Handles Me.KeyUp
       If e.Key = Keys.F10 AndAlso Exists(Game.GetWaypoint) AndAlso Player.Character.isInVehicle = True Then
           World.GetClosestPed(Player.Character.Position, 5.0F)
           myVeh = Player.LastVehicle()
           If World.GetClosestPed(Player.Character.Position, 5.0F) = Nothing Then
           Else
               myPed = World.GetClosestPed(Player.Character.Position, 5.0F)
               If myPed.isInVehicle = True Then
                   Exit Sub
               End If
               myPed.Task.EnterVehicle(myVeh, VehicleSeat.Driver)
           End If
           If myPed.isInVehicle = True Then
               myPed.Task.DriveTo(Game.GetWaypoint.Position.ToGround, 200, True, True)
           End If
       End If
   End Sub

   Private Sub HeliDriverScript_Tick(sender As Object, e As EventArgs) Handles Me.Tick
   End Sub
End Class


EDIT: Here is the scripthookdotnet log

2013-01-12 17:21:08 - Error during Tick in script 'HeliDriverScript':
System.NullReferenceException: Object reference not set to an instance of an object.
at HeliDriverScript.HeliDriverScript_KeyUp(Object sender, KeyEventArgs e)
at GTA.Script.ProcessEvents()
at GTA.Script.DoTick()
at GTA.ScriptThread.OnTick()

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#12

Posted 12 January 2013 - 04:44 PM

well

you must check if the possible detected ped exists, i did some changes and explanations that can help you:

CODE


Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports GTA
Public Class HeliDriverScript
  Inherits Script
  Private myPed As Ped
  Private myVeh As Vehicle
  Private InVehicle As Boolean = True

  Public Sub New()
      Me.Interval = 10
  End Sub

  Private Sub HeliDriverScript_KeyUp(sender As Object, e As GTA.KeyEventArgs) Handles Me.KeyUp
      If e.Key = Keys.F10 AndAlso Exists(Game.GetWaypoint) AndAlso Player.Character.isInVehicle Then
          myVeh = Player.lastvehicle ' get the vehicle

          dim myTmpPed as ped = nothing ' lets declare an temporary ped object

          myTmpPed  = World.GetClosestPed(Player.Character.Position, 20.0F) ' search for him/her

          If exists(myTmpPed ) Then ' check if exists
              ' then do the code related to the found ped
              If myTmpPed.isInVehicle Then
                  Exit Sub
              End If
             
     ' we need to free the Driver seat
     player.character.WarpIntoVehicle(myVeh, vehicleseat.RightFront)

              ' just to see who its the found ped
     myTmpPed.attachblip
     
              ' its good to clear possible previous tasks
     myTmpPed.Task.clearall
              ' before setting new ones
              myTmpPed.Task.EnterVehicle(myVeh, VehicleSeat.Driver)
              myTmpPed.Task.DriveTo(Game.GetWaypoint.Position.ToGround, 200, True, True)
              ' you can call the two tasks in sequence, if im not wrong
     
     game.displaytext("ped found")
  else
   game.displaytext("ped not found")
          End If
      End If
  End Sub

  Private Sub HeliDriverScript_Tick(sender As Object, e As EventArgs) Handles Me.Tick
  End Sub
End Class


julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#13

Posted 09 March 2013 - 06:57 PM

added new method to get targeted peds/vehicles/objects:

http://www.gtaforums...&t=529784&st=0#

123iamking
  • 123iamking

    Who am I?

  • Members
  • Joined: 21 Jan 2011

#14

Posted 10 March 2013 - 01:40 PM

QUOTE
Tip: Run gta in window mode using commandline.txt with line -windowed or with an shortcut to the LaunchGTAIV.exe with param -windowed


Can you upload step by step photos about this ? As usual , I write a script then put it in Scripts folder and test it . I don't know how to have GTAIV process it along with its real scripts threads (even I have downloaded GTA_IV_CPLUSPLUS_Script_Hook_Version_0.4.0_(Development_Kit)_(Apr_16_2010)_by_aru) , you know , launch the game then realize your scripts crash but you can't fix it immediately - you have to quit the game then fix the script then launch it again monocle.gif

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#15

Posted 10 March 2013 - 09:27 PM

QUOTE (123iamking @ Sunday, Mar 10 2013, 13:40)
QUOTE
Tip: Run gta in window mode using commandline.txt with line -windowed or with an shortcut to the LaunchGTAIV.exe with param -windowed


Can you upload step by step photos about this ? As usual , I write a script then put it in Scripts folder and test it . I don't know how to have GTAIV process it along with its real scripts threads (even I have downloaded GTA_IV_CPLUSPLUS_Script_Hook_Version_0.4.0_(Development_Kit)_(Apr_16_2010)_by_aru) , you know , launch the game then realize your scripts crash but you can't fix it immediately - you have to quit the game then fix the script then launch it again monocle.gif

mmm, well to open in window mode you can create an text file called commandline.txt inside your GTAIV.exe folder, then inside this file you add the line:

-windowed

and save it, the game should open in window mode

for version 1.0.4.0 or bellow you need to press Win+D (windows key + D key) to minimize all, including GTA window, then you can access your editor window, for version 1.0.7.0 its good to use Alt+Tab to change between gta window and the editor window, but its good to have the game in the Map menu to avoid doing things in the game window with the keypresses in the script editor ^^

in version 1.0.4.0 if you come back to gta window and it dont chagne from black to the normal game window after soem seconds, you can press ctrl+alt+del to call windows "managment" menu and them press Esc to close this menu, then the gta window should be normal again smile.gif

123iamking
  • 123iamking

    Who am I?

  • Members
  • Joined: 21 Jan 2011

#16

Posted 18 March 2013 - 07:31 AM

Can you say more about the library we using
I often using these :
CODE

using System;
using System.Windows.Forms;
using GTA;
using System.Collections.Generic;

but somebody often using those
CODE

using System;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
using System.Media;
using GTA;

so can u explain each library and what library we should use ? monocle.gif
It's kind of important cause some people can or can't use some scripts just because of the library we import monocle.gif Am I right ?

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#17

Posted 18 March 2013 - 02:19 PM

QUOTE (123iamking @ Monday, Mar 18 2013, 07:31)
so can u explain each library and what library we should use  ? monocle.gif
It's kind of important cause some people can or can't use some scripts just because of the library we import  monocle.gif   Am I right ?

no, the library will affect the development and not the execution, without the proper library you cant access some methods/properties/language objects in an easy way...

for example: system.windows.forms its necessary to have easy access to Keys enumeration that you probably will use in keydown events:

CODE

Private Sub keyDown(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyDown    
               if e.key = keys.d1 then


without the library system.windows.forms, you will have more work because you will need to specify the entire "path" to keys eumeration

CODE

Private Sub keyDown(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyDown    
               if e.key = system.windows.forms.keys.d1 then



its basically this


now, to determine what you will need or not will depend on what exactly you will do in your script

for example: to use File.readAllBytes (when loading image data to texture) you will need system.IO to have easy access to "File."


this System.Collections.Generic its necessary to create lists of objects


basically what i do to discover what library i will need its try to find some examples on web, not scripting examples but language examples, but in great part of cases Visual Studio tells me what library im probably missing



obs.: I did this explanation based on my experiences with vb.net, im not vb.net programmer, so probably something here can be wrong or with bad exaplanation ^^

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#18

Posted 20 March 2013 - 05:26 AM

Added tut about Playing game/external sounds smile.gif

http://gtaxscripting...d-external.html

avatar0068
  • avatar0068

    Player Hater

  • Members
  • Joined: 18 Feb 2013

#19

Posted 20 March 2013 - 10:09 AM

thanks, this is a useful post icon14.gif

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#20

Posted 08 April 2013 - 02:59 PM

Creating an "Cool 3D" HUD for targets:

http://gtaxscripting...target-hud.html

123iamking
  • 123iamking

    Who am I?

  • Members
  • Joined: 21 Jan 2011

#21

Posted 09 April 2013 - 10:17 AM

GTA 4 has a lot of great audio files - but I don't know how to call it .
If I want to trigger the sound : "THUNDER_CLOSE" (I found this in the file sound.dat15) - How can I do it ?
Thanks for reading . colgate.gif

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#22

Posted 10 April 2013 - 08:54 PM

QUOTE (123iamking @ Tuesday, Apr 9 2013, 10:17)
GTA 4 has a lot of great audio files - but I don't know how to call it .
If I want to trigger the sound : "THUNDER_CLOSE" (I found this in the file sound.dat15) - How can I do it ?
Thanks for reading . colgate.gif

seems that you didn't saw this tutorial in first page smile.gif

http://gtaxscripting...d-external.html

i show how to play game sounds and i provide an "sounds demo" script to help you filter and hear the sounds ingame.

123iamking
  • 123iamking

    Who am I?

  • Members
  • Joined: 21 Jan 2011

#23

Posted 10 April 2013 - 11:59 PM

QUOTE (julionib @ Wednesday, Apr 10 2013, 20:54)
seems that you didn't saw this tutorial in first page smile.gif
http://gtaxscripting...d-external.html

Opps ... Sorry , my bad blush.gif

123iamking
  • 123iamking

    Who am I?

  • Members
  • Joined: 21 Jan 2011

#24

Posted 12 April 2013 - 09:15 AM Edited by 123iamking, 12 April 2013 - 09:28 AM.

Is there any way to make the blood or rain drop appears on the camera ?
Just like when you get hit - the camera is automatically covered with blood (a lot of blood)
when it's rain - the camera is automatically covered with water (a lot of water)
the basic R* blood and rain drop camera effect's not satisfied at all
PS : use native function to run animation
CODE
GTA.Native.Function.Call("TASK_PLAY_ANIM", Player.Character, "walking_shove_l_", "missjacob2", 4.00, 0, 1, 1, 0, -2);

OR use
CODE
Player.Character.Task.PlayAnimation(new AnimationSet("missjacob2"), "piss_loop", 1.0f);  

(sorry ,I use C# script )
would be better ?

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#25

Posted 12 April 2013 - 09:57 PM

i will try to create this blood effect for my chainsaw script

i dont know what is better, to use animation flags i prefer to use scripthook object task, to simple play i use native method

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#26

Posted 26 April 2013 - 03:46 AM

added tut about particle effects smile.gif

http://gtaxscripting...le-effects.html

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#27

Posted 13 May 2013 - 05:13 AM

Using NAudio to simultaneous play wave files

http://gtaxscripting...ounds-very.html

123iamking
  • 123iamking

    Who am I?

  • Members
  • Joined: 21 Jan 2011

#28

Posted 13 May 2013 - 07:24 AM

I think you pasted the wrong code of the Sound Demo Script .
When I open console and press "sd" , nothing happen , then I read the script , I see this
CODE
....
If e.Key = Keys.NumPad0 Then
           For Each o As GTA.Object In World.GetAllObjects
               If Exists(o) AndAlso (o.Position.DistanceTo(Player.Character.Position) < 5) Then
                   Native.Function.Call("PLAY_SOUND_FROM_OBJECT", soundID, "GENERAL_WEAPONS_ROCKET_LOOP", o)
.....

Please check again and post the right code , Thank for your tut , It's cool cookie.gif cookie.gif

Nevitro
  • Nevitro

    Modder

  • Members
  • Joined: 31 Mar 2009

#29

Posted 13 May 2013 - 11:52 AM

Julio, You should add instruction how add screen effect tutorial smile.gif

123iamking
  • 123iamking

    Who am I?

  • Members
  • Joined: 21 Jan 2011

#30

Posted 14 May 2013 - 01:38 AM

A mod would not be completed if u miss "Animation" smile.gif




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users