Jump to content
  • Create New...

Recommended Posts

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

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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

Important Information

Please view the site: Terms of Use, Privacy Policy, and Guidelines. // IMPORTANT: We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.