Hey, in every C# Script i write the Time % is complained with a Lua Script extreme high, here for example the PlayerSpawner script in C#
the Code:
using CitizenFX.Core;
using static CitizenFX.Core.Native.API;
using System;
using System.Collections;
namespace PlayerSpawner.Client
{
internal class Spawner : BaseScript
{
public Spawner()
{
EventHandlers["onClientResourceStart"] += new Action<string>(OnClientResourceStart);
}
private async void OnClientResourceStart(string resourceName)
{
if (resourceName != GetCurrentResourceName())
{
return;
}
Player player = Game.Player;
Model model = PedHash.FilmNoir;
if (!model.IsValid)
{
return;
}
model.Request();
while (!model.IsLoaded)
{
await Delay(1);
}
await player.ChangeModel(model);
model.MarkAsNoLongerNeeded();
player.Character.Position = new Vector3(126.975f, 3714.419f, 46.827f);
player.Character.IsPositionFrozen = false;
ShutdownLoadingScreen();
ShutdownLoadingScreenNui();
}
}
}
Cfx is working on an updated mono runtime, so if the overhead of the current runtime is that much of an issue then swapping is an option. It was just recently enabled with feat(scripting-mono): enable mono v2 runtime · citizenfx/fivem@37986b0 · GitHub .
# Mono rt2 prerelease
If you came in here after reading the `mono_rt2` flag in your fxmanifest, then you might not want to use it at this time. In short: only use these resources in testing environments as it's not fully released and supported yet.
The mono rt2 environment is currently in prerelease, crashes and bugs are to be expected, and the runtime may be prone to deactivation after the given dates. Using it in production is highly discouraged and no support nor guarantees are given.
Want to start developing and testing this new environment, then [start right here](README.md). If you encounter any technical issues then create your Minimal Reproducible Example (MRE or repro) and create an issue on [FiveM GitHub](https://github.com/citizenfx/fivem/issues) or contact thorium directly. [Stack Overflow has a nice help page](https://stackoverflow.com/help/minimal-reproducible-example) on how to make an MRE, thank you for using it.
1 Like
Like Linden mentioned the C# performance issues are solved in the v2 runtime, feel free to try it .
Time %
will however depend on the resource’s CPU msec
relative to the [Total CPU]
, so this value is only interesting for finding the biggest CPU hogging resource.
2 Likes
Coul you explain a little more how to use & install this, I have read the whole github, but dont understand it
Follow the setup mono_v2_get_started/Setup.md at main · thorium-cfx/mono_v2_get_started · GitHub
Most is the same as the v1 runtime, but in v2 you need to use the new assemblies (from v2/
directory) and supply the CitizenFX.<Game>.Native.dll
with your resource.