/// <summary> /// Set the attitude and faction of an object with respect to this solar /// </summary> public static void SendSetReputation(Player player, Object.Solar.Solar solar) { float attitude = 0; if (solar.Faction.FactionID != 0xFFFFFFFF) { attitude = player.Ship.GetAttitudeTowardsFaction(solar.Faction); } player.Log.AddLog(LogType.FL_MSG, "tx FLPACKET_SERVER_SETREPUTATION solar.objid={0} faction={1} attitude={2}", solar.Objid, solar.Faction.FactionID, attitude); byte[] omsg = { 0x29, 0x02, 0x01 }; FLMsgType.AddUInt32(ref omsg, solar.Objid); FLMsgType.AddUInt32(ref omsg, solar.Faction.FactionID); FLMsgType.AddFloat(ref omsg, attitude); player.SendMsgToClient(omsg); }
/// <summary> /// Process an admin command. /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="chat"></param> /// <returns>Returns true if the command was processed and further processing should be stopped</returns> public static bool ProcessAdminCommands(Player.Player from, uint to, string chat) { // If this is an admin command and the player has admin permissions // then dispatch if (chat[0] == '.') { // Echo the chat back to the player. SendEcho(from, chat); string[] args = chat.Split(' '); // Figure out if the charname argument for the command is for // a partial, FL ID match or exact match. int searchMode = 2; if (args.Length > 0 && args[0].EndsWith("&")) { args[0] = args[0].Substring(0, args[0].Length - 1); searchMode = 1; } else if (args.Length > 0 && args[0].EndsWith("$")) { args[0] = args[0].Substring(0, args[0].Length - 1); searchMode = 0; } // Process the command. if (args.Length == 3 && args[0] == ".beam") { Player.Player player = FindActivePlayerByCharname(from.Runner, args[1], searchMode); if (player == null) { SendEcho(from, "ERR charname not found"); return(true); } string basename = args[2]; BaseData basedata = UniverseDB.FindBase(basename); if (basedata == null) { SendEcho(from, "ERR base not found"); return(true); } if (player.Ship.Basedata != null) { SendEcho(from, "ERR player not in space"); return(true); } player.Runner.AddEvent(new DPGRBeam(player, basedata)); SendEcho(from, "OK"); // fixme: need feedback. } else if (args.Length == 3 && args[0] == ".addcash") { Player.Player player = FindActivePlayerByCharname(from.Runner, args[1], searchMode); if (player == null) { SendEcho(from, "ERR charname not found"); return(true); } int money = 0; if (!Int32.TryParse(args[2], out money)) { SendEcho(from, "ERR invalid money"); return(true); } player.Runner.AddEvent(new DPGRAddCash(player, money)); SendEcho(from, "OK"); // fixme: SendChatToPlayer(from, "OK cash=" + player.money); } else if (args.Length == 3 && args[0] == ".setcash") { Player.Player player = FindActivePlayerByCharname(from.Runner, args[1], searchMode); if (player == null) { SendEcho(from, "ERR charname not found"); return(true); } int money = 0; if (!Int32.TryParse(args[2], out money)) { SendEcho(from, "ERR invalid money count"); return(true); } player.Runner.AddEvent(new DPGRSetCash(player, money)); SendEcho(from, "OK"); // fixme: SendChatToPlayer(from, "OK cash=" + player.money); } else if (args.Length == 3 && args[0] == ".setcash") { Player.Player player = FindActivePlayerByCharname(from.Runner, args[1], searchMode); if (player == null) { SendEcho(from, "ERR charname not found"); return(true); } int money = Int32.Parse(args[2]); player.Money += money; player.SendSetMoney(); SendEcho(from, "OK cash=" + player.Money); } else if (args.Length == 3 && args[0] == ".getrep") { Player.Player player = FindActivePlayerByCharname(from.Runner, args[1], searchMode); if (player == null) { SendEcho(from, "ERR charname not found"); return(true); } string factionname = args[2]; Faction faction = UniverseDB.FindFaction(factionname); if (faction == null) { SendEcho(from, "ERR not found faction=" + factionname); return(true); } float attitude = player.Ship.GetAttitudeTowardsFaction(faction); SendEcho(from, "OK faction=" + factionname + " rep=" + attitude); } else if (args.Length == 4 && args[0] == ".setrep") { Player.Player player = FindActivePlayerByCharname(from.Runner, args[1], searchMode); if (player == null) { SendEcho(from, "ERR charname not found"); return(true); } string factionname = args[2]; Faction faction = UniverseDB.FindFaction(factionname); if (faction == null) { SendEcho(from, "ERR not found faction=" + factionname); return(true); } float attitude = 0; if (!float.TryParse(args[3], out attitude)) { SendEcho(from, "ERR invalid rep=" + args[3]); return(true); } player.Ship.SetReputation(faction, attitude); SendEcho(from, "OK faction=" + faction.Nickname + " rep=" + player.Ship.GetAttitudeTowardsFaction(faction)); } else if (args.Length == 3 && args[0] == ".setrept") { var player = FindActivePlayerByCharname(from.Runner, args[1], searchMode); if (player == null) { SendEcho(from, "ERR charname not found"); return(true); } float attitude = 0; if (!float.TryParse(args[2], out attitude)) { SendEcho(from, "ERR invalid rep=" + args[3]); return(true); } Object.Solar.Solar solar = UniverseDB.FindSolar(player.Ship.TargetObjID); if (solar != null) { SendEcho(from, "OK solar=" + solar.Faction + " rep=" + attitude); player.Ship.SetReputation(solar.Faction, attitude); return(true); } SendEcho(from, "ERR only solar's supported cause I was lazy"); } else if (args.Length == 2 && args[0] == ".kill") { Player.Player player = FindActivePlayerByCharname(from.Runner, args[1], searchMode); if (player == null) { SendEcho(from, "ERR charname not found"); return(true); } if (player.Ship.Basedata != null) { SendEcho(from, "ERR player not in space"); return(true); } player.Ship.Destroy(DeathCause.Command); SendEcho(from, "OK"); } else if (args.Length == 4 && args[0] == ".move") { float x = 0; float y = 0; float z = 0; if (!float.TryParse(args[1], out x) || !float.TryParse(args[2], out y) || !float.TryParse(args[3], out z)) { SendEcho(from, String.Format("ERR invalid position={0:0} {1:0} {2:0}", x, y, z)); return(true); } var dummyAction = new LaunchInSpaceAction { Position = new Vector(x, y, z), Orientation = Quaternion.MatrixToQuaternion(@from.Ship.Orientation) }; from.Ship.CurrentAction = dummyAction; from.SendServerLaunch(); from.Ship.CurrentAction = null; SendEcho(from, String.Format("OK position={0:0} {1:0} {2:0}", x, y, z)); } else if (args.Length == 1 && args[0] == ".help") { from.SendInfocardUpdate(500000, "Admin Commands"); from.SendInfocardUpdate(500001, from.Runner.Server.AdminHelpMsg); from.SendPopupDialog(new FLFormatString(500000), new FLFormatString(500001), Player.Player.PopupDialogButtons.POPUPDIALOG_BUTTONS_CENTER_OK); } else { SendEcho(from, "ERR command invalid, type .help for valid commands"); } return(true); } return(false); }
/// <summary> /// FLPACKET_SERVER_SYSTEM_SWITCH_OUT /// </summary> /// <param name="player"></param> /// <param name="ship"></param> /// <param name="solar"></param> public static void SendSystemSwitchOut(Player player, Old.Object.Ship.Ship ship, Object.Solar.Solar solar) { player.Log.AddLog(LogType.FL_MSG, "tx FLPACKET_SERVER_SYSTEM_SWITCH_OUT objid={0} solar={1}", ship.Objid, solar.Objid); byte[] omsg = { 0x21, 0x02 }; FLMsgType.AddUInt32(ref omsg, ship.Objid); FLMsgType.AddUInt32(ref omsg, solar.Objid); player.SendMsgToClient(omsg); }