BenX Posted May 18, 2019 Share Posted May 18, 2019 (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(); }); } Edited May 18, 2019 by BenX Link to comment Share on other sites More sharing options...
Tokyo Youkai Posted June 26, 2020 Share Posted June 26, 2020 Have you figured out how it works? If so, how did you do it? Link to comment Share on other sites More sharing options...
Xabi Posted June 26, 2020 Share Posted June 26, 2020 Threads won't work in clientside C#, do your own timer with Tick event. Link to comment Share on other sites More sharing options...
sui228 Posted November 8, 2020 Share Posted November 8, 2020 You can use RAGE.Task.Run(action, delay); or RAGE.Task.RunBackground(action); Link to comment Share on other sites More sharing options...
enisn Posted December 26, 2020 Share Posted December 26, 2020 On 11/8/2020 at 2:55 PM, sui228 said: You can use RAGE.Task.Run(action, delay); or RAGE.Task.RunBackground(action); You talking about Server-Side. But there is no way to do it in client-side. Link to comment Share on other sites More sharing options...
enisn Posted December 26, 2020 Share Posted December 26, 2020 @sui228 is right! It works but; I'm using compiler to validate my code, so adding this class into `rage-sharp` nuget package will really help, for now I'm adding in my project to provide intellisense: using System; namespace RAGE { public class Task { public static void Run(Action action, int delay) { // to provide intellisense throw new NotImplementedException(); } public static void RunBackground(Action action) { // to provide intellisense throw new NotImplementedException(); } } } Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now