public void FixShipModLookedAt() { if (Context.Player == null) { Context.Respond("Console has no Character so cannot use this command. Use !fixshipmod <Gridname> instead!"); return; } IMyCharacter character = Context.Player.Character; if (character == null) { Context.Respond("You have no Character currently. Make sure to spawn and be out of cockpit!"); return; } var steamId = new SteamIdCooldownKey(PlayerUtils.GetSteamId(Context.Player)); if (!CheckConformation(steamId, 0, "nogrid", character)) { return; } try { var result = ShipFixerCore.Instance.FixShip(character, 0); WriteResponse(result); } catch (Exception e) { Log.Error(e, "Error on fixing ship"); } }
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 FixShipModGridName(string gridName) { var steamId = new SteamIdCooldownKey(PlayerUtils.GetSteamId(Context.Player)); if (!CheckConformation(steamId, 0, gridName, null)) { return; } try { var result = ShipFixerCore.Instance.FixShip(0, gridName); WriteResponse(result); } catch (Exception e) { Log.Error(e, "Error on fixing ship"); } }
private void ChangeCooldownOnFactionChange(long identityId) { var cooldownMs = Config.CooldownMinutesFactionChange * 60 * 1000L; ulong steamId = MySession.Static.Players.TryGetSteamId(identityId); var steamIdKey = new SteamIdCooldownKey(steamId); if (cooldownMs <= 0) { CooldownManagerFactionChange.StopCooldown(steamIdKey); } else { CooldownManagerFactionChange.StartCooldown(steamIdKey, COOLDOWN_COMMAND, cooldownMs); } Log.Info("Player " + PlayerUtils.GetPlayerNameById(identityId) + " was put into Cooldown for Faction Change"); }
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"); } }
private void BuyInternal(long price, PurchaseMode mode) { if (Context.Player == null) { Context.Respond("Only an actual player can buy GPS!"); return; } if (price < 0) { Context.Respond("This command was disabled in the settings. Use '!gps list commands' to see which commands are active!"); return; } var player = Context.Player; var identity = PlayerUtils.GetIdentityById(player.IdentityId); price = GetAdjustedPriceForPlayer(price, identity); if (Plugin.Config.MustBeInFactionToBuy) { var faction = FactionUtils.GetPlayerFaction(identity.IdentityId); if (faction == null) { Context.Respond("You must be part of a Faction to buy GPS!"); return; } } if (mode == PurchaseMode.ONLINE || mode == PurchaseMode.RANDOM) { var minPlayersOnline = Plugin.Config.MinPlayerOnlineToBuy; int onlineCount = MySession.Static.Players.GetOnlinePlayerCount(); if (onlineCount < minPlayersOnline) { Context.Respond("For Online/Random gps at least " + minPlayersOnline + " players must be online!"); return; } } var minOnlineTime = Plugin.Config.MinOnlineMinutesToBuy; if (minOnlineTime > 0) { var lastSeen = Plugin.getLastLoginDate(identity.IdentityId); var minOnlineDate = DateTime.Now.AddMinutes(-Plugin.Config.MinOnlineMinutesToBuy); if (lastSeen > minOnlineDate) { int differenceSeconds = (int)lastSeen.Subtract(minOnlineDate).TotalSeconds; int minutes = (differenceSeconds / 60); int seconds = differenceSeconds % 60; Context.Respond("You are not online for long enough! You must be online for at least " + minutes.ToString("00") + ":" + seconds.ToString("00") + " more minutes!"); return; } } var minPCUToBuy = Plugin.Config.MinPCUToBuy; if (minPCUToBuy > 0) { var pcuBuilt = identity.BlockLimits.PCUBuilt; var neededPcu = Plugin.Config.MinPCUToBuy; if (neededPcu > pcuBuilt) { Context.Respond("You dont have enough PCU to buy! You need at least " + (neededPcu - pcuBuilt) + " more!"); return; } } var cooldownManager = Plugin.CooldownManager; var cooldownManagerFaction = Plugin.CooldownManagerFactionChange; var steamId = new SteamIdCooldownKey(player.SteamUserId); long currentBalance = MyBankingSystem.GetBalance(player.IdentityId); if (currentBalance < price) { Context.Respond("You dont have enough credits to effort a GPS! You need at least " + price.ToString("#,##0") + " SC."); return; } if (!cooldownManagerFaction.CheckCooldown(steamId, GpsRoulettePlugin.COOLDOWN_COMMAND, out long remainingSecondsFaction)) { Log.Info("Faction Cooldown for Player " + player.DisplayName + " still running! " + remainingSecondsFaction + " seconds remaining!"); Context.Respond("Command is still on cooldown after you changed Factions for " + remainingSecondsFaction + " seconds."); return; } if (!cooldownManager.CheckCooldown(steamId, GpsRoulettePlugin.COOLDOWN_COMMAND, 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; } var buyables = FindFilteredBuyablesForPlayer(mode); if (buyables.Count == 0) { Context.Respond("Currently there is no GPS available for purchase. Please try again later!"); return; } if (!CheckConformation(steamId, mode, price)) { return; } if (BuyRandomFromDict(buyables)) { var config = Plugin.Config; var cooldownMs = config.CooldownMinutes * 60 * 1000L; MyBankingSystem.ChangeBalance(player.IdentityId, -price); cooldownManager.StartCooldown(steamId, GpsRoulettePlugin.COOLDOWN_COMMAND, cooldownMs); Context.Respond("Purchase successful!"); } else { Context.Respond("The location of the selected player could not be retrieved. The purchase was cancelled. Please try again."); } }