Art of Simulation Posted August 30 Share Posted August 30 Hi, Does anyone know how I can use async code / await Task.Delay(x) to delay/wait a few seconds only in that particular method? Problem is that Script.Wait() does not work how I want, it Waits the entire class, but I want only one specific method to wait, and other methods still being executing code, without freezing the script. I've tried the following: public static void FakeDeath(Ped ped) { var t = Task.Run(async delegate { await Task.Delay(3000); GTA.UI.Notification.Show("TEST!!!"); }); t.Dispose(); } I also tried it by just making an async Task of the method, and do the Task.Delay(). This should delay only that task (method), while other tasks/methods which have to run every frame, keeps being executed. When I try above approach, the game crashes instantly. It looks like I can't use async programmability in scripthook I guess. The thing I want to achieve is only waiting one (or more) specific methods, but independent from each other. So when one method Waits, other methods should not be impacted and still be checking stuff every frame. Does anyone ever did this before? I've tried many methods (using Timers, Stopwatches etc.) but it doesn't achieve the thing I want. Thanks! Link to comment Share on other sites More sharing options...
waynieoaks Posted Thursday at 07:47 PM Share Posted Thursday at 07:47 PM (edited) Hi - Did you ever solve this? I have managed to get async to work if you want to see what I did it may help? I am not an expert - my answer may be complete rubbish. Edited Thursday at 07:49 PM by waynieoaks 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