Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Reference from https://forum.fivem.net/t/help-finger-point/25652
- Imports System.Runtime.CompilerServices
- Imports GTA
- Imports GTA.Native
- Imports System.Math
- Imports GTA.Math
- Public Class mpPoint
- Inherits Script
- Dim mp_pointing As Boolean = False
- Dim ped As Ped
- Public Shared config As ScriptSettings = ScriptSettings.Load("scripts\MP_Point.ini")
- Dim dtTimer As Integer = 0
- Dim timeout As Integer = 0
- Dim once As Boolean = False
- Dim oldval As Boolean = False
- Dim oldvalped As Boolean = False
- Public Sub New()
- End Sub
- Private Sub Point_Tick(sender As Object, e As EventArgs) Handles Me.Tick
- ped = Game.Player.Character
- config = ScriptSettings.Load("scripts\MP_Point.ini")
- If once Then once = False
- If Not config.GetValue(Of Boolean)("GENERAL", "DoubleTap", False) Then 'Keyboard
- If Game.IsControlJustReleased(0, Control.SpecialAbilitySecondary) AndAlso Not mp_pointing AndAlso ped.IsOnFoot AndAlso Not Game.Player.IsPlayerFreeAiming Then
- Script.Wait(200)
- StartPointing()
- mp_pointing = True
- End If
- If Game.IsControlJustReleased(0, Control.SpecialAbilitySecondary) AndAlso mp_pointing AndAlso ped.IsOnFoot AndAlso Not Game.Player.IsPlayerFreeAiming Then
- Script.Wait(200)
- StopPointing()
- mp_pointing = False
- End If
- Else 'Joypad
- If Game.IsControlJustReleased(0, Control.SpecialAbilitySecondary) Then
- dtTimer += 1
- timeout = Game.GameTime
- End If
- If dtTimer >= 2 AndAlso Not mp_pointing AndAlso ped.IsOnFoot AndAlso Not Game.Player.IsPlayerFreeAiming Then
- Script.Wait(200)
- StartPointing()
- mp_pointing = True
- dtTimer = 0
- End If
- If dtTimer >= 2 AndAlso mp_pointing AndAlso ped.IsOnFoot AndAlso Not Game.Player.IsPlayerFreeAiming Then
- Script.Wait(200)
- StopPointing()
- mp_pointing = False
- dtTimer = 0
- End If
- End If
- If ped.UnkNative_0x921CE12C489C4C41() AndAlso Not mp_pointing Then
- StopPointing()
- End If
- If ped.UnkNative_0x921CE12C489C4C41() Then
- If Not ped.IsOnFoot Then
- StopPointing()
- Else
- Dim camPitch = GameplayCamera.RelativePitch
- If camPitch < -70.0F Then
- camPitch = -70.0F
- ElseIf camPitch > 42.0F Then
- camPitch = 42.0F
- End If
- camPitch = (camPitch + 70.0F) / 112.0F
- Dim camHeading = GameplayCamera.RelativeHeading
- Dim cosCamHeading = Cos(camHeading)
- Dim sinCamHeading = Sin(camHeading)
- If camHeading < -180.0F Then
- camHeading = -180.0F
- ElseIf camHeading > 180.0F Then
- camHeading = 180.0F
- End If
- camHeading = (camHeading + 180.0F) / 360.0F
- Dim blocked = 0
- Dim nn = 0
- Dim coords = ped.GetOffsetInWorldCoords(New Vector3((cosCamHeading * -0.2F) - (sinCamHeading * (0.4F * camHeading + 0.3F)), (sinCamHeading * -0.2F) + (cosCamHeading * (0.4F * camHeading + 0.3F)), 0.6F))
- Dim ray = World.Raycast(New Vector3(coords.X, coords.Y, coords.Z - 0.2F), New Vector3(coords.X, coords.Y, coords.Z + 0.2F), 0.4F, 95, ped)
- nn = ray.Result
- blocked = ray.Result
- ped.UnkNative_0xD5BB4025AE449A4E("Pitch", camPitch)
- ped.UnkNative_0xD5BB4025AE449A4E("Heading", camHeading * -1.0F + 1.0F)
- ped.UnkNative_0xB0A6CFD2C69C1088("isBlocked", blocked)
- ped.UnkNative_0xB0A6CFD2C69C1088("isFirstPerson", UnkNative_0xEE778F8C7E1142E2() = 4)
- End If
- End If
- If timeout <= (Game.GameTime - 500) Then
- dtTimer = 0
- End If
- If Game.IsControlJustPressed(0, Control.Attack) OrElse Game.IsControlJustPressed(0, Control.Aim) Then
- StopPointing()
- mp_pointing = False
- dtTimer = 0
- End If
- End Sub
- Public Sub StartPointing()
- RequestAnimDict("anim@mp_point")
- If config.GetValue(Of Boolean)("GENERAL", "HideWeapon", True) Then ped.SetPedCurrentWeaponVisible()
- ped.SetPedConfigFlag(PedConfigFlags.PointingFlag)
- ped.TaskMoveNetwork("task_mp_pointing", 0.5F, "anim@mp_point", 24)
- RemoveAnimDict("anim@mp_point")
- End Sub
- Public Sub StopPointing()
- ped.UnkNative_0xD01015C7316AE176("Stop")
- If Not ped.IsInjured Then ped.Task.ClearSecondary()
- If Not ped.IsInVehicle() Then
- If config.GetValue(Of Boolean)("GENERAL", "HideWeapon", True) Then ped.SetPedCurrentWeaponVisible()
- End If
- ped.SetPedConfigFlag(PedConfigFlags.PointingFlag)
- ped.Task.ClearSecondary()
- End Sub
- End Class
- Public Module PointHelper
- <Extension()>
- Public Sub SetPedCurrentWeaponVisible(ped As Ped)
- Native.Function.Call(Hash.SET_PED_CURRENT_WEAPON_VISIBLE, ped.Handle, False, True, True, True)
- End Sub
- <Extension()>
- Public Sub SetPedConfigFlag(ped As Ped, flags As PedConfigFlags)
- Native.Function.Call(Hash.SET_PED_CONFIG_FLAG, ped.Handle, flags, 1)
- End Sub
- Public Enum PedConfigFlags
- PED_FLAG_CAN_FLY_THRU_WINDSCREEN = 32
- PED_FLAG_DIES_BY_RAGDOLL = 33
- PointingFlag = 36
- PED_FLAG_NO_COLLISION = 52
- _PED_FLAG_IS_SHOOTING = 58
- _PED_FLAG_IS_ON_GROUND = 60
- PED_FLAG_NO_COLLIDE = 62
- PED_WAS_KILLED_BY_TAKEDOWN = 70
- PED_FLAG_DEAD = 71
- PED_FLAG_IS_SNIPER_SCOPE_ACTIVE = 72
- PED_FLAG_SUPER_DEAD = 73
- _PED_FLAG_IS_IN_AIR = 76
- PED_FLAG_IS_AIMING = 78
- PED_FLAG_DRUNK = 100
- _PED_FLAG_IS_NOT_RAGDOLL_AND_NOT_PLAYING_ANIM = 104
- PED_FLAG_NO_PLAYER_MELEE = 122
- PED_FLAG_NM_MESSAGE_466 = 125
- PED_FLAG_INJURED_LIMP = 166
- PED_FLAG_INJURED_LIMP_2 = 170
- PED_FLAG_INJURED_DOWN = 187
- PED_FLAG_SHRINK = 223
- PED_FLAG_MELEE_COMBAT = 224
- _PED_FLAG_IS_ON_STAIRS = 253
- _PED_FLAG_HAS_ONE_LEG_ON_GROUND = 276
- PED_FLAG_NO_WRITHE = 281
- PED_FLAG_FREEZE = 292
- PED_FLAG_IS_STILL = 301
- PED_FLAG_NO_PED_MELEE = 314
- _PED_SWITCHING_WEAPON = 331
- PED_FLAG_ALPHA = 410
- End Enum
- <Extension()>
- Public Sub TaskMoveNetwork(ped As Ped, task As String, multiplier As Single, anim As String, flag As Integer)
- Native.Function.Call(Hash._0x2D537BA194896636, ped.Handle, task, multiplier, False, anim, flag)
- End Sub
- <Extension()>
- Public Sub UnkNative_0xD01015C7316AE176(ped As Ped, p1 As String)
- Native.Function.Call(Hash._0xD01015C7316AE176, ped.Handle, p1)
- End Sub
- Public Sub RequestAnimDict(value As String)
- Native.Function.Call(Hash.REQUEST_ANIM_DICT, value)
- Dim endtime = DateTime.UtcNow + New TimeSpan(0, 0, 0, 0, 1000)
- While Not Native.Function.Call(Of Boolean)(Hash.HAS_ANIM_DICT_LOADED, value)
- Script.Yield()
- If DateTime.UtcNow >= endtime Then
- Return
- End If
- End While
- End Sub
- Public Sub RemoveAnimDict(value As String)
- Native.Function.Call(Hash.REMOVE_ANIM_DICT, value)
- End Sub
- <Extension()>
- Public Function UnkNative_0x921CE12C489C4C41(ped As Ped) As Boolean
- Return Native.Function.Call(Of Boolean)(Hash._0x921CE12C489C4C41, ped.Handle)
- End Function
- <Extension()>
- Public Sub UnkNative_0xD5BB4025AE449A4E(ped As Ped, p1 As String, p2 As Single)
- Native.Function.Call(Hash._0xD5BB4025AE449A4E, ped, p1, p2)
- End Sub
- <Extension()>
- Public Sub UnkNative_0xB0A6CFD2C69C1088(ped As Ped, p1 As String, p2 As Integer)
- Native.Function.Call(Hash._0xB0A6CFD2C69C1088, ped, p1, p2)
- End Sub
- Public Function UnkNative_0xEE778F8C7E1142E2() As Integer
- Dim unk = Native.Function.Call(Of Integer)(Hash._0x19CAFA3C87F7C2FF)
- Return Native.Function.Call(Of Integer)(Hash._0xEE778F8C7E1142E2, unk)
- End Function
- <Extension()>
- Public Function IsPlayerFreeAiming(player As Player) As Boolean
- Return Native.Function.Call(Of Boolean)(Hash.IS_PLAYER_FREE_AIMING, player)
- End Function
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement