@@ -86,35 +86,34 @@ local recoils = {
86
86
[` weapon_rayminigun` ] = 0.3 ,
87
87
}
88
88
89
- CreateThread (function ()
90
- while true do
91
- local ped = PlayerPedId ()
92
- if IsPedShooting (ped ) and not IsPedDoingDriveby (ped ) then
93
- local _ , weap = GetCurrentPedWeapon (ped )
94
- if recoils [weap ] and recoils [weap ] ~= 0 then
95
- local tv = 0
96
- if GetFollowPedCamViewMode () ~= 4 then
97
- repeat
98
- Wait (0 )
99
- local p = GetGameplayCamRelativePitch ()
100
- SetGameplayCamRelativePitch (p + 0.1 , 0.2 )
101
- tv += 0.1
102
- until tv >= recoils [weap ]
89
+ AddEventHandler (" CEventGunShot" , function (entities , eventEntity , args )
90
+ local ped = PlayerPedId ()
91
+
92
+ if eventEntity ~= ped then return end
93
+ if IsPedDoingDriveby (ped ) then return end
94
+
95
+ local _ , weap = GetCurrentPedWeapon (ped )
96
+ if recoils [weap ] and recoils [weap ] ~= 0 then
97
+ local tv = 0
98
+ if GetFollowPedCamViewMode () ~= 4 then
99
+ repeat
100
+ Wait (0 )
101
+ local p = GetGameplayCamRelativePitch ()
102
+ SetGameplayCamRelativePitch (p + 0.1 , 0.2 )
103
+ tv += 0.1
104
+ until tv >= recoils [weap ]
105
+ else
106
+ repeat
107
+ Wait (0 )
108
+ local p = GetGameplayCamRelativePitch ()
109
+ if recoils [weap ] > 0.1 then
110
+ SetGameplayCamRelativePitch (p + 0.6 , 1.2 )
111
+ tv += 0.6
103
112
else
104
- repeat
105
- Wait (0 )
106
- local p = GetGameplayCamRelativePitch ()
107
- if recoils [weap ] > 0.1 then
108
- SetGameplayCamRelativePitch (p + 0.6 , 1.2 )
109
- tv += 0.6
110
- else
111
- SetGameplayCamRelativePitch (p + 0.016 , 0.333 )
112
- tv += 0.1
113
- end
114
- until tv >= recoils [weap ]
113
+ SetGameplayCamRelativePitch (p + 0.016 , 0.333 )
114
+ tv += 0.1
115
115
end
116
- end
116
+ until tv >= recoils [ weap ]
117
117
end
118
- Wait (0 )
119
118
end
120
119
end )
0 commit comments