public static void JoinGame(CommandArgs args) { TSPlayer tSPlayer = args.Player; if (HubEvent.GetEventPlayerIn(tSPlayer.Name) != null) { tSPlayer.SendErrorMessage("You're already in an event! Please use /leave first!"); return; } if (args.Parameters.Count < 1) { tSPlayer.SendErrorMessage("Invalid syntax! Proper syntax: /join <Event Name>"); return; } string eventName = string.Join("", args.Parameters).ToLower(); HubEvent hubEvent = HubEvent.GetEvent(eventName); if (hubEvent == null) { tSPlayer.SendErrorMessage("Invalid syntax! Proper syntax: /forcejoinall <Event Name>"); return; } HubEvent.AddPlayerToEvent(tSPlayer, hubEvent); hubEvent.TeleportPlayerToSpawn(tSPlayer); tSPlayer.SendSuccessMessage(string.Format("You successfully joined {0}!", hubEvent.eventName)); }
public static void ForceJoin(CommandArgs args) { TSPlayer tSPlayer = args.Player; if (args.Parameters.Count < 2) { tSPlayer.SendErrorMessage("Invalid syntax! Proper syntax: /forcejoin <Player Name> <Event Name>"); return; } List <TSPlayer> tSPlayerTargets = TSPlayer.FindByNameOrID(args.Parameters[0]); if (tSPlayerTargets.Count == 0) { tSPlayer.SendErrorMessage("The player specified was not found!"); return; } if (tSPlayerTargets.Count > 1) { tSPlayer.SendErrorMessage("Multiple players with that name were found!"); return; } TSPlayer tSPlayerTarget = tSPlayerTargets.First(); string eventName = string.Join("", args.Parameters.Skip(1)).ToLower(); HubEvent hubEvent = HubEvent.GetEvent(eventName); if (hubEvent == null) { tSPlayer.SendErrorMessage("The event specified was not found!"); return; } // Check if player has already joined an event, and if so, remove them from it HubEvent playerHubEvent = HubEvent.GetEventPlayerIn(tSPlayerTarget.Name); if (playerHubEvent != null) { HubEvent.RemovePlayerFromEvent(tSPlayerTarget, playerHubEvent); } HubEvent.AddPlayerToEvent(tSPlayerTarget, hubEvent); tSPlayer.SendSuccessMessage(string.Format("{0} was successfully added to {1}!", tSPlayerTarget.Name, hubEvent.eventName)); }
public static void ForceJoinAll(CommandArgs args) { TSPlayer tSPlayer = args.Player; if (args.Parameters.Count < 1) { tSPlayer.SendErrorMessage("Invalid syntax! Proper syntax: /forcejoinall <Event Name>"); return; } string eventName = string.Join("", args.Parameters).ToLower(); HubEvent hubEvent = HubEvent.GetEvent(eventName); if (hubEvent == null) { tSPlayer.SendErrorMessage("The event specified was not found!"); return; } string players = ""; foreach (TSPlayer tSP in TShock.Players) { if (tSP == null) { continue; } // Check if player has already joined an event, and if so, remove them from it HubEvent playerHubEvent = HubEvent.GetEventPlayerIn(tSP.Name); if (playerHubEvent != null) { HubEvent.RemovePlayerFromEvent(tSP, playerHubEvent); } HubEvent.AddPlayerToEvent(tSP, hubEvent); players += tSP.Name + ", "; } players = players.Trim(' ', ','); tSPlayer.SendSuccessMessage(string.Format("{0} was successfully added to {1}!", players, hubEvent.eventName)); }