source: binary-improvements/CoppisAdditions/src/Commands/TeleportPlayerHome.cs@ 296

Last change on this file since 296 was 273, checked in by alloc, 9 years ago

fixes 8_10_13_1

File size: 1.7 KB
RevLine 
[273]1using System;
2using System.Collections.Generic;
3using System.Reflection;
4
5namespace CoppisAdditions.CustomCommands
6{
7 public class TeleportPlayerHome : ConsoleCmdAbstract
8 {
9 public override string GetDescription ()
10 {
11 return "teleport a player to his home (on bedroll)";
12 }
13
14 public override string GetHelp ()
15 {
16 return "Usage:\n" +
17 " teleportplayerhome <steam id / player name / entity id>";
18 }
19
20 public override string[] GetCommands ()
21 {
22 return new string[] { "teleportplayerhome", "teleh" };
23 }
24
25 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo)
26 {
27 try {
28 if (_params.Count != 1) {
29 SdtdConsole.Instance.Output ("Usage: teleportplayerhome <entityid|playername|steamid>");
30 } else {
31 ClientInfo ci1 = ConsoleHelper.ParseParamIdOrName (_params [0]);
32 if (ci1 == null) {
33 SdtdConsole.Instance.Output ("Playername or entity/steamid id not found.");
34 return;
35 }
36 EntityPlayer ep1 = GameManager.Instance.World.Players.dict [ci1.entityId];
37 EntityBedrollPositionList bed = ep1.SpawnPoints;
38 if (bed.Count != 0) {
39 Vector3i pos = bed [0];
40 ep1.position.x = pos.x;
41 ep1.position.y = pos.y + 1;
42 ep1.position.z = pos.z;
43
44 NetPackageEntityTeleport pkg = new NetPackageEntityTeleport (ep1);
45 ci1.SendPackage (pkg);
46 SdtdConsole.Instance.Output ("Player teleported to his home at " + ep1.position.x + " " + ep1.position.y + " " + ep1.position.z);
47 } else {
48 SdtdConsole.Instance.Output ("The player does not have a defined HOME bed!");
49 }
50 }
51 } catch (Exception e) {
52 Log.Out ("Error in TeleportPlayerHome.Run: " + e);
53 }
54 }
55 }
56}
Note: See TracBrowser for help on using the repository browser.