public void FixShipPlayerLookAt() { IMyPlayer player = Context.Player; long playerId; if (player == null) { Context.Respond("Console has no Grids so cannot use this command. Use !fixshipmod <Gridname> instead!"); return; } else { playerId = player.IdentityId; } IMyCharacter character = player.Character; if (character == null) { Context.Respond("You have no Character currently. Make sure to spawn and be out of cockpit!"); return; } CooldownManager cooldownManager = Plugin.CommandCooldownManager; var steamId = new SteamIdCooldownKey(PlayerUtils.GetSteamId(Context.Player)); if (!cooldownManager.CheckCooldown(steamId, null, out long remainingSeconds)) { Log.Info("Cooldown for Player " + player.DisplayName + " still running! " + remainingSeconds + " seconds remaining!"); Context.Respond("Command is still on cooldown for " + remainingSeconds + " seconds."); return; } if (!CheckConformation(steamId, playerId, "nogrid", character)) { return; } try { var result = Plugin.FixShip(character, playerId); WriteResponse(result); if (result == CheckResult.SHIP_FIXED) { Log.Info("Cooldown for Player " + player.DisplayName + " started!"); cooldownManager.StartCooldown(steamId, null, Plugin.Cooldown); } } catch (Exception e) { Log.Error(e, "Error on fixing ship"); } }
public void FixShipPlayerGridName(string gridName) { IMyPlayer player = Context.Player; long playerId; if (player == null) { Context.Respond("Console has no Grids so cannot use this command. Use !fixshipmod <Gridname> instead!"); return; } else { playerId = player.IdentityId; } CooldownManager cooldownManager = Plugin.CommandCooldownManager; var steamId = new SteamIdCooldownKey(PlayerUtils.GetSteamId(Context.Player)); if (!cooldownManager.CheckCooldown(steamId, null, out long remainingSeconds)) { Log.Info("Cooldown for Player " + player.DisplayName + " still running! " + remainingSeconds + " seconds remaining!"); Context.Respond("Command is still on cooldown for " + remainingSeconds + " seconds."); return; } if (!CheckConformation(steamId, playerId, gridName, null)) { return; } try { var result = ShipFixerCore.Instance.FixShip(playerId, gridName); WriteResponse(result); if (result == CheckResult.SHIP_FIXED) { Log.Info("Cooldown for Player " + player.DisplayName + " started!"); cooldownManager.StartCooldown(steamId, null, Plugin.Cooldown); } } catch (Exception e) { Log.Error(e, "Error on fixing ship"); } }