private void controller_BeginMap(ServerController sender, ManiaPlanetBeginMap methodCall) { currentCheckpoints.Clear(); currentMap = methodCall.Map; getGameMode(); // Has to be called with the UId, because otherwise it'd return the old currentRecords. currentRecords = GetRecords(currentMap.UId).Cast <LocalRecord>().ToDictionary(record => record.Player.Login); }
/// <summary> /// Gets called when the plugin is loaded. /// Use this to add your methods to the controller's events and load your saved data. /// </summary> /// <param name="controller">The controller loading the plugin.</param> /// <returns>Whether it loaded successfully or not.</returns> public override bool Load(ServerController controller) { if (!isAssemblyServerController(Assembly.GetCallingAssembly())) { return(false); } this.controller = controller; controller.BeginMap += controller_BeginMap; controller.PlayerCheckpoint += controller_PlayerCheckpoint; controller.PlayerFinish += controller_PlayerFinish; using (var command = controller.Database.CreateCommand()) { command.CommandText = tableDDL; command.ExecuteNonQuery(); } if (!getGameMode()) { return(false); } var getCurrentMapInfoCall = new GetCurrentMapInfo(); controller.CallMethod(getCurrentMapInfoCall, 5000); if (getCurrentMapInfoCall.HadFault) { return(false); } currentMap = getCurrentMapInfoCall.ReturnValue; // Has to be called with the UId, because otherwise it'd return the old currentRecords. currentRecords = GetRecords(currentMap.UId).Cast <LocalRecord>().ToDictionary(record => record.Player.Login); if (!controller.RecordsProviderManager.RegisterProvider("local", this)) { return(false); } return(true); }