private async void OnClientResourceStart(string resourceName) { if (GetCurrentResourceName() != resourceName) { return; } await UI.Init(GetCurrentResourceName(), EventHandlers); RegisterCommand("test", new Action <int, List <object>, string>(async(source, args, raw) => { var testIndex = 0; if (args.Count != 1 || !int.TryParse(args[0].ToString(), out testIndex)) { PrintToChat("Usage: /test [test_number]"); return; } if (testIndex >= _tests.Count || testIndex < 0) { PrintToChat($"Unable to start test with number of {testIndex}. Type /tests to show all possible tests."); return; } if (_currentTest != null) { _currentTest.DidEnd -= CurrentTestOnDidEnd; _currentTest.Abort(); PrintToChat($"Currently running test {_currentTest.TestName} has been aborted."); } _currentTest = _tests[testIndex]; if (_currentTest.ActivityState == ActivityState.NotReady) { PrintToChat("Loading test..."); await _currentTest.Prepare(); PrintToChat("Test has been loaded."); } if (_currentTest.ActivityState == ActivityState.Consumed) { _currentTest.Reset(); } PrintToChat($"Starting test {_currentTest.TestName}."); _currentTest.DidEnd += CurrentTestOnDidEnd; _currentTest.Start(); }), false); RegisterCommand("abort", new Action <int, List <object>, string>((source, args, raw) => { if (args.Count != 0) { PrintToChat("Usage: /abort"); return; } if (_currentTest == null) { PrintToChat("There is nothing to abort. Type /current to check if any test is running."); return; } var abortedTest = _currentTest; _currentTest.DidEnd -= CurrentTestOnDidEnd; _currentTest.Abort(); _currentTest = null; PrintToChat($"Test {abortedTest.TestName} has been aborted."); }), false); RegisterCommand("current", new Action <int, List <object>, string>((source, args, raw) => { if (args.Count != 0) { PrintToChat("Usage: /current"); return; } PrintToChat(_currentTest == null ? "No tests are running right now." : $"Current test is {_currentTest.TestName}"); }), false); RegisterCommand("tests", new Action <int, List <object>, string>((source, args, raw) => { if (args.Count != 0) { PrintToChat("Usage: /help"); return; } if (_tests.Count == 0) { PrintToChat("There are no tests to check out."); return; } var testIndex = 0; foreach (var test in _tests) { PrintToChat($"{testIndex++} - {test.TestName}"); } }), false); RegisterCommand("lester", new Action <int, List <object>, string>((source, args, raw) => { if (args.Count != 0) { PrintToChat("Usage: /lester"); return; } ClearPlayerWantedLevel(Game.Player.Handle); PrintToChat("Your wanted level has been reseted."); }), false); }