@@ -50,7 +50,7 @@ function YimActions:init()
5050 end )
5151
5252 ThreadManager :RegisterLooped (" SS_YIMACTIONS" , function ()
53- self :MainThread ()
53+ self :OnTick ()
5454 end )
5555
5656 self .m_initialized = true
@@ -127,7 +127,7 @@ function YimActions:IsPlayerBusy()
127127 or LocalPlayer :IsBrowsingApps ()
128128 or LocalPlayer :IsInWater ()
129129 or LocalPlayer :IsRagdoll ()
130- or script . is_active ( " maintransition " )
130+ or Game . IsInNetworkTransition ( )
131131 or Backend :IsPlayerSwitchInProgress ()
132132 or Backend :AreControlsDisabled ()
133133end
@@ -227,16 +227,16 @@ function YimActions:PlayAnim(animData, targetPed)
227227
228228 if (not GVars .features .yim_actions .disable_props ) then
229229 if (animData .props and # animData .props > 0 ) then
230- YimActions .PropManager :AttachProp (targetPed , animData .props )
230+ self .PropManager :AttachProp (targetPed , animData .props )
231231 end
232232
233233 if (animData .propPeds and # animData .propPeds > 0 ) then
234- YimActions .PropManager :AttachProp (targetPed , animData .propPeds , true )
234+ self .PropManager :AttachProp (targetPed , animData .propPeds , true )
235235 end
236236 end
237237
238238 if (not GVars .features .yim_actions .disable_ptfx and animData .ptfx and animData .ptfx .name ) then
239- YimActions .FXManager :StartPTFX (targetPed , animData .ptfx )
239+ self .FXManager :StartPTFX (targetPed , animData .ptfx )
240240 end
241241
242242 local isLooped = Bit .IsBitSet (animData .flags , Enums .eAnimFlags .LOOPING )
@@ -264,7 +264,7 @@ function YimActions:PlayScenario(scenarioData, targetPed, playImmediately)
264264 0.0
265265 )
266266
267- local bbq = YimActions .PropManager :SpawnProp (
267+ local bbq = self .PropManager :SpawnProp (
268268 targetPed ,
269269 { model = 286252949 },
270270 false ,
@@ -307,8 +307,7 @@ function YimActions:Play(action, ped)
307307 ped = self :GetPed (ped )
308308
309309 if (ped == LocalPlayer :GetHandle () and self :IsPlayerBusy ()) then
310- Notifier :ShowMessage (
311- " Samurai's Scripts" ,
310+ Notifier :ShowMessage (" YimActions" ,
312311 " Player is unavailable at this moment. Clear any other tasks then try again."
313312 )
314313 return
@@ -364,7 +363,7 @@ function YimActions:Cleanup(ped)
364363 self .SceneManager :Wipe ()
365364
366365 if (string.find (self .CurrentlyPlaying [ped ].data .label , " DJ" )) then
367- Audio :PartyMode (false )
366+ Audio :PartyMode (false , ped )
368367 end
369368
370369 sleep (200 )
@@ -393,15 +392,15 @@ function YimActions:ForceCleanup()
393392 self .PropManager :Wipe ()
394393 self .SceneManager :Wipe ()
395394 self .CompanionManager :Wipe ()
396- self .CurrentlyPlaying = {}
397395 self :ResetPlayer ()
398396 Audio :StopAllEmitters ()
399397 LocalPlayer :ClearTasks ()
398+ self .CurrentlyPlaying = {}
400399end
401400
402401function YimActions :OnInterruptEvent ()
403- local localPlayer = LocalPlayer :GetHandle ()
404- local current = self .CurrentlyPlaying [localPlayer ]
402+ local playerHandle = LocalPlayer :GetHandle ()
403+ local current = self .CurrentlyPlaying [playerHandle ]
405404 if (not current ) then
406405 yield ()
407406 return
@@ -419,34 +418,34 @@ function YimActions:OnInterruptEvent()
419418 return
420419 end
421420
422- if (not LocalPlayer :IsAlive () or LocalPlayer :IsBeingArrested () or Backend :IsPlayerSwitchInProgress () or script . is_active ( " maintransition " )) then
421+ if (not LocalPlayer :IsAlive () or LocalPlayer :IsBeingArrested () or Backend :IsPlayerSwitchInProgress () or Game . IsInNetworkTransition ( )) then
423422 self :ForceCleanup ()
424- sleep ( 1000 )
423+ yield ( )
425424 return
426425 end
427426
428- if (current and self :WasActionInterrupted (localPlayer )) then
427+ if (current and self :WasActionInterrupted (playerHandle )) then
429428 if (LocalPlayer :IsFalling ()) then
430429 repeat
431- sleep ( 1000 )
430+ yield ( )
432431 until not LocalPlayer :IsFalling ()
433432 sleep (1000 )
434433 end
435434
436- if LocalPlayer :IsRagdoll () then
435+ if ( LocalPlayer :IsRagdoll () ) then
437436 repeat
438- sleep ( 1000 )
437+ yield ( )
439438 until not LocalPlayer :IsRagdoll ()
440439 sleep (1000 )
441440 end
442441
443- if LocalPlayer :IsSwimming () then
444- self :Cleanup (localPlayer )
442+ if ( LocalPlayer :IsSwimming () ) then
443+ self :Cleanup (playerHandle )
445444 sleep (1000 )
446445 return
447446 end
448447
449- self :Play (current , localPlayer )
448+ self :Play (current , playerHandle )
450449 end
451450end
452451
@@ -631,7 +630,7 @@ function YimActions:GoofyUnaliveAnim()
631630 end )
632631end
633632
634- function YimActions :HandleCleanupKeybind ()
633+ function YimActions :OnKeyDown ()
635634 if (KeyManager :IsKeybindJustPressed (" stop_anim" )) then
636635 ThreadManager :Run (function ()
637636 local timer = Timer .new (1000 )
@@ -652,15 +651,15 @@ function YimActions:HandleCleanupKeybind()
652651 end
653652end
654653
655- function YimActions :MainThread ()
654+ function YimActions :OnTick ()
656655 if (next (self .CurrentlyPlaying ) == nil )
657656 and (next (self .PropManager .Props ) == nil )
658657 and (# self .CompanionManager .Companions == 0 ) then
659658 yield ()
660659 return
661660 end
662661
663- self :HandleCleanupKeybind ()
662+ self :OnKeyDown ()
664663
665664 local ped = LocalPlayer :GetHandle ()
666665 local current = self .CurrentlyPlaying [ped ]
0 commit comments