//RMTSQD:pid:destsquad:sound:text public static void Try(string[] parameters) { if (string.IsNullOrEmpty(parameters[4]) || string.IsNullOrEmpty(parameters[2])) { return; } string squad = parameters[2].ToLower(); string name = Player.GetPlayerName(parameters[1]); string message = SiusUtil.Collate(4, parameters); if (SiusConf.GetSetting.Boolean("squadonlychat")) { //player is sending a squad message to a different squad if (Player.GetSquad(parameters[1]).ToLower() != squad) { SiusLog.Log(SiusLog.WARNING, "squad", name + " tried to send a message to a different squad (refer to settings - squadonlychat)."); return; } } //It's easier to blindly send the message //RMTSQD:destsquad:sender:sound:text Zone.BroadcastMessage("RMTSQD:" + squad + ":" + name + ":" + parameters[3] + ":" + message); SiusLog.Log(SiusLog.INFORMATION, "squad", name + " sent squad message to " + squad); SiusLog.Log(SiusLog.DEBUG, "squad", "Message: " + message); }
public static void Try(string[] parameters) { //RMT:pid:destination:sound:text string sender = Player.GetPlayerName(parameters[1]); string message = SiusUtil.Collate(4, parameters); for (int i = 0; i < Player.PlayerList.Count; i++) { Player.PlayerStruct p = (Player.PlayerStruct)Player.PlayerList[i]; if (p.name == parameters[2]) { try { TcpClient tcpZone = (TcpClient)Listen.htRcon[p.ZoneName]; StreamWriter swSenderSender; swSenderSender = new StreamWriter(tcpZone.GetStream()); //RMT:pid:sender:sound:text swSenderSender.WriteLine("RMT:" + p.pid + ":" + sender + ":" + parameters[3] + ":" + message); swSenderSender.Flush(); swSenderSender = null; } catch (Exception e) { SiusLog.Log(SiusLog.DEBUG, "remote", e.Message); } SiusLog.Log(SiusLog.INFORMATION, "remote", sender + " sent remote message to " + parameters[2]); SiusLog.Log(SiusLog.DEBUG, "remote", "Message: " + message); return; } } Message.Send = "MSG:" + parameters[1] + ":0:Unable to locate player."; SiusLog.Log(SiusLog.DEBUG, "remote", "Unable to locate and send remote message from " + sender + " to " + parameters[2]); SiusLog.Log(SiusLog.DEBUG, "remote", "Message: " + message); }
public static void Try(string[] parameters) { if (!string.IsNullOrEmpty(parameters[3])) { string name = Player.GetPlayerName(parameters[1]); string password = SiusUtil.Collate(3, parameters); if (password.Contains(":")) { Message.Send = "MSG:" + parameters[1] + ":0:Your password may not contain colons."; SiusLog.Log(SiusLog.DEBUG, "password", "Unable to change [" + name + "]'s password. Password contains a colon."); return; } //Check the password length if (password.Length < 1 || password.Length > 23) { Message.Send = "MSG:" + parameters[1] + ":0:The length of you password is invalid."; SiusLog.Log(SiusLog.DEBUG, "password", "Unable to change [" + name + "]'s password. Password length is invalid."); return; } password = SiusEncrypt.Encrypt(password, name, "players"); /* Begin Database Connection */ DataTable dt = new DataTable(); SQLiteConnection SConnection = new SQLiteConnection(); SConnection.ConnectionString = SQLite.ConnectionString; SConnection.Open(); SQLiteCommand cmd = new SQLiteCommand(SConnection); cmd.CommandText = @"UPDATE 'players' SET password = @ppassword WHERE name = @pname"; SQLiteParameter ppassword = new SQLiteParameter("@ppassword"); SQLiteParameter pname = new SQLiteParameter("@pname"); cmd.Parameters.Add(ppassword); cmd.Parameters.Add(pname); ppassword.Value = password; pname.Value = name; cmd.ExecuteNonQuery(); SConnection.Close(); SConnection.Dispose(); /* End Database Connection */ Message.Send = "MSG:" + parameters[1] + ":0:Your password has been successfully changed."; SiusLog.Log(SiusLog.INFORMATION, "?password", "Successfully changed " + name + "'s password."); SiusLog.Log(SiusLog.DEBUG, "password", "Player [" + name + "] changed password to: " + password); } }
public static void Try(string[] parameters) { if (string.IsNullOrEmpty(parameters[3])) { string[] chats = Player.GetPlayerChat(parameters[1]); if (chats != null) { SendChatList(chats, parameters); SiusLog.Log(SiusLog.INFORMATION, "?chat", "Retrieved " + Player.GetPlayerName(parameters[1]) + "'s chat list."); return; } else { Message.Send = "MSG:" + parameters[1] + ":0:Empty."; } } else { Player.SetPlayerChat(parameters[1], SiusUtil.Collate(3, parameters)); SiusLog.Log(SiusLog.INFORMATION, "?chat", "Set " + Player.GetPlayerName(parameters[1]) + "'s chat list."); } }
public static void Try(string[] parameters) { Player.PlayerStruct p = Player.GetPlayer(parameters[1]); if (!string.IsNullOrEmpty(p.Squad)) { /* Begin Database Connection */ DataTable dt = new DataTable(); SQLiteConnection SConnection = new SQLiteConnection(); SConnection.ConnectionString = SQLite.ConnectionString; SConnection.Open(); SQLiteCommand cmd = new SQLiteCommand(SConnection); cmd.CommandText = @"SELECT owner FROM squads WHERE name = @nsquad"; SQLiteParameter nsquad = new SQLiteParameter("@nsquad"); SQLiteParameter pname = new SQLiteParameter("@pname"); cmd.Parameters.Add(nsquad); cmd.Parameters.Add(pname); nsquad.Value = p.Squad; pname.Value = p.name; SQLiteDataReader Reader = cmd.ExecuteReader(); dt.Load(Reader); Reader.Close(); SConnection.Close(); /* End Database Connection */ if (dt.Rows.Count > 0) { if (dt.Rows[0][0].ToString().ToLower() == p.name.ToLower()) //if owner { string password = SiusUtil.Collate(3, parameters); if (string.IsNullOrEmpty(password)) { Message.Send = "MSG:" + parameters[1] + ":0:Please specify a password."; return; } if (password.Length > 23) { Message.Send = "MSG:" + parameters[1] + ":0:Password is too long."; return; } password = SiusEncrypt.Encrypt(password, p.Squad, "squads"); /* Begin Database Connection */ SConnection.Open(); cmd.CommandText = @"UPDATE squads SET password = @spass WHERE name = @nsquad"; SQLiteParameter spass = new SQLiteParameter("@spass"); cmd.Parameters.Add(spass); spass.Value = password; cmd.ExecuteNonQuery(); SConnection.Close(); /* End Database Connection */ Message.Send = "MSG:" + parameters[1] + ":0:Squad password successfully changed."; SiusLog.Log(SiusLog.INFORMATION, "?squadpassword", p.name + " successfully changed the password to squad <" + p.Squad + ">"); return; } else { Message.Send = "MSG:" + parameters[1] + ":0:You do not own this squad."; SiusLog.Log(SiusLog.INFORMATION, "?squadpassword", p.name + " attempted to change the password of <" + p.Squad + ">, but is not owner."); return; } } } Message.Send = "MSG:" + parameters[1] + ":0:You are not on a squad."; }
public static void Try(string[] parameters) { if (!string.IsNullOrEmpty(parameters[3])) { string squad = parameters[3]; string password = SiusUtil.Collate(4, parameters); string name = Player.GetPlayerName(parameters[1]); /* Begin Database Connection */ DataTable dt = new DataTable(); SQLiteConnection SConnection = new SQLiteConnection(); SConnection.ConnectionString = SQLite.ConnectionString; SConnection.Open(); SQLiteCommand cmd = new SQLiteCommand(SConnection); cmd.CommandText = @"SELECT * FROM squads WHERE name = @nsquad"; SQLiteParameter nsquad = new SQLiteParameter("@nsquad"); cmd.Parameters.Add(nsquad); nsquad.Value = squad; SQLiteDataReader Reader = cmd.ExecuteReader(); dt.Load(Reader); Reader.Close(); SConnection.Close(); /* End Database Connection */ //The squad exists if (dt.Rows.Count > 0) { Message.Send = "MSG:" + parameters[1] + ":0:Sorry, this squad already exists."; SiusLog.Log(SiusLog.DEBUG, "?squadcreate", "Unable to create squad <" + squad + "> for " + name + ", but squad already exists."); SConnection.Dispose(); return; } else { SConnection.Open(); cmd.CommandText = @"INSERT INTO squads (name, owner, lastact) values (@nsquad, @pname, @last)"; SQLiteParameter last = new SQLiteParameter("@last"); SQLiteParameter pname = new SQLiteParameter("@pname"); cmd.Parameters.Add(last); cmd.Parameters.Add(pname); last.Value = System.DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"); pname.Value = name; cmd.ExecuteNonQuery(); cmd.CommandText = @"UPDATE squads SET password = @spass WHERE name = @nsquad"; SQLiteParameter spass = new SQLiteParameter("@spass"); cmd.Parameters.Add(spass); spass.Value = SiusEncrypt.Encrypt(password, squad, "squads"); cmd.ExecuteNonQuery(); cmd.CommandText = @"UPDATE players SET squad = @nsquad WHERE name = @pname"; cmd.ExecuteNonQuery(); SConnection.Close(); SConnection.Dispose(); Message.Send = "MSG:" + parameters[1] + ":0:Squad successfully created. Please exit" + " your current zone and log back in for the change to take effect."; SiusLog.Log(SiusLog.INFORMATION, "?squadcreate", "Successfully created squad <" + squad + "> for " + name); return; } } }
public static void Try(string[] parameters) { //CHAT:pid:channel:sound:text string sender = ""; // the name of the sender string channel = ""; // the name of the chat channel Player.PlayerStruct p = Player.GetPlayer(parameters[1]); // Check if the player is sending to a valid channel if (p.Chat != null) { sender = p.name; int num; try { num = Convert.ToInt32(parameters[2]); } catch { num = 0; } if (num < p.Chat.Length) { channel = p.Chat[num]; } else { return; } } if (string.IsNullOrEmpty(channel) || string.IsNullOrEmpty(sender)) { return; } // Send the message to every player on that chat for (int i = 0; i < Player.PlayerList.Count; i++) { Player.PlayerStruct pp = (Player.PlayerStruct)Player.PlayerList[i]; if (SiusUtil.StringInArray(channel, pp.Chat) && pp.name != sender) { try { TcpClient tcpZone = (TcpClient)Listen.htRcon[pp.ZoneName]; StreamWriter swSenderSender; swSenderSender = new StreamWriter(tcpZone.GetStream()); //CHATTXT:channel:sender:sound:text //CHAT:pid:number swSenderSender.WriteLine("CHATTXT:" + channel + ":" + sender + ":" + parameters[3] + ":" + SiusUtil.Collate(4, parameters)); if (pp.ZoneSW == "asss 1.4.3" || pp.ZoneSW == "asss 1.4.2") // Older versions are broken. { swSenderSender.WriteLine("CHAT:" + pp.pid + ":" + Array.IndexOf(pp.Chat, channel).ToString() + ":"); } else { swSenderSender.WriteLine("CHAT:" + pp.pid + ":" + Array.IndexOf(pp.Chat, channel).ToString()); } swSenderSender.Flush(); swSenderSender = null; } catch (Exception e) { SiusLog.Log(SiusLog.DEBUG, "chat", e.Message); } } } SiusLog.Log(SiusLog.INFORMATION, "chat", sender + " to " + channel + ": " + SiusUtil.Collate(4, parameters)); return; }
public static void Try(string[] parameters) { //CMD:pid:cmdname:name:text if (string.IsNullOrEmpty(parameters[3])) { Player.PlayerStruct p = Player.GetPlayer(parameters[1]); /* Begin Database Connection */ DataTable dt = new DataTable(); SQLiteConnection SConnection = new SQLiteConnection(); SConnection.ConnectionString = SQLite.ConnectionString; SConnection.Open(); SQLiteCommand cmd = new SQLiteCommand(SConnection); cmd.CommandText = @"UPDATE 'messages' SET flag = 1 WHERE name = @pname;" + "SELECT * FROM 'messages' WHERE name = @pname"; SQLiteParameter pname = new SQLiteParameter("@pname"); cmd.Parameters.Add(pname); pname.Value = p.name; SQLiteDataReader Reader = cmd.ExecuteReader(); dt.Load(Reader); Reader.Close(); SConnection.Close(); /* End Database Connection */ // The player has no new messages if (dt.Rows.Count == 0) { Message.Send = "MSG:" + parameters[1] + ":0:You have no new messages."; SiusLog.Log(SiusLog.DEBUG, "?messages", "[" + p.name + "] has no new messages."); return; } TcpClient tcpZone = (TcpClient)p.tcpZone; StreamWriter swSenderSender; swSenderSender = new StreamWriter(tcpZone.GetStream()); for (int a = 0; a < dt.Rows.Count; a++) { string time = dt.Rows[a][3].ToString(); string sender = dt.Rows[a][1].ToString(); string message = dt.Rows[a][2].ToString(); swSenderSender.WriteLine("MSG:" + parameters[1] + ":0:" + "[" + time + "] " + sender + ": " + message); } swSenderSender.Flush(); swSenderSender = null; SiusLog.Log(SiusLog.INFORMATION, "?messages", "Sent [" + p.name + "] their messages."); return; } else { if (parameters.Length < 5) { return; } string receiver = parameters[3]; string message = SiusUtil.Collate(4, parameters); string name = Player.GetPlayerName(parameters[1]); /*SQLite.SendQuery("INSERT INTO 'messages' (name,sender,message,time) " + * "VALUES ('" + receiver + "','" + * name + "','" + message + "','" + * System.DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + "');"); * * SiusLog.Log(SiusLog.DEBUG, "messages", "[" + name + "] sent [" + receiver + * "] the following message: " + message);*/ /* Begin Database Connection */ DataTable dt = new DataTable(); SQLiteConnection SConnection = new SQLiteConnection(); SConnection.ConnectionString = SQLite.ConnectionString; SQLiteCommand cmd = new SQLiteCommand(SConnection); SQLiteParameter apname = new SQLiteParameter("@pname"); cmd.Parameters.Add(apname); apname.Value = name; //Check maximum number of messages sent if (!string.IsNullOrEmpty(SiusConf.GetSetting.String("maxsent"))) { SConnection.Open(); cmd.CommandText = @"SELECT * FROM messages WHERE name = @pname"; SQLiteDataReader Reader = cmd.ExecuteReader(); dt.Load(Reader); Reader.Close(); SConnection.Close(); int rows = 0; for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i][4].ToString() == "0") { rows++; } } if (rows >= SiusConf.GetSetting.Integer("maxsent")) { Message.Send = "MSG:" + parameters[1] + ":0:Error: Too many messages have been sent out." + " Please wait a while before trying again"; SConnection.Dispose(); SiusLog.Log(SiusLog.INFORMATION, "?message", "Unable to send <" + receiver + "> " + name + "'s message (too many pending messages sent)."); return; } dt.Clear(); } //Check maximum number of messages received if (!string.IsNullOrEmpty(SiusConf.GetSetting.String("maxinbox"))) { SConnection.Open(); cmd.CommandText = @"SELECT * FROM messages WHERE sender = @pname"; SQLiteDataReader Reader = cmd.ExecuteReader(); dt.Load(Reader); Reader.Close(); SConnection.Close(); int rows = 0; for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i][4].ToString() == "0") { rows++; } } if (rows >= SiusConf.GetSetting.Integer("maxinbox")) { Message.Send = "MSG:" + parameters[1] + ":0:Error: This player's message inbox is full." + " Please try again at another time."; SConnection.Dispose(); SiusLog.Log(SiusLog.DEBUG, "?message", "Unable to send <" + receiver + "> " + name + "'s message (inbox full)."); return; } dt.Clear(); } //Send the message SConnection.Open(); cmd.CommandText = @"INSERT INTO 'messages' (name,sender,message,time) " + "VALUES (@receiver,@pname,@message,@utc);"; SQLiteParameter areceiver = new SQLiteParameter("@receiver"); SQLiteParameter amessage = new SQLiteParameter("@message"); SQLiteParameter autc = new SQLiteParameter("@utc"); cmd.Parameters.Add(areceiver); cmd.Parameters.Add(amessage); cmd.Parameters.Add(autc); areceiver.Value = receiver; amessage.Value = message; autc.Value = System.DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"); cmd.ExecuteNonQuery(); SConnection.Close(); SConnection.Dispose(); /* End Database Connection */ Message.Send = "MSG:" + parameters[1] + ":0:Message has been sent to " + receiver; SiusLog.Log(SiusLog.INFORMATION, "?message", name + " sent " + receiver + " a message."); SiusLog.Log(SiusLog.DEBUG, "?message", "Message: " + message); } }
public static void Try(string[] parameters) { if (!string.IsNullOrEmpty(parameters[3])) { string squad = parameters[3]; string password = SiusUtil.Collate(4, parameters); /* Begin Database Connection */ DataTable dt = new DataTable(); SQLiteConnection SConnection = new SQLiteConnection(); SConnection.ConnectionString = SQLite.ConnectionString; SConnection.Open(); SQLiteCommand cmd = new SQLiteCommand(SConnection); cmd.CommandText = @"SELECT * FROM squads WHERE name = @nsquad"; SQLiteParameter nsquad = new SQLiteParameter("@nsquad"); cmd.Parameters.Add(nsquad); nsquad.Value = squad; SQLiteDataReader Reader = cmd.ExecuteReader(); dt.Load(Reader); Reader.Close(); SConnection.Close(); /* End Database Connection */ //The squad exists if (dt.Rows.Count > 0) { //Check if the password is correct if (SiusEncrypt.Encrypt(password, squad, "squads") == dt.Rows[0][1].ToString()) { SConnection.Open(); cmd.CommandText = @"UPDATE players SET squad = @nsquad WHERE name = @pname"; SQLiteParameter pname = new SQLiteParameter("@pname"); cmd.Parameters.Add(pname); pname.Value = Player.GetPlayerName(parameters[1]); cmd.ExecuteNonQuery(); SConnection.Close(); SConnection.Dispose(); Message.Send = "MSG:" + parameters[1] + ":0:Your squad has been successfully changed." + " Please log back in for the change to take effect."; SiusLog.Log(SiusLog.INFORMATION, "?squadjoin", Player.GetPlayerName(parameters[1]) + " successfully joined squad <" + squad + ">."); return; } else { Message.Send = "MSG:" + parameters[1] + ":0:Invalid password for the specified squad."; SiusLog.Log(SiusLog.DEBUG, "?squadjoin", Player.GetPlayerName(parameters[1]) + " was unable to join squad <" + squad + "> (invalid password)."); } } else { Message.Send = "MSG:" + parameters[1] + ":0:This squad does not exist."; SiusLog.Log(SiusLog.DEBUG, "?squadjoin", Player.GetPlayerName(parameters[1]) + " was unable to join squad <" + squad + "> (squad does not exist)."); } } }
/// <summary> /// Handle logs sent from the zone. /// </summary> public static void Try(string[] parameters) { //TODO: Send this log to all online operators SiusLog.Log(SiusLog.WARNING, "zone", "(" + Zone.ZoneName + ") " + SiusUtil.Collate(1, parameters)); }