Imports GTA Imports GTA.Math Imports GTA.Native Imports System Imports System.Collections.Generic Imports System.IO Imports System.Windows.Forms Public Class GateLock Inherits Script Private toggleKey As Keys Private radius As Single Private gateModels As Model() Private lockInPos As Boolean Public Sub New() toggleKey = Settings.GetValue("Settings", "ToggleKey", Keys.L) radius = Settings.GetValue("Settings", "Radius", 20F) lockInPos = Settings.GetValue("Settings", "DefaultLocked", True) ReadModels() Interval = 100 Tick += AddressOf OnTick KeyDown += AddressOf OnKeyDown End Sub Private Sub OnTick(ByVal sender As Object, ByVal e As EventArgs) LockGates() End Sub Private Sub OnKeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) If e.KeyCode = toggleKey AndAlso AnyModelsNearby(Game.Player.Character.Position) Then lockInPos = Not lockInPos If lockInPos Then GTA.UI.Screen.ShowSubtitle("LOCKED IN PLACE") Else GTA.UI.Screen.ShowSubtitle("UNLOCKED") End If End If End Sub Private Function AnyModelsNearby(ByVal pos As Vector3) As Boolean For Each model As Model In gateModels If [Function].[Call](Of Boolean)(Hash.DOES_OBJECT_OF_TYPE_EXIST_AT_COORDS, pos.X, pos.Y, pos.Z, radius, model.Hash, 0) Then Return True End If Next Return False End Function Private Sub ReadModels() If File.Exists("./scripts/Gates.txt") Then Dim models As List(Of Model) = New List(Of Model)() Dim strArrModels As String() = File.ReadAllLines("./scripts/Gates.txt") For Each strModel As String In strArrModels Dim model As Model = New Model(strModel.Trim()) If model.IsValid Then models.Add(model) End If Next If models.Count > 0 Then gateModels = models.ToArray() End If End If End Sub Private Sub LockGates() Dim pos As Vector3 = Game.Player.Character.Position For Each model As Model In gateModels If [Function].[Call](Of Boolean)(Hash.DOES_OBJECT_OF_TYPE_EXIST_AT_COORDS, pos.X, pos.Y, pos.Z, radius, model.Hash, 0) Then Dim prop As Prop = CType(Entity.FromHandle([Function].[Call](Of Integer)(Hash.GET_CLOSEST_OBJECT_OF_TYPE, pos.X, pos.Y, pos.Z, radius, model.Hash, False, 0, 0)), Prop) If prop.Exists() Then prop.IsPositionFrozen = lockInPos End If End If Next End Sub End Class