It works but not how I was hoping.
If you know how I can fix this a bit please tell me but here it is for now.
-------
/sideslap PlayerName
Shortcut: /sslap
Spoiler:
- Code: Select all
//Made by ane200055
//Version: v0.1
using System;
namespace MCDzienny
{
public class CmdSideslap : Command
{
public override string name { get { return "sideslap"; } }
public override string shortcut { get { return "sslap"; } }
public override string type { get { return "other"; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public override void Use(Player p, string message)
{
if (message == "") { Help(p); return; }
Player who = Player.Find(message);
if (p != null && who.group.Permission > p.group.Permission) { Player.SendMessage(p, "You can't use this command on someone a higher rank then you."); return; }
if (who == null)
{
Player.SendMessage(p, "Couldn't find player.");
return;
}
ushort currentX = (ushort)(who.pos[0] / 32);
ushort currentY = (ushort)(who.pos[1] / 32);
ushort currentZ = (ushort)(who.pos[2] / 32);
ushort foundDirection = 0;
for (ushort xx = currentX; xx < who.level.width; xx++)
{
if (!Block.Walkthrough(p.level.GetTile(xx, currentY, currentZ)) && p.level.GetTile(xx, currentY, currentZ) != Block.Zero);
{
foundDirection = (ushort)(xx - 1);
who.level.ChatLevel(who.color + who.name + Server.DefaultColor + " was slapped sideways by " + p.color + p.name);
break;
}
}
if (foundDirection == 0)
{
who.level.ChatLevel(who.color + who.name + Server.DefaultColor + " was slapped into the side of map by " + p.color + p.name);
foundDirection = 1000;
}
unchecked { who.SendPos((byte)-1, (ushort)(foundDirection * 32), who.pos[1], who.pos[2], who.rot[0], who.rot[1]); }
}
public override void Help(Player p)
{
Player.SendMessage(p, "/sideslap %bPlayerName %eslaps a player sideways.");
Player.SendMessage(p, "This also works by doing /sslap %bPlayerName%e.");
}
}
}