@@ -19,6 +19,12 @@ MessageShortcuts = {}
19
19
FrozenPlayers = {}
20
20
MutedPlayers = {}
21
21
22
+ local cachedInfo = {
23
+ ped = PlayerPedId (),
24
+ veh = 0 ,
25
+ player = PlayerId (),
26
+ }
27
+
22
28
local vehicleInfo = {
23
29
netId = nil ,
24
30
seat = nil ,
@@ -126,20 +132,37 @@ RegisterNetEvent('EasyAdmin:SetPlayerMuted', function(player,state)
126
132
end
127
133
end )
128
134
129
- Citizen .CreateThread ( function ()
130
- while true do
131
- Citizen .Wait (0 )
132
- if frozen then
133
- local localPlayerPedId = PlayerPedId ()
134
- FreezeEntityPosition (localPlayerPedId , frozen )
135
- if IsPedInAnyVehicle (localPlayerPedId , true ) then
136
- FreezeEntityPosition (GetVehiclePedIsIn (localPlayerPedId , false ), frozen )
137
- end
138
- else
139
- Citizen .Wait (200 )
135
+ function freezeMe ()
136
+
137
+ Citizen .CreateThread (function ()
138
+
139
+ local disableShootingWhileFrozen = GetConvar (" ea_disableShootingWhileFrozen" , ' false' )
140
+
141
+ while frozen do
142
+
143
+ FreezeEntityPosition (cachedInfo .ped , frozen )
144
+ if cachedInfo .veh ~= 0 then
145
+ FreezeEntityPosition (cachedInfo .veh , frozen )
146
+ end
147
+ if disableShootingWhileFrozen == ' true' then
148
+ DisablePlayerFiring (cachedInfo .player , true )
149
+ end
150
+
151
+ Wait (0 )
152
+
140
153
end
154
+
155
+ end )
156
+
157
+ end
158
+
159
+ function unFreezeMe ()
160
+ local localPlayerPedId = PlayerPedId ()
161
+ FreezeEntityPosition (localPlayerPedId , false )
162
+ if IsPedInAnyVehicle (localPlayerPedId , true ) then
163
+ FreezeEntityPosition (GetVehiclePedIsIn (localPlayerPedId , false ), false )
141
164
end
142
- end )
165
+ end
143
166
144
167
RegisterNetEvent (" EasyAdmin:requestSpectate" , function (playerServerId , tgtCoords )
145
168
local localPlayerPed = PlayerPedId ()
@@ -166,6 +189,7 @@ RegisterNetEvent("EasyAdmin:requestSpectate", function(playerServerId, tgtCoords
166
189
end
167
190
spectatePlayer (localPlayerPed ,GetPlayerFromServerId (PlayerId ()),GetPlayerName (PlayerId ()))
168
191
frozen = false
192
+ unFreezeMe ()
169
193
return
170
194
else
171
195
if not oldCoords then
@@ -174,6 +198,7 @@ RegisterNetEvent("EasyAdmin:requestSpectate", function(playerServerId, tgtCoords
174
198
end
175
199
SetEntityCoords (localPlayerPed , tgtCoords .x , tgtCoords .y , tgtCoords .z - 10.0 , 0 , 0 , 0 , false )
176
200
frozen = true
201
+ freezeMe ()
177
202
stopSpectateUpdate = true
178
203
local adminPed = localPlayerPed
179
204
local playerId = GetPlayerFromServerId (playerServerId )
252
277
Citizen .CreateThread ( function ()
253
278
while true do
254
279
Citizen .Wait (500 )
280
+ local localPlayerPed = PlayerPedId ()
255
281
if drawInfo and not stopSpectateUpdate then
256
- local localPlayerPed = PlayerPedId ()
257
282
local targetPed = GetPlayerPed (drawTarget )
258
283
local targetGod = GetPlayerInvincible (drawTarget )
259
284
@@ -264,6 +289,11 @@ Citizen.CreateThread( function()
264
289
else
265
290
Citizen .Wait (1000 )
266
291
end
292
+ cachedInfo = {
293
+ ped = localPlayerPed ,
294
+ veh = GetVehiclePedIsIn (localPlayerPed , false ),
295
+ player = PlayerId (),
296
+ }
267
297
end
268
298
end )
269
299
@@ -328,11 +358,11 @@ end, false)
328
358
329
359
RegisterNetEvent (" EasyAdmin:FreezePlayer" , function (toggle )
330
360
frozen = toggle
331
- local playerPed = PlayerPedId ()
332
- FreezeEntityPosition ( playerPed , frozen )
333
- if IsPedInAnyVehicle ( playerPed , false ) then
334
- FreezeEntityPosition ( GetVehiclePedIsIn ( playerPed , false ), frozen )
335
- end
361
+ if frozen then
362
+ freezeMe ( )
363
+ else
364
+ unFreezeMe ( )
365
+ end
336
366
end )
337
367
338
368
@@ -376,6 +406,7 @@ function spectatePlayer(targetPed,target,name)
376
406
StopDrawPlayerInfo ()
377
407
TriggerEvent (" EasyAdmin:showNotification" , GetLocalisedText (" stoppedSpectating" ))
378
408
frozen = false
409
+ unFreezeMe ()
379
410
Citizen .Wait (200 ) -- to prevent staying invisible
380
411
SetEntityVisible (playerPed , true , 0 )
381
412
SetEntityCollision (playerPed , true , true )
0 commit comments