11local function startPointing (ped )
2- LoadAnimDict (' anim@mp_point' )
3- SetPedConfigFlag (ped , 36 , true )
4- TaskMoveNetworkByName (ped , ' task_mp_pointing' , 0.5 , false , ' anim@mp_point' , 24 )
5- RemoveAnimDict (' anim@mp_point' )
2+ LoadAnimDict (' anim@mp_point' )
3+ SetPedConfigFlag (ped , 36 , true )
4+ TaskMoveNetworkByName (ped , ' task_mp_pointing' , 0.5 , false , ' anim@mp_point' , 24 )
5+ RemoveAnimDict (' anim@mp_point' )
66end
77
88local function stopPointing (ped )
9- RequestTaskMoveNetworkStateTransition (ped , ' Stop' )
10- SetPedConfigFlag (ped , 36 , false )
11- ClearPedSecondaryTask (ped )
9+ RequestTaskMoveNetworkStateTransition (ped , ' Stop' )
10+ SetPedConfigFlag (ped , 36 , false )
11+ ClearPedSecondaryTask (ped )
1212end
1313
1414function ResetOtherAnimsVals ()
15- PlayerVars .pointing = false
15+ PlayerVars .pointing = false
1616
17- if PlayerVars .handsUp then
18- PlayerVars .handsUp = false
19- end
17+ if PlayerVars .handsUp then
18+ PlayerVars .handsUp = false
19+ end
2020end
2121
2222if Config .Framework == ' esx' then
23- AddEventHandler (' esx:onPlayerDeath' , ResetOtherAnimsVals )
23+ AddEventHandler (' esx:onPlayerDeath' , ResetOtherAnimsVals )
2424end
2525
2626RegisterCommand (' +handsup' , function ()
27- local playerPed = PlayerPedId ()
28-
29- if not PlayerVars .isDead and IsPedOnFoot (playerPed ) then
30- if PlayerVars .pointing then
31- PlayerVars .pointing = false
32- end
33-
34- PlayerVars .handsUp = not PlayerVars .handsUp
35-
36- if PlayerVars .handsUp then
37- LoadAnimDict (' random@mugging3' )
38- TaskPlayAnim (playerPed , ' random@mugging3' , ' handsup_standing_base' , 8.0 , - 8.0 , - 1 , 49 , 0.0 , false , false , false )
39- RemoveAnimDict (' random@mugging3' )
40- else
41- StopAnimTask (playerPed , ' random@mugging3' , ' handsup_standing_base' , - 4.0 )
42- end
43- end
27+ local playerPed = PlayerPedId ()
28+
29+ if not PlayerVars .isDead and IsPedOnFoot (playerPed ) then
30+ if PlayerVars .pointing then
31+ PlayerVars .pointing = false
32+ end
33+
34+ PlayerVars .handsUp = not PlayerVars .handsUp
35+
36+ if PlayerVars .handsUp then
37+ LoadAnimDict (' random@mugging3' )
38+ TaskPlayAnim (playerPed , ' random@mugging3' , ' handsup_standing_base' , 8.0 , - 8.0 , - 1 , 49 , 0.0 , false , false , false )
39+ RemoveAnimDict (' random@mugging3' )
40+ else
41+ StopAnimTask (playerPed , ' random@mugging3' , ' handsup_standing_base' , - 4.0 )
42+ end
43+ end
4444end , false )
4545
4646RegisterCommand (' -handsup' , function () end , false )
@@ -50,21 +50,21 @@ TriggerEvent('chat:removeSuggestion', '/+handsup')
5050TriggerEvent (' chat:removeSuggestion' , ' /-handsup' )
5151
5252RegisterCommand (' +fingerpoint' , function ()
53- local playerPed = PlayerPedId ()
53+ local playerPed = PlayerPedId ()
5454
55- if not PlayerVars .isDead and IsPedOnFoot (playerPed ) then
56- if PlayerVars .handsUp then
57- PlayerVars .handsUp = false
58- end
55+ if not PlayerVars .isDead and IsPedOnFoot (playerPed ) then
56+ if PlayerVars .handsUp then
57+ PlayerVars .handsUp = false
58+ end
5959
60- PlayerVars .pointing = not PlayerVars .pointing
60+ PlayerVars .pointing = not PlayerVars .pointing
6161
62- if PlayerVars .pointing then
63- startPointing (playerPed )
64- else
65- stopPointing (playerPed )
66- end
67- end
62+ if PlayerVars .pointing then
63+ startPointing (playerPed )
64+ else
65+ stopPointing (playerPed )
66+ end
67+ end
6868end , false )
6969
7070RegisterCommand (' -fingerpoint' , function () end , false )
@@ -74,64 +74,64 @@ TriggerEvent('chat:removeSuggestion', '/+fingerpoint')
7474TriggerEvent (' chat:removeSuggestion' , ' /-fingerpoint' )
7575
7676CreateThread (function ()
77- while true do
78- Wait (0 )
79- local playerPed = PlayerPedId ()
80-
81- DisableControlAction (0 , Config .Controls .Crouch .keyboard , true )
82-
83- if IsDisabledControlJustReleased (0 , Config .Controls .Crouch .keyboard ) and IsUsingKeyboard (2 ) then
84- if DoesEntityExist (playerPed ) and not IsEntityDead (playerPed ) and IsPedOnFoot (playerPed ) then
85- PlayerVars .crouched = not PlayerVars .crouched
86-
87- if PlayerVars .crouched then
88- LoadAnimSet (' move_ped_crouched' )
89- SetPedMovementClipset (playerPed , ' move_ped_crouched' , 0.5 )
90- RemoveAnimSet (' move_ped_crouched' )
91- else
92- ResetPedMovementClipset (playerPed , 0.5 )
93- end
94- end
95- end
96-
97- if PlayerVars .crouched or PlayerVars .handsUp or PlayerVars .pointing then
98- if not IsPedOnFoot (playerPed ) then
99- ResetPedMovementClipset (playerPed , 0.5 )
100- stopPointing ()
101-
102- PlayerVars .crouched = false
103- PlayerVars .pointing = false
104-
105- if PlayerVars .handsUp then
106- PlayerVars .handsUp = false
107- end
108- else
109- if PlayerVars .pointing then
110- local camPitch = GetGameplayCamRelativePitch ()
111- camPitch = (camPitch < - 70.0 and - 70.0 ) or (camPitch > 42.0 and 42.0 ) or camPitch
112- camPitch = (camPitch + 70.0 ) / 112.0
113-
114- local camHeading = GetGameplayCamRelativeHeading ()
115- local cosCamHeading , sinCamHeading = math.cos (camHeading * (math.pi / 180.0 )), math.sin (camHeading * (math.pi / 180.0 ))
116-
117- camHeading = (camHeading < - 180.0 and - 180.0 ) or (camHeading > 180.0 and 180.0 ) or camHeading
118- camHeading = (camHeading + 180.0 ) / 360.0
119-
120- local coords = GetOffsetFromEntityInWorldCoords (playerPed , vec3 ((cosCamHeading * - 0.2 ) - (sinCamHeading * (0.4 * camHeading + 0.3 )), (sinCamHeading * - 0.2 ) + (cosCamHeading * (0.4 * camHeading + 0.3 )), 0.6 ))
121- local shapeTestHandle = StartShapeTestCapsule (coords - vec3 (0.0 , 0.0 , 0.2 ), coords + vec3 (0.0 , 0.0 , 0.2 ), 0.4 , 95 , playerPed , 7 )
122-
123- local shapeTestStatus , hit , endCoords , surfaceNormal , entityHit = GetShapeTestResult (shapeTestHandle )
124- while shapeTestStatus == 1 do
125- Wait (0 )
126- shapeTestStatus , hit , endCoords , surfaceNormal , entityHit = GetShapeTestResult (shapeTestHandle )
127- end
128-
129- SetTaskMoveNetworkSignalFloat (playerPed , ' Pitch' , camPitch )
130- SetTaskMoveNetworkSignalFloat (playerPed , ' Heading' , (camHeading * - 1.0 ) + 1.0 )
131- SetTaskMoveNetworkSignalBool (playerPed , ' isBlocked' , shapeTestStatus == 2 and hit == 1 )
132- SetTaskMoveNetworkSignalBool (playerPed , ' isFirstPerson' , GetCamViewModeForContext (GetCamActiveViewModeContext ()) == 4 )
133- end
134- end
135- end
136- end
77+ while true do
78+ Wait (0 )
79+ local playerPed = PlayerPedId ()
80+
81+ DisableControlAction (0 , Config .Controls .Crouch .keyboard , true )
82+
83+ if IsDisabledControlJustReleased (0 , Config .Controls .Crouch .keyboard ) and IsUsingKeyboard (2 ) then
84+ if DoesEntityExist (playerPed ) and not IsEntityDead (playerPed ) and IsPedOnFoot (playerPed ) then
85+ PlayerVars .crouched = not PlayerVars .crouched
86+
87+ if PlayerVars .crouched then
88+ LoadAnimSet (' move_ped_crouched' )
89+ SetPedMovementClipset (playerPed , ' move_ped_crouched' , 0.5 )
90+ RemoveAnimSet (' move_ped_crouched' )
91+ else
92+ ResetPedMovementClipset (playerPed , 0.5 )
93+ end
94+ end
95+ end
96+
97+ if PlayerVars .crouched or PlayerVars .handsUp or PlayerVars .pointing then
98+ if not IsPedOnFoot (playerPed ) then
99+ ResetPedMovementClipset (playerPed , 0.5 )
100+ stopPointing ()
101+
102+ PlayerVars .crouched = false
103+ PlayerVars .pointing = false
104+
105+ if PlayerVars .handsUp then
106+ PlayerVars .handsUp = false
107+ end
108+ else
109+ if PlayerVars .pointing then
110+ local camPitch = GetGameplayCamRelativePitch ()
111+ camPitch = (camPitch < - 70.0 and - 70.0 ) or (camPitch > 42.0 and 42.0 ) or camPitch
112+ camPitch = (camPitch + 70.0 ) / 112.0
113+
114+ local camHeading = GetGameplayCamRelativeHeading ()
115+ local cosCamHeading , sinCamHeading = math.cos (camHeading * (math.pi / 180.0 )), math.sin (camHeading * (math.pi / 180.0 ))
116+
117+ camHeading = (camHeading < - 180.0 and - 180.0 ) or (camHeading > 180.0 and 180.0 ) or camHeading
118+ camHeading = (camHeading + 180.0 ) / 360.0
119+
120+ local coords = GetOffsetFromEntityInWorldCoords (playerPed , vec3 ((cosCamHeading * - 0.2 ) - (sinCamHeading * (0.4 * camHeading + 0.3 )), (sinCamHeading * - 0.2 ) + (cosCamHeading * (0.4 * camHeading + 0.3 )), 0.6 ))
121+ local shapeTestHandle = StartShapeTestCapsule (coords - vec3 (0.0 , 0.0 , 0.2 ), coords + vec3 (0.0 , 0.0 , 0.2 ), 0.4 , 95 , playerPed , 7 )
122+
123+ local shapeTestStatus , hit , endCoords , surfaceNormal , entityHit = GetShapeTestResult (shapeTestHandle )
124+ while shapeTestStatus == 1 do
125+ Wait (0 )
126+ shapeTestStatus , hit , endCoords , surfaceNormal , entityHit = GetShapeTestResult (shapeTestHandle )
127+ end
128+
129+ SetTaskMoveNetworkSignalFloat (playerPed , ' Pitch' , camPitch )
130+ SetTaskMoveNetworkSignalFloat (playerPed , ' Heading' , (camHeading * - 1.0 ) + 1.0 )
131+ SetTaskMoveNetworkSignalBool (playerPed , ' isBlocked' , shapeTestStatus == 2 and hit == 1 )
132+ SetTaskMoveNetworkSignalBool (playerPed , ' isFirstPerson' , GetCamViewModeForContext (GetCamActiveViewModeContext ()) == 4 )
133+ end
134+ end
135+ end
136+ end
137137end )
0 commit comments