/punch (actual)

/punch (actual)

Postby Ultima » 29 Jul 2013, 17:53

This punch actually punches the player, like slap but sideways.
Am using it on my own servers for a while now.

Code: Select all
using System;

namespace MCDzienny
{
    public class CmdPunch : Command
    {
        public override string name { get { return "punch"; } }
        public override string shortcut { get { return ""; } }
        public override string type { get { return "other"; } }
        public override bool museumUsable { get { return true; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
       
        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, "Cannot punch someone of greater rank"); return; }


            if (who == null)
            {
                Player.SendMessage(p, "Could not find player specified");
                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 <= 1000; xx++)
            {
                if (!Block.Walkthrough(p.level.GetTile(currentY, xx, currentZ)) && p.level.GetTile(currentY, xx, currentZ) != Block.Zero)
                {
                    foundDirection = (ushort)(xx - 1);
                    who.level.ChatLevel(who.color + who.name + Server.DefaultColor + " was punched into the wall by " + p.color + p.name);
                    break;
                }
            }

            if (foundDirection == 0)
            {
                who.level.ChatLevel(who.color + who.name + Server.DefaultColor + " was punched across the map by " + p.color + p.name);
                foundDirection = 1000;
            }
           
            unchecked { who.SendPos((byte)-1, (ushort)(foundDirection * 32), who.pos[1], who.pos[2], who.rot[1], who.rot[1]); }
        }
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/punch <name> - Punches <name>, knocking them into the wall.");
        }
    }
}
User avatar
Ultima
 
Posts: 953
Joined: 19 Aug 2011, 23:45

Re: /punch (actual)

Postby Leeizazombie » 29 Jul 2013, 17:59

Very nice!
Owner of:
LeeIzaZombie Freebuild and Lava Survival V2 (Shut Down and updated)
LeeIzaZombie Survival (Comming back soon)

Contact:
Skype: leeizazombie
IRC: irc.geekshed.net, #leeizazombie, #mcclassichosting
User avatar
Leeizazombie
 
Posts: 536
Joined: 10 Jun 2013, 17:45
Location: Ireland.

Re: /punch (actual)

Postby Clowny » 29 Jul 2013, 18:22

Genius.. nice.. I will definitely be using this as a command and as an example for future commands! <ok> <ok>
Founder Of MC Classic Hosting Community http://mcclassichosting.webs.com
Founder of MC Classic Software MCReborn http://mcreborn.tk
Professional Hoster and Basic C# Coder
Image
User avatar
Clowny
 
Posts: 112
Joined: 14 Jul 2013, 03:53

Re: /punch (actual)

Postby ane200055 » 30 Jul 2013, 21:04

Not bad, however when I made something like this I was not copying it was something I was working on for ages.
Sorry if it looked like I copied the code but it was just something I was working on and as there is no other way to do it ended looking the same.

Anyway... this command looks like fun to play with it could be useful to get people out the way of stuff, nice job <ok>
Website: http://ane200055.co.vu
The Developer of The XtraIRC IRC Client: http://xtrairc.tk
C# coder.
User avatar
ane200055
 
Posts: 98
Joined: 30 Jun 2013, 09:07
Location: United Kingdom

Re: /punch (actual)

Postby Conor » 30 Jul 2013, 21:52

ane200055 wrote:Not bad, however when I made something like this I was not copying it was something I was working on for ages.
Sorry if it looked like I copied the code but it was just something I was working on and as there is no other way to do it ended looking the same.

Anyway... this command looks like fun to play with it could be useful to get people out the way of stuff, nice job <ok>


Lying about plagiarism will just dig you a deeper hole.

"A man must be big enough to admit his mistakes, smart enough to profit from them, and strong enough to correct them." ;)

You can use other people's code from command submissions, just credit them.
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Re: /punch (actual)

Postby lucasds12 » 02 Aug 2013, 07:42

We got our self a current code genius :D, anyways, very nice command and yes, I knew you definitely were going to post this command. Such a complicated command, but yet so simple to use.
-Lucas
There is only one thing I do in life, that's contributing here.
lucasds12
 
Posts: 334
Joined: 17 Apr 2013, 16:17
Location: In the deep caves.


Return to Custom Commands

Who is online

Users browsing this forum: No registered users and 5 guests

cron