private void GivePlayerKit(RocketPlayer _player, string _kit, bool _adminGive) { foreach (Kit kit in this.Configuration.Kits) //Loop through kits and see if kit with name exists. { if (kit.Name.ToLower().Equals(_kit.ToLower())) //Found a matching kit. { if (this.Configuration.randomProfessionMode && this.Configuration.professionChatMessages && _adminGive == false) { RocketChat.Say(_player, "You spawned as a " + _kit + "." + " " + kit.SpawnPercentChance + "% Chance."); } foreach (KitItem kitItem in kit.Items) //Loop through all items { if (!_player.GiveItem(kitItem.ItemId, kitItem.Amount)) { logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "Failed to give player item!"); } } return; } else { } } logHelper.LogMessage(3, "Kit does not exist!"); }
internal void listJails(RocketPlayer caller) { if (cells.Count == 0) { RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_jail_notset")); return; } else { string jailsString = ""; foreach (KeyValuePair <string, Cell> jail in cells) { jailsString += jail.Value.Name + ", "; } if (jailsString != "") { jailsString = jailsString.Remove(jailsString.Length - 2) + "."; } RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_jail_list", jailsString)); return; } }
private void PrintMessageToPlayerList(string _message) { foreach (ulong sID in playerIDSendToList) { RocketChat.Say(RocketPlayer.FromCSteamID((CSteamID)sID), parentName + ": " + _message); } }
private static async Task StartRestApi() { string host = "https://open.rocket.chat"; RocketChat rocketChat = new RocketChat(host); var loginResult = await rocketChat.Api.Authentication.Login("", ""); if (loginResult.Success) { var channels = await rocketChat.Api.Channels.ListJoined(); foreach (var channel in channels.Content._Channels) { System.Console.WriteLine($"{channel.Id} - {channel.Name}"); if (channel.Fname == "testingChannel") { var result = await DeleteChannel(rocketChat, channel.Id); //ChannelQuery.History query = new ChannelQuery.History //{ // RoomId = channel.Id, // Offset = 50, // Inclusive = true //}; //Result<Messages> messagesResult = await rocketChat.Api.Channels.History(query); //var messages = messagesResult.Content; //Result<Messages> messagesResult = await rocketChat.Api.Channels.Messages(channel.Id); //var messages = messagesResult.Content; } } } }
internal void listPlayers(RocketPlayer caller) { if (players.Count == 0) { RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_player_list_clear")); return; } else { string playersString = ""; foreach (KeyValuePair <string, Sentence> player in players) { try { playersString += RocketPlayer.FromName(player.Key).CharacterName + " (" + player.Value.Cell.Name + "), "; } catch { } } if (playersString != "") { playersString = playersString.Remove(playersString.Length - 2) + "."; } RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_player_list", playersString)); return; } }
public void Execute(RocketPlayer caller, string[] command) { if (command.Length < 2) { RocketChat.Say(caller, "You did not specify a name or item IDs. Usage: /" + string.Format(Usage, Name)); return; } Unit u = (from Unit unit in Blitz.Instance.Configuration.Units where unit.Name.ToLower().Equals(command [0]) select unit).FirstOrDefault <Unit> (); if (u != null) { RocketChat.Say(caller, "A unit already exists with that name."); return; } List <UnitItem> loadout = new List <UnitItem> (); for (int i = 1; i < command.Length; i++) { loadout.Add(new UnitItem(UInt16.Parse(command [i]))); } Blitz.Instance.Configuration.Units.Add(new Unit(command [0], false, loadout)); Blitz.Instance.Configuration.Save(); RocketChat.Say(caller, "Successfully added new unit '" + command [0] + "'."); }
private static async Task CreateChannel(RocketChat rocketChat) { var payload = new Payload.Create { Name = "testingChannel" }; await rocketChat.Api.Channels.Create(payload); }
internal void removePlayer(RocketPlayer caller, string playerName) { RocketPlayer target; try { target = RocketPlayer.FromCSteamID(new CSteamID(Convert.ToUInt64(playerName))); } catch { target = RocketPlayer.FromName(playerName); } if (target != null && players.ContainsKey(target.ToString())) { removePlayerFromJail(target, players[target.ToString()]); RocketChat.Say(target, JailTime.Instance.Translate("jailtime_player_release_msg")); if (caller != null) { RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_player_released", target.CharacterName)); } players.Remove(target.ToString()); } else { if (caller != null) { RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_player_notfound", playerName)); } return; } }
public void Execute(RocketPlayer caller, string[] command) { System.Random rand = new System.Random(); int bombsCount = 0; Timer tmr = new Timer(500 * rand.Next(1, 6) + 200); Vector3 initialPosition = caller.Position; tmr.Elapsed += delegate { tmr.Interval = 500 * rand.Next(1, 6) + 200; bombsCount++; if (bombsCount > 10) { tmr.Stop(); } Vector3 explosionPosition = new Vector3( initialPosition.x + rand.Next(-25, 25), initialPosition.y + rand.Next(2, 10), initialPosition.z + rand.Next(-25, 25) ); // The below code is taken from the SDG method 'Grenade#Explode'. DamageTool.explode(explosionPosition, 10, EDeathCause.GRENADE, 200, 200, 200, 200, 200, 1000); EffectManager.sendEffect(34, EffectManager.r, explosionPosition); }; tmr.Start(); RocketChat.Say(caller, "You are being bombarded by the enemy!"); }
private void onPlayerConnect(RocketPlayer p) { PlayerData data = PlayerData.ForPlayer(p); if (data == null) { // The player does not have saved data. data = new PlayerData(p.CSteamID, ERank.PRIVATE, Unit.DefaultUnit); Logger.Log("Saving new data for player '" + p.SteamName + "'."); Logger.Log("\t> Rank: " + ERank.PRIVATE + "."); Logger.Log("\t> Unit: " + Unit.DefaultUnit.Name + "."); // Assign the player to the team with the least players. Team team1 = Blitz.Instance.Configuration.Teams[0]; Team team2 = Blitz.Instance.Configuration.Teams[1]; if (team1.Players.Count <= team2.Players.Count) { team1.AddPlayer(data); } else { team2.AddPlayer(data); } } else { // The player already has saved data. Logger.Log("Using existing saved data for player '" + p.SteamName + "'."); } RocketChat.Say(string.Format("{0} {1} joined.", data.Rank, p.SteamName)); }
// Player Methods internal void addPlayer(RocketPlayer caller, string playerName, string jailName = "", uint jailTime = 0) { Cell jail; RocketPlayer target = RocketPlayer.FromName(playerName); if (jailTime == 0) { jailTime = Configuration.JailTimeInSeconds; } if (target == null) { RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_player_notfound", jailName)); return; } else if (players.ContainsKey(target.ToString())) { RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_player_in_jail", target.CharacterName)); return; } else { if (target.IsAdmin || target.Permissions.Contains("jail.immune")) { RocketChat.Say(target, JailTime.Instance.Translate("jailtime_player_immune")); return; } else if (cells.Count == 0) { RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_jail_notset", jailName)); return; } else if (jailName == "") { jail = getRandomCell(); } else { jail = getCellbyName(jailName); } if (jail == null) { RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_jail_notfound", jailName)); return; } players.Add(target.ToString(), new Sentence(jail, jailTime, target.Position)); movePlayerToJail(target, jail); target.GiveItem(303, 1); target.GiveItem(304, 1); RocketChat.Say(target, JailTime.Instance.Translate("jailtime_player_arrest_msg", jailTime)); RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_player_arrested", target.CharacterName, jail.Name)); } }
public static void Respond(RocketPlayer caller, String message) { if (caller == null) { Logger.Log(message); } else { RocketChat.Say(caller, message); } }
internal void List(RocketPlayer caller) { if (!caller.IsAdmin && !caller.Permissions.Contains("givekit") && !caller.Permissions.Contains("givekit.*")) { RocketChat.Say(caller, GiveKit.Instance.Translate("command_givekit_no_permissions")); return; } List <string> kitLists = new List <string>(); String kits = ""; byte v = 0; foreach (Kit kit in GiveKit.Instance.Configuration.Kits) { if (caller.IsAdmin || caller.Permissions.Contains("givekit." + kit.Name.ToLower()) || caller.Permissions.Contains("givekit.*")) { if (v == 7) { if (kits != "") { kits = kits.Remove(kits.Length - 1); } kitLists.Add(kits); kits = ""; v = 0; } kits += ' ' + kit.Name + ','; v++; } } if (kits != "") { kits = kits.Remove(kits.Length - 1); } kitLists.Add(kits); if (caller.IsAdmin || caller.Permissions.Contains("givekit.share") || caller.Permissions.Contains("givekit.*")) { RocketChat.Say(caller, GiveKit.Instance.Translate("command_givekit_instructions_share")); } else { RocketChat.Say(caller, GiveKit.Instance.Translate("command_givekit_instructions")); } foreach (string kitString in kitLists) { RocketChat.Say(caller, GiveKit.Instance.Translate("command_givekit_available_kits", kitString)); } return; }
internal void teleportToCell(RocketPlayer caller, string jailName) { if (!cells.ContainsKey(jailName.ToLower())) { RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_jail_notfound", jailName)); return; } else { caller.Teleport(cells[jailName.ToLower()].Location, caller.Rotation); } }
public void Execute(RocketPlayer caller, string[] command) { Vector3 playerLoc = caller.Position; Blitz.Instance.Configuration.Lobby.x = playerLoc.x; Blitz.Instance.Configuration.Lobby.y = playerLoc.y; Blitz.Instance.Configuration.Lobby.z = playerLoc.z; Blitz.Instance.Configuration.Save(); RocketChat.Say(caller, string.Format("Successfully set the lobby at {0}.", playerLoc)); }
public void Execute(Rocket.Unturned.Player.RocketPlayer caller, string[] command) { DateTime currenttime = DateTime.Now; DateTime delaytime; //ushort id2 = ushort.Parse(command[0]); // TODO how does this differ from GetUInt16Parameter() ? ushort?id = RocketCommandExtensions.GetUInt16Parameter(command, 0); int? count = RocketCommandExtensions.GetInt32Parameter(command, 1); float? delay = RocketCommandExtensions.GetFloatParameter(command, 2); // if ((command.Length < 3 && caller == null) || (command.Length < 3 && caller.HasPermission("advancedeffect"))) if (command.Length < 3 && (caller.HasPermission("advancedeffect") || caller == null || caller.IsAdmin)) { RocketChat.Say(caller, "missing parameters! command usage: <id> <amount of times> <delay between effects>"); } else if (command.Length == 3 && (caller == null || caller.IsAdmin || caller.HasPermission("advancedeffect"))) { for (int ii = 1; ii <= count.Value; ii++) { delaytime = currenttime.AddMilliseconds(delay.Value); bool doloop = true; while (doloop) { continuelooping: currenttime = DateTime.Now; if (currenttime >= delaytime) { // caller.TriggerEffect(id.Value); Logger.Log("the time comparison worked!"); doloop = false; } else { goto continuelooping; } } } } else { if (caller == null) { Logger.Log("u dont have permission to use this command!"); } else { RocketChat.Say(caller, "u dont have permission to use this command!"); } } }
public void Execute(RocketPlayer caller, string[] command) { // If a unit was not specified, output a list of available units. if (command.Length == 0) { RocketChat.Say(caller, "You did not specify a unit."); RocketChat.Say(caller, "Units are: " + Unit.UnitList); return; } // If a unit name was entered, make sure it is valid. Unit unit = Unit.FromString(command [0], false); if (unit == null) { RocketChat.Say(caller, "Class not found."); return; } // Check the user's current unit. if (PlayerData.ForPlayer(caller).Unit.Equals(unit.Name)) { RocketChat.Say(caller, "You are already " + unit.Name); return; } else { RocketChat.Say(caller, "You have changed unit."); caller.Inventory.Clear(); } // Add them to their new unit. Team t = Team.ForPlayer(PlayerData.ForPlayer(caller)); PlayerData pd = (from PlayerData d in t.Players where d.SteamID64.Equals(caller.CSteamID.ToString()) select d).FirstOrDefault <PlayerData> (); pd.Unit = unit.Name; Blitz.Instance.Configuration.Save(); // Give them their items. if (!Unit.GiveLoadout(PlayerData.ForPlayer(caller))) { RocketChat.Say(caller, "Failed to find items in loadout."); } // Teleport them to their unit's spawn. caller.Teleport(SpawnManager.Instance.GetSpawnpoint(PlayerData.ForPlayer(caller)), 0); }
private void OnTimedEvent(RocketPlayer caller) { try { if (destroyList[dIdx].Type == "s") { try { StructureManager.damage(destroyList[dIdx].Transform, destroyList[dIdx].Transform.position, 65535, 1); } catch { } } else if (destroyList[dIdx].Type == "b") { try { BarricadeManager.damage(destroyList[dIdx].Transform, 65535, 1); } catch { } } else if (destroyList[dIdx].Type == "v") { try { destroyList[dIdx].Vehicle.askDamage(65535); } catch { } } else if (destroyList[dIdx].Type == "z") { EPlayerKill pKill; try { for (int i = 0; i < 100; i++) { destroyList[dIdx].Zombie.askDamage(255, destroyList[dIdx].Zombie.transform.up, out pKill); } } catch { } } dIdx++; if (destroyList.Count == dIdx) { RocketChat.Say(caller, Translate("wreckingball_complete", dIdx)); StructureManager.save(); Abort(); processing = false; } } catch (Exception) { throw; } }
private void Tick(System.Object stateInfo) { // If the time has run out, stop the timer if (Ticks == 0) { Timer.Change(Timeout.Infinite, Timeout.Infinite); this.OnFinish.Invoke(); } if (NumbersToPrint.Contains(Ticks)) { RocketChat.Say(string.Format(Message, Ticks), Color.cyan); } Ticks--; }
internal void Teleport(RocketPlayer caller, bool toBarricades = false) { if (SDG.StructureManager.Structures.Count == 0 && BarricadeManager.BarricadeRegions.LongLength == 0) { RocketChat.Say(caller, Translate("wreckingball_map_clear")); return; } Vector3 tpVector; if (!toBarricades) { foreach (Transform trf in SDG.StructureManager.Structures) { if (Vector3.Distance(trf.position, caller.Position) > 200) { tpVector = new Vector3(trf.position.x, trf.position.y + 3, trf.position.z); caller.Teleport(tpVector, caller.Rotation); return; } } } else { for (int k = 0; k < BarricadeManager.BarricadeRegions.GetLength(0); k++) { for (int l = 0; l < BarricadeManager.BarricadeRegions.GetLength(1); l++) { foreach (Transform trf in BarricadeManager.BarricadeRegions[k, l].Barricades) { if (Vector3.Distance(trf.position, caller.Position) > 20) { tpVector = new Vector3(trf.position.x, trf.position.y + 3, trf.position.z + 3); caller.Teleport(tpVector, caller.Rotation); return; } } } } } Vector3 trfPos = SDG.StructureManager.Structures[UnityEngine.Random.Range(0, SDG.StructureManager.Structures.Count - 1)].position; tpVector = new Vector3(trfPos.x, trfPos.y + 5, trfPos.z); caller.Teleport(tpVector, caller.Rotation); }
// Jail Methods internal void setJail(RocketPlayer caller, string jailName, UnityEngine.Vector3 location) { if (caller != null) { if (cells.ContainsKey(jailName.ToLower())) { RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_jail_exists", jailName)); return; } else { RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_jail_set", jailName)); } Configuration.Cells.Add(new CellLoc(jailName, location.x, location.y, location.z)); Configuration.Save(); } cells.Add(jailName.ToLower(), new Cell(jailName, location)); }
internal void Confirm(RocketPlayer caller) { if (destroyList.Count <= 0) { RocketChat.Say(caller, WreckingBall.Instance.Translate("wreckingball_help")); } else { if (aTimer == null) { aTimer = new Timer(delSpeed); aTimer.Elapsed += delegate { OnTimedEvent(caller); }; aTimer.AutoReset = true; } processing = true; RocketChat.Say(caller, Translate("wreckingball_initiated", (Math.Ceiling((double)(destroyList.Count * delSpeed) / 1000)))); dIdx = 0; aTimer.Enabled = true; } }
public void Execute(RocketPlayer caller, string[] command) { // If a team or unit was not specified, output a list of available options. if (command.Length < 2) { RocketChat.Say(caller, "You did not specify a team or unit. Usage: /" + string.Format(Usage, Name)); RocketChat.Say(caller, "Teams are: " + Team.TeamList); RocketChat.Say(caller, "Units are: " + Unit.UnitList); return; } // Make sure a team exists with the specified name. // TODO extract into 'Team##FromString' method. Team team = (from Team t in Blitz.Instance.Configuration.Teams where t.Name.ToLower().Contains(command [0].ToLower()) select t).FirstOrDefault <Team> (); if (team == null) { RocketChat.Say(caller, "You did not specify a valid team."); RocketChat.Say(caller, "Teams are: " + Team.TeamList); return; } // Make sure a unit exists with the specified name. Unit unit = Unit.FromString(command[1]); if (unit == null) { RocketChat.Say(caller, "You did not specify a valid unit."); RocketChat.Say(caller, "Units are: " + Unit.UnitList); return; } Vector3 playerLoc = caller.Position; team.Spawns.Add(new Spawn(playerLoc.x, playerLoc.y, playerLoc.z, unit.Name)); RocketChat.Say(caller, string.Format("Successfully added a new spawn at {0} for {1} {2}.", playerLoc, team.Name, unit.Name)); Blitz.Instance.Configuration.Save(); }
internal void Scan(RocketPlayer caller, string filter, uint radius) { Wreck(caller, filter, radius, true); string report = ""; if (WreckCategories.Instance.reportList.Count > 0) { foreach (KeyValuePair <char, uint> reportFilter in WreckCategories.Instance.reportList) { report += " " + WreckCategories.Instance.category[reportFilter.Key].Name + ": " + reportFilter.Value + ","; } if (report != "") { report = report.Remove(report.Length - 1); } RocketChat.Say(caller, Translate("wreckingball_scan", radius, report)); } else { RocketChat.Say(caller, Translate("wreckingball_not_found", radius)); } }
internal void unsetJail(RocketPlayer caller, string jailName) { if (!cells.ContainsKey(jailName.ToLower())) { RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_jail_notfound", jailName)); return; } else { RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_jail_unset", jailName)); cells.Remove(jailName.ToLower()); foreach (CellLoc cell in Configuration.Cells) { if (cell.Name.ToLower() == jailName.ToLower()) { Configuration.Cells.Remove(cell); Configuration.Save(); return; } } } }
private void checkFeast() { Feast feast = Feast.instance; if (feast.Configuration.Enabled) { if ((feast.nextFeast - DateTime.Now).TotalSeconds - 300.0 <= 0.0 && (DateTime.Now - feast.lastMsg).TotalSeconds >= 60.0) { byte b = feast.msgNum; if (b != 0) { RocketChat.Say(string.Format(feast.Configuration.msgComingFeast, feast.nextLocation.Name(), feast.msgNum)); feast.lastMsg = DateTime.Now; feast.msgNum -= 1; } else { RocketChat.Say(string.Format(feast.Configuration.msgNowFeast, feast.nextLocation.Name())); feast.lastMsg = DateTime.Now; feast.runFeast(); } } } }