Teleport handler now handles wormhole potions.
Added a permission to use wormhole potions
This commit is contained in:
parent
e044dfaf52
commit
9d55122da8
2 changed files with 38 additions and 17 deletions
|
|
@ -3564,40 +3564,58 @@ namespace TShockAPI
|
|||
|
||||
private static bool HandleTeleport(GetDataHandlerArgs args)
|
||||
{
|
||||
var flag = (BitsByte)args.Data.ReadInt8();
|
||||
var id = args.Data.ReadInt16();
|
||||
BitsByte flag = (BitsByte)args.Data.ReadByte();
|
||||
short id = args.Data.ReadInt16();
|
||||
var x = args.Data.ReadSingle();
|
||||
var y = args.Data.ReadSingle();
|
||||
|
||||
if (OnTeleport(id, flag, x, y))
|
||||
return true;
|
||||
|
||||
int type = 0;
|
||||
byte style = 0;
|
||||
var isNPC = false || (flag & 1) == 1;
|
||||
bool isNPC = type == 1;
|
||||
|
||||
if ((flag & 2) != 2)
|
||||
if (flag[0])
|
||||
{
|
||||
if ((flag & 4) == 4)
|
||||
{
|
||||
style++;
|
||||
}
|
||||
type = 1;
|
||||
}
|
||||
if (flag[1])
|
||||
{
|
||||
type = 2;
|
||||
}
|
||||
if (flag[2])
|
||||
{
|
||||
style++;
|
||||
}
|
||||
if (flag[3])
|
||||
{
|
||||
style += 2;
|
||||
}
|
||||
|
||||
if ((flag & 8) == 8)
|
||||
{
|
||||
style++;
|
||||
}
|
||||
//Rod of Discord teleport (usually (may be used by modded clients to teleport))
|
||||
if (type == 0 && !args.Player.Group.HasPermission(Permissions.rod))
|
||||
{
|
||||
args.Player.SendErrorMessage("You do not have permission to teleport.");
|
||||
args.Player.Teleport(args.TPlayer.position.X, args.TPlayer.position.Y);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (id > (isNPC ? 200 : 255))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//NPC teleport
|
||||
if (type == 1 && id >= Main.maxNPCs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//Player to player teleport (wormhole potion, usually (may be used by modded clients to teleport))
|
||||
if (type == 2)
|
||||
{
|
||||
if (id >= Main.maxPlayers || Main.player[id] == null || TShock.Players[id] == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isNPC && !args.Player.Group.HasPermission(Permissions.rod))
|
||||
if (!args.Player.Group.HasPermission(Permissions.wormhole))
|
||||
{
|
||||
args.Player.SendErrorMessage("You do not have permission to teleport.");
|
||||
args.Player.Teleport(args.TPlayer.position.X, args.TPlayer.position.Y);
|
||||
|
|
|
|||
|
|
@ -252,6 +252,9 @@ namespace TShockAPI
|
|||
[Description("User can use the Rod of Discor.")]
|
||||
public static readonly string rod = "tshock.tp.rod";
|
||||
|
||||
[Description("User can use wormhole potions.")]
|
||||
public static readonly string wormhole = "tshock.tp.wormhole";
|
||||
|
||||
// tshock.world nodes
|
||||
|
||||
[Description("User can change expert state.")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue