- Timestamp:
- Apr 18, 2015, 4:27:57 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/AllocsCommands/Commands/TeleportPlayer.cs
r228 r230 1 using AllocsFixes.PersistentData;2 1 using System; 3 2 using System.Collections.Generic; … … 6 5 namespace AllocsFixes.CustomCommands 7 6 { 8 public class TeleportPlayer : ConsoleC ommand7 public class TeleportPlayer : ConsoleCmdAbstract 9 8 { 10 public TeleportPlayer (ConsoleSdtd cons) : base(cons) 11 { 12 } 13 14 public override string Description () 9 public override string GetDescription () 15 10 { 16 11 return "teleport a player to a given location"; 17 12 } 18 13 19 public override string[] Names ()14 public override string[] GetCommands () 20 15 { 21 16 return new string[] { "teleportplayer", "tele" }; 22 17 } 23 18 24 public override void Run (string[] _params)19 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 25 20 { 26 21 try { 27 if (_params. Length != 4 && _params.Length!= 2) {28 m_Console.SendResult ("Usage: teleportplayer <entityid|playername|steamid> <x> <y> <z>");29 m_Console.SendResult (" or: teleportplayer <entityid|playername|steamid> <target entityid|playername|steamid>");22 if (_params.Count != 4 && _params.Count != 2) { 23 SdtdConsole.Instance.Output ("Usage: teleportplayer <entityid|playername|steamid> <x> <y> <z>"); 24 SdtdConsole.Instance.Output (" or: teleportplayer <entityid|playername|steamid> <target entityid|playername|steamid>"); 30 25 } else { 31 Player p1 = PersistentContainer.Instance.Players.GetPlayerByNameOrId (_params [0], true);32 if ( p1 == null) {33 m_Console.SendResult ("Playername or entity/steamid id not found.");26 ClientInfo ci1 = ConsoleHelper.ParseParamIdOrName (_params [0]); 27 if (ci1 == null) { 28 SdtdConsole.Instance.Output ("Playername or entity/steamid id not found."); 34 29 return; 35 30 } 36 if (!p1.IsOnline) { 37 m_Console.SendResult ("Player not online."); 38 return; 39 } 31 EntityPlayer ep1 = GameManager.Instance.World.Players.dict [ci1.entityId]; 40 32 41 if (_params. Length== 4) {33 if (_params.Count == 4) { 42 34 int x = int.MinValue; 43 35 int y = int.MinValue; … … 49 41 50 42 if (x == int.MinValue || y == int.MinValue || z == int.MinValue) { 51 m_Console.SendResult ("At least one of the given coordinates is not a valid integer");43 SdtdConsole.Instance.Output ("At least one of the given coordinates is not a valid integer"); 52 44 return; 53 45 } 54 46 55 p1.Entity.position.x = x;56 p1.Entity.position.y = y;57 p1.Entity.position.z = z;47 ep1.position.x = x; 48 ep1.position.y = y; 49 ep1.position.z = z; 58 50 } else { 59 Player p2 = PersistentContainer.Instance.Players.GetPlayerByNameOrId (_params [1], true);60 if ( p2 == null) {61 m_Console.SendResult ("Target playername or entity/steamid id not found.");51 ClientInfo ci2 = ConsoleHelper.ParseParamIdOrName (_params [1]); 52 if (ci2 == null) { 53 SdtdConsole.Instance.Output ("Target playername or entity/steamid id not found."); 62 54 return; 63 55 } 64 if (!p2.IsOnline) { 65 m_Console.SendResult ("Target player not online."); 66 return; 67 } 56 EntityPlayer ep2 = GameManager.Instance.World.Players.dict [ci2.entityId]; 68 57 69 p1.Entity.position = p2.Entity.GetPosition();70 p1.Entity.position.y += 1;71 p1.Entity.position.z += 1;58 ep1.position = ep2.GetPosition(); 59 ep1.position.y += 1; 60 ep1.position.z += 1; 72 61 } 73 62 74 NetPackage_EntityTeleport pkg = new NetPackage_EntityTeleport ( p1.Entity);63 NetPackage_EntityTeleport pkg = new NetPackage_EntityTeleport (ep1); 75 64 76 ConnectionManager.Instance.SendPackage (pkg, new PackageDestinationSingleEntityID (p1.ClientInfo.entityId));65 ci1.netConnection [0].AddToSendQueue (pkg); 77 66 } 78 67 } catch (Exception e) {
Note:
See TracChangeset
for help on using the changeset viewer.