sasinosoft 0 Posted January 7 Share Posted January 7 In regular FiveM BaseScripts you can create multiple game tick threads simply by creating different `Tick` event handlers: // Somewhere in constructor Tick += OnTick1; Tick += OnTick2; Tick += OnTick3; // Somewhere else in the BaseScript derived class private async Task OnTick1() { await BaseScript.Delay(0); // every tick if (IsControlJustPressed(2, 51)) // something that needs to be executed every single tick to work correctly { } } private async Task OnTick2() { await BaseScript.Delay(100); // every 100 ms foreach (var ped in peds) // something that's not necessary to execute every tick { ped.Task.ClearAll(); } } private async Task OnTick3() { await BaseScript.Delay(500); // every 500 ms foreach (var ped in peds) // something that's better not to execute too often because it's computationally expensive { var v = GetEntityCoords(ped); var dist = v.DistanceToSquared(y); // .. } } However, in a FivePD Callout, handling the Tick event with 3 different handlers, will just make them execute one after the other... So basically, the game will wait for OnTick1 to end before doing OnTick2, and wait for OnTick2 to end before doing OnTick3, which in the example aboves, breaks the IsControlJustPressed check. Quote Link to post Share on other sites
Management Team NorthCam18 311 Posted January 8 Management Team Share Posted January 8 Eyyyy! Thanks for sharing this resource! If you're not already in our API Discord dedicated to the FivePD API, you can join here! Quote NorthCam18 OPERATIONS DIRECTOR GitHub Account | northcam@gtapolicemods.com Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.