- Timestamp:
- Aug 12, 2015, 6:10:28 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/AllocsCommands/Commands/TeleportPlayer.cs
r238 r250 5 5 namespace AllocsFixes.CustomCommands 6 6 { 7 public class TeleportPlayer : ConsoleCmdAbstract 8 { 9 public override string GetDescription () 10 { 7 public class TeleportPlayer : ConsoleCmdAbstract { 8 public override string GetDescription () { 11 9 return "teleport a player to a given location"; 12 10 } … … 14 12 public override string GetHelp () { 15 13 return "Usage:\n" + 16 " 1. teleportplayer <steam id / player name / entity id> <x> <y> <z>\n" + 17 " 2. teleportplayer <steam id / player name / entity id> <target steam id / player name / entity id>\n" + 18 "1. Teleports the player given by his SteamID, player name or entity id (as given by e.g. \"lpi\")\n" + 19 " to the specified location\n" + 20 "2. As 1, but destination given by another player which has to be online"; 14 " 1. teleportplayer <steam id / player name / entity id> <x> <y> <z>\n" + 15 " 2. teleportplayer <steam id / player name / entity id> <target steam id / player name / entity id>\n" + 16 " 3. teleportplayer <inc x> <inc y> <inc z>\n" + 17 "1. Teleports the player given by his SteamID, player name or entity id (as given by e.g. \"lpi\")\n" + 18 " to the specified location\n" + 19 "2. As 1, but destination given by another player which has to be online\n" + 20 "3. Teleport the local player to the position calculated by his current position and the given offsets"; 21 21 } 22 22 23 public override string[] GetCommands () 24 { 23 public override string[] GetCommands () { 25 24 return new string[] { "teleportplayer", "tele" }; 26 25 } 27 26 28 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 29 { 27 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 30 28 try { 31 if (_params.Count != 4 && _params.Count != 2) {32 SdtdConsole.Instance.Output (" Usage: teleportplayer <entityid|playername|steamid> <x> <y> <z>");33 SdtdConsole.Instance.Output (" or: teleportplayer <entityid|playername|steamid> <target entityid|playername|steamid>");29 if (_params.Count < 2 || _params.Count > 4) { 30 SdtdConsole.Instance.Output ("Wrong number of arguments, expected 2 to 4, found " + _params.Count + "."); 31 return; 34 32 } else { 35 ClientInfo ci1 = ConsoleHelper.ParseParamIdOrName (_params [0]); 36 if (ci1 == null) { 37 SdtdConsole.Instance.Output ("Playername or entity/steamid id not found."); 38 return; 39 } 40 EntityPlayer ep1 = GameManager.Instance.World.Players.dict [ci1.entityId]; 33 ClientInfo ci1 = null; 34 EntityPlayer ep1 = null; 35 36 if (_params.Count == 2 || _params.Count == 4) { 37 ci1 = ConsoleHelper.ParseParamIdOrName (_params [0]); 38 if (ci1 == null) { 39 SdtdConsole.Instance.Output ("Playername or entity/steamid id not found."); 40 return; 41 } 42 ep1 = GameManager.Instance.World.Players.dict [ci1.entityId]; 41 43 42 if (_params.Count == 4) { 44 if (_params.Count == 4) { 45 int x = int.MinValue; 46 int y = int.MinValue; 47 int z = int.MinValue; 48 49 int.TryParse (_params [1], out x); 50 int.TryParse (_params [2], out y); 51 int.TryParse (_params [3], out z); 52 53 if (x == int.MinValue || y == int.MinValue || z == int.MinValue) { 54 SdtdConsole.Instance.Output ("At least one of the given coordinates is not a valid integer"); 55 return; 56 } 57 58 ep1.position.x = x; 59 ep1.position.y = y; 60 ep1.position.z = z; 61 } else if (_params.Count == 2) { 62 ClientInfo ci2 = ConsoleHelper.ParseParamIdOrName (_params [1]); 63 if (ci2 == null) { 64 SdtdConsole.Instance.Output ("Target playername or entity/steamid id not found."); 65 return; 66 } 67 EntityPlayer ep2 = GameManager.Instance.World.Players.dict [ci2.entityId]; 68 69 ep1.position = ep2.GetPosition (); 70 ep1.position.y += 1; 71 ep1.position.z += 1; 72 } 73 } else if (_params.Count == 3) { 74 if (_senderInfo.RemoteClientInfo == null) { 75 SdtdConsole.Instance.Output ("This command can only be executed on the in-game console."); 76 return; 77 } 78 79 ci1 = _senderInfo.RemoteClientInfo; 80 ep1 = GameManager.Instance.World.Players.dict [ci1.entityId]; 81 43 82 int x = int.MinValue; 44 83 int y = int.MinValue; 45 84 int z = int.MinValue; 46 85 47 int.TryParse (_params [ 1], out x);48 int.TryParse (_params [ 2], out y);49 int.TryParse (_params [ 3], out z);86 int.TryParse (_params [0], out x); 87 int.TryParse (_params [1], out y); 88 int.TryParse (_params [2], out z); 50 89 51 90 if (x == int.MinValue || y == int.MinValue || z == int.MinValue) { … … 54 93 } 55 94 56 ep1.position.x = x; 57 ep1.position.y = y; 58 ep1.position.z = z; 59 } else { 60 ClientInfo ci2 = ConsoleHelper.ParseParamIdOrName (_params [1]); 61 if (ci2 == null) { 62 SdtdConsole.Instance.Output ("Target playername or entity/steamid id not found."); 63 return; 64 } 65 EntityPlayer ep2 = GameManager.Instance.World.Players.dict [ci2.entityId]; 66 67 ep1.position = ep2.GetPosition(); 68 ep1.position.y += 1; 69 ep1.position.z += 1; 95 ep1.position.x = ep1.position.x + x; 96 ep1.position.y = ep1.position.y + y; 97 ep1.position.z = ep1.position.z + z; 70 98 } 71 99
Note:
See TracChangeset
for help on using the changeset viewer.