- Timestamp:
- Sep 12, 2014, 11:14:11 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/CustomCommands/TeleportPlayer.cs
r174 r189 2 2 using System; 3 3 using System.Collections.Generic; 4 using UnityEngine; 4 5 5 6 namespace AllocsFixes.CustomCommands … … 24 25 { 25 26 try { 26 if (_params.Length != 4 ) {27 if (_params.Length != 4 && _params.Length != 2) { 27 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>"); 28 30 } else { 29 string steamid = PersistentContainer.Instance.Players.GetSteamID(_params [0], true);30 if ( steamid== null) {31 Player p1 = PersistentContainer.Instance.Players.GetPlayerByNameOrId (_params [0], true); 32 if (p1 == null) { 31 33 m_Console.SendResult ("Playername or entity/steamid id not found."); 32 34 return; 33 35 } 34 35 Player p = PersistentContainer.Instance.Players [steamid]; 36 if (!p.IsOnline) { 36 if (!p1.IsOnline) { 37 37 m_Console.SendResult ("Player not online."); 38 38 return; 39 39 } 40 40 41 int x = int.MinValue; 42 int.TryParse (_params [1], out x); 43 int y = int.MinValue; 44 int.TryParse (_params [2], out y); 45 int z = int.MinValue; 46 int.TryParse (_params [3], out z); 41 if (_params.Length == 4) { 42 int x = int.MinValue; 43 int y = int.MinValue; 44 int z = int.MinValue; 47 45 48 if (x == int.MinValue || y == int.MinValue || z == int.MinValue) { 49 m_Console.SendResult ("At least one of the given coordinates is not a valid integer"); 50 return; 46 int.TryParse (_params [1], out x); 47 int.TryParse (_params [2], out y); 48 int.TryParse (_params [3], out z); 49 50 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"); 52 return; 53 } 54 55 p1.Entity.position.x = x; 56 p1.Entity.position.y = y; 57 p1.Entity.position.z = z; 58 } 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."); 62 return; 63 } 64 if (!p2.IsOnline) { 65 m_Console.SendResult ("Target player not online."); 66 return; 67 } 68 69 p1.Entity.position = p2.Entity.GetPosition(); 51 70 } 52 71 53 p.Entity.position.x = x; 54 p.Entity.position.y = y; 55 p.Entity.position.z = z; 56 NetPackage_EntityPosAndRot pkg = new NetPackage_EntityPosAndRot (p.Entity); 72 NetPackage_EntityPosAndRot pkg = new NetPackage_EntityPosAndRot (p1.Entity); 57 73 58 p .ClientInfo.netConnection [0].Send (pkg);74 p1.ClientInfo.netConnection [0].Send (pkg); 59 75 } 60 76 } catch (Exception e) {
Note:
See TracChangeset
for help on using the changeset viewer.