What does it do?
Allows you to teleport to coordinates and other players, while also letting you save and load your coordinates. This was created to just mess around and camp
Requirements:
Dedicated server addon V1.270+
Commands:
Teleporter.zip (Size: 2.71 KB / Downloads: 509)
Allows you to teleport to coordinates and other players, while also letting you save and load your coordinates. This was created to just mess around and camp
Requirements:
Dedicated server addon V1.270+
Commands:
Code:
!savepos - Save your current position
!loadpos - Load your old position
!setpos x y z - Set your player's position to the coordinates
!goto Name|ID - Set your player's position to another player's
Source code (Click to View)
Code:
using System;
using Addon;
namespace Teleporter
{
public class Class1 : CPlugin
{
struct OldOrigins
{
public float flX, flY, flZ;
};
OldOrigins[] pSaves;
float[] parsed;
public override void OnServerLoad()
{
ServerPrint("Teleporter plugin by Nukem loaded.");
pSaves = new OldOrigins[18];
parsed = new float[3];
}
public override ChatType OnSay(string Message, ServerClient Client)
{
if (Message.StartsWith("!savepos"))//!savepos - save current position
{
pSaves[Client.ClientNum].flX = Client.OriginX;
pSaves[Client.ClientNum].flY = Client.OriginY;
pSaves[Client.ClientNum].flZ = Client.OriginZ;
TellClient(Client.ClientNum, "[^1Teleporter^7]: Saved position at (" + pSaves[Client.ClientNum].flX + "," + pSaves[Client.ClientNum].flY + "," + pSaves[Client.ClientNum].flZ + ").", true);
return ChatType.ChatNone;
}
else if (Message.StartsWith("!loadpos"))//!loadpos - load old position
{
Client.OriginX = pSaves[Client.ClientNum].flX;
Client.OriginY = pSaves[Client.ClientNum].flY;
Client.OriginZ = pSaves[Client.ClientNum].flZ;
TellClient(Client.ClientNum, "[^1Teleporter^7]: Loaded position.", true);
return ChatType.ChatNone;
}
else if (Message.StartsWith("!setpos"))//!setpos x y z - set player's position to the coordinates
{
string[] tokens = Message.Split(' ');
if (tokens.Length < 4)
{
TellClient(Client.ClientNum, "[^1Teleporter^7]: Invalid amount of arguments.", true);
TellClient(Client.ClientNum, "[^1Teleporter^7]: Usage: !setpos x y z", true);
return ChatType.ChatNone;
}
for (int i = 0; i < parsed.Length; i++)
{
if (!float.TryParse(tokens[i + 1], out parsed[i]))
{
TellClient(Client.ClientNum, "[^1Teleporter^7]: An error occurred.", true);
return ChatType.ChatNone;
}
}
Client.OriginX = parsed[0];
Client.OriginY = parsed[1];
Client.OriginZ = parsed[2];
TellClient(Client.ClientNum, "[^1Teleporter^7]: Set position.", true);
return ChatType.ChatNone;
}
else if (Message.StartsWith("!goto"))//!goto <Name|ID> - set player's position to another player's
{
string[] tokens = Message.Split(' ');
if (tokens.Length < 2)
{
TellClient(Client.ClientNum, "[^1Teleporter^7]: Invalid amount of arguments.", true);
TellClient(Client.ClientNum, "[^1Teleporter^7]: Usage: !goto <Name|ID>", true);
return ChatType.ChatNone;
}
ServerClient ci = null;
int num = 0;
if (int.TryParse(tokens[1], out num))
ci = GetClient(num);
else
ci = GetClientByName(tokens[1]);
if (ci == null)
{
TellClient(Client.ClientNum, "[^1Teleporter^7]: An error occurred (Player not found).", true);
return ChatType.ChatNone;
}
Client.OriginX = ci.OriginX;
Client.OriginY = ci.OriginY;
Client.OriginZ = ci.OriginZ;
TellClient(Client.ClientNum, "[^1Teleporter^7]: Set position to " + tokens[1] + ".", true);
return ChatType.ChatNone;
}
return ChatType.ChatContinue;
}
public ServerClient GetClientByName(string name)
{
if (name == null)
return null;
ServerClient client = null;
for (int i = 0; i < 18; i++)
{
client = GetClient(i);
if (client == null)
continue;
if (client.Name.ToLower().Contains(name.ToLower()))
return client;
}
return null;
}
}
}
Teleporter.zip (Size: 2.71 KB / Downloads: 509)