|
 |
|
|
|
|
|
GTA Modification Forums
[Q] Make the npcs stop behind my car
 |
|
 |
| |
HazardX  |
Posted: Tuesday, Feb 24 2009, 23:38
|
pedestrian mangler

Group: Members
Joined: Dec 13, 2008


|
I tried it that way. Seems to work great: | CODE | Imports System Imports System.Windows.Forms Imports System.Collections.Generic Imports Microsoft.VisualBasic Imports GTA
Public Class HaltBehindScript Inherits Script
Private list As New List(Of Vehicle) Private bStopped As Boolean = False Private offset As New Vector3(0.0F, -4.0F, 0.0F)
Public Sub New() 'Interval = 250 End Sub
Private Sub HaltBehindScript_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Tick Dim v As Vehicle = Player.Character.CurrentVehicle If v Is Nothing Then If bStopped Then Disable() Return End If If Not bStopped Then If v.Speed >= 1.0F Then Return bStopped = True Else If v.Speed >= 2.0F Then Disable Return End If End If
CheckForNewCar(v.GetOffsetPosition(offset)) ProcessCars() End Sub
Private Sub Disable() bStopped = False list.Clear() End Sub
Private Sub CheckForNewCar(ByVal Position As Vector3) Dim v As Vehicle = World.GetClosestVehicle(Position, 3.0F) If v Is Nothing OrElse list.Contains(v) Then Return list.Add(v) v.SetMetadata("maxspeed", False, v.Speed) End Sub
Private Sub ProcessCars() Dim CurrentSpeed As Single Dim MaxSpeed As Single For Each v As Vehicle In list CurrentSpeed = v.Speed MaxSpeed = v.GetMetadata(Of Single)("maxspeed", False) If CurrentSpeed < MaxSpeed Then v.SetMetadata("maxspeed", False, CurrentSpeed) ElseIf CurrentSpeed > MaxSpeed Then v.Speed = MaxSpeed End If Next End Sub
End Class |
It checks only behind the car and also will not lower vehicle speeds, but instead just don't allow them to accelerate again. This post has been edited by HazardX on Wednesday, Feb 25 2009, 08:36
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
Pages:
(4) [1] 2 3 ... Last »
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
| |
 |
|
 |
|
|
|
|