Skip to content

Commit

Permalink
Use Fibers instead of a loop
Browse files Browse the repository at this point in the history
  • Loading branch information
justalemon committed Nov 19, 2023
1 parent 316814a commit 9221acf
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions LemonUI.RagePluginHook.Example/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,8 @@ public static void Main()
pool.Add(menu);
pool.Add(submenu);

// Every GTA mods needs it's own Tick event, so let's make one
// Remember that RPH uses Fibers, and fibers need to yield so they don't block
while (true)
{
OnTick();
GameFiber.Yield();
}
// Every GTA mods needs it's own Tick event, so let's make one with Fibers
GameFiber.StartNew(OnTick);
}

private static void OnTick()
Expand Down Expand Up @@ -98,6 +93,9 @@ private static void OnTick()
menu.Visible = true;
}
}

// Remember that RPH uses Fibers, and fibers need to yield so they don't block
GameFiber.Yield();
}

// You can also register a console command
Expand Down

0 comments on commit 9221acf

Please sign in to comment.