Hi, first post here in the forums
Ive decided to start some minor gta 4 modding.
In my script i need to use timers, and every time i have tried to use it- i get the following error:
2014-02-15 20:05:51 - STARTING SCRIPTS... 2014-02-15 20:05:51 - ...successfully started script 'Tutorial.Main'! 2014-02-15 20:05:51 - ...successfully started script 'Tutorial.Commands'! 2014-02-15 20:05:51 - ...successfully started script 'Tutorial.AI'! 2014-02-15 20:05:52 - Error during Tick in script 'Tutorial.AI': System.NullReferenceException: Object reference not set to an instance of an object. at Tutorial.AI.suvStalkerStalk(Object sender, EventArgs e) at GTA.Script.TryTick() at GTA.Script.DoTick() at GTA.ScriptThread.OnTick()
Yes, i used a template from a tutorial to get started, i havent renamed it yet.
If im missing essential information, please tell me, Ill update this if needed...
If i find out the solution, i will update this with the solution
InfamousSabre reminded me kindly that i needed to show my own code, which i for some reason forgot... Sorry!
Imports GTA Imports System.Drawing Imports System.Windows.Forms Public Class AI Inherits Script Public S_SUV As Vehicle Public S_SEDAN As Vehicle Public S_BIKE As Vehicle Public SUV_DRIVER As Ped Private Sub suvStalkers(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyDown If e.Key = Keys.L AndAlso Keys.O Then S_SUV = World.CreateVehicle("LANDSTALKER", Player.Character.Position.Around(10.0F)) If S_SUV.Exists = True Then SUV_DRIVER = World.CreatePed("M_Y_HARLEM_01", Player.Character.Position.Around(10.0F)) End If If S_SUV.Exists = True And SUV_DRIVER.Exists = True Then SUV_DRIVER.WarpIntoVehicle(S_SUV, VehicleSeat.Driver) End If If SUV_DRIVER.isInVehicle Then End If End If End Sub Public Sub New() Me.Interval = 5000 ' Interval is the time between two Ticks (in milliseconds) End Sub Private Sub suvStalkerStalk(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Tick If S_SUV.Exists = True Then SUV_DRIVER.CurrentVehicle.SoundHorn(1000) End If End Sub End Class
AND for some reason after i added the " If S_SUV.Exists = True Then
it worked? Does a timer need stuff to be inside IF stuff or something to work proberly?