Sign in to follow this  
BenX

Timer on C# client-side not working

Recommended Posts

Posted (edited)

I'm using C# task to handle event after player spawn, but just look like only the message function work perfectly with the task and others don't.
Here my code:

private void OnPlayerSpawn(Events.CancelEventArgs cancel)
{
  player.FreezePosition(true);
  player.FreezeCameraRotation();
  player.SetInvincible(true);

  RAGE.Game.Graphics.StopScreenEffect("DeathFailMPIn");
  MainCam = RAGE.Game.Cam.CreateCameraWithParams(RAGE.Game.Misc.GetHashKey("DEFAULT_SCRIPTED_CAMERA"), 350.9601f, -638.4666f, 36.8042f, 0, 0, 0, 90.0f, true, 2);
  RAGE.Game.Cam.SetCamActive(Global.Camera.Main, true);
  RAGE.Game.Cam.PointCamAtCoord(Main, 0.02908f, 0.99953f, 0.00921f);
  RAGE.Game.Cam.RenderScriptCams(true, false, 0, true, false, 0);

  Run(() =>
      {
        RAGE.Game.Cam.DestroyCam(MainCam, true);
        RAGE.Game.Cam.RenderScriptCams(false, false, 0, true, false, 0);
        RAGE.Chat.Output("test2");
      }, 2000);
}

public static void Run(Action task, long delayTime = 0)
{
  Task.Factory.StartNew(async () =>
                        {
                          await Task.Delay((int)delayTime);
                          task();
                        });
}

k3xnwlp.jpg

Edited by BenX

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.