BenX Posted May 18, 2019 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
Tokyo Youkai Posted June 26, 2020 Posted June 26, 2020 Have you figured out how it works? If so, how did you do it?
Xabi Posted June 26, 2020 Posted June 26, 2020 Threads won't work in clientside C#, do your own timer with Tick event.
sui228 Posted November 8, 2020 Posted November 8, 2020 You can use RAGE.Task.Run(action, delay); or RAGE.Task.RunBackground(action);
enisn Posted December 26, 2020 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.
enisn Posted December 26, 2020 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(); } } }
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