Hello servuo, is there an easy way to check wich direction player is facing?

i need a snipe like
C#:
if m.Player.Direction == South

i took a look at playermobile but it seems kinda complex to me

thanks
 
Not sure what you need it for but this is how I checked direction for the flying system

Code:
//Simple not using anything

namespace Server.Flying
{
    public static class FlyingDirection
    {
        public static int GetDirection(string direction, out int getY)
        {
            if (direction == "Mask" || direction == "ValueMask")
            {
                getY = -1;
                return -1;
            }
            else if (direction == "Down" || direction == "131")
            {
                getY = 1;
                return 1;
            }
            else if (direction == "Left" || direction == "133")
            {
                getY = 1;
                return -1;
            }
            else if (direction == "Right" || direction == "129")
            {
                getY = -1;
                return 1;
            }
            else if (direction == "North" || direction == "Running")
            {
                getY = -1;
                return 0;
            }
            else if (direction == "South" || direction == "132")
            {
                getY = 1;
                return 0;
            }
            else if (direction == "East" || direction == "130")
            {
                getY = 0;
                return 1;
            }
            else if (direction == "West" || direction == "134")
            {
                getY = 0;
                return -1;
            }
            else
            {
                getY = 0;
                return 0;
            }
        }

        public static Direction ChangeDirection(string direction)
        {
            if (direction == "Mask" || direction == "ValueMask")
            {
                return Direction.Down;
            }
            else if (direction == "Down" || direction == "131")
            {
                return Direction.Mask;
            }
            else if (direction == "Left" || direction == "133")
            {
                return Direction.Right;
            }
            else if (direction == "Right" || direction == "129")
            {
                return Direction.Left;
            }
            else if (direction == "North" || direction == "Running")
            {
                return Direction.South;
            }
            else if (direction == "South" || direction == "132")
            {
                return Direction.North;
            }
            else if (direction == "East" || direction == "130")
            {
                return Direction.West;
            }
            else if (direction == "West" || direction == "134")
            {
                return Direction.East;
            }
            else
            {
                return Direction.Mask;
            }
        }

        public static Direction ChangeAltitudeDown(string direction)
        {
            if (direction == $"{Direction.ValueMask}")
            {
                return Direction.Mask;
            }
            else if (direction == "131")
            {
                return Direction.Down;
            }
            else if (direction == "133")
            {
                return Direction.Left;
            }
            else if (direction == "129")
            {
                return Direction.Right;
            }
            else if (direction == $"{Direction.Running}")
            {
                return Direction.North;
            }
            else if (direction == "132")
            {
                return Direction.South;
            }
            else if (direction == "130")
            {
                return Direction.East;
            }
            else if (direction == "134")
            {
                return Direction.West;
            }
            else
            {
                return Direction.Mask;
            }
        }
    }
}
 
I mean there is this in Mobile.cs .. so :D

C#:
        [CommandProperty(AccessLevel.Decorator)]
        public Direction Direction
        {
            get { return m_Direction; }
            set
            {
                if (m_Direction != value)
                {
                    m_Direction = value;

                    Delta(MobileDelta.Direction);
                    //ProcessDelta();
                }
            }
        }
 
Not sure what you need it for but this is how I checked direction for the flying system

Code:
//Simple not using anything

namespace Server.Flying
{
    public static class FlyingDirection
    {
        public static int GetDirection(string direction, out int getY)
        {
            if (direction == "Mask" || direction == "ValueMask")
            {
                getY = -1;
                return -1;
            }
            else if (direction == "Down" || direction == "131")
            {
                getY = 1;
                return 1;
            }
            else if (direction == "Left" || direction == "133")
            {
                getY = 1;
                return -1;
            }
            else if (direction == "Right" || direction == "129")
            {
                getY = -1;
                return 1;
            }
            else if (direction == "North" || direction == "Running")
            {
                getY = -1;
                return 0;
            }
            else if (direction == "South" || direction == "132")
            {
                getY = 1;
                return 0;
            }
            else if (direction == "East" || direction == "130")
            {
                getY = 0;
                return 1;
            }
            else if (direction == "West" || direction == "134")
            {
                getY = 0;
                return -1;
            }
            else
            {
                getY = 0;
                return 0;
            }
        }

        public static Direction ChangeDirection(string direction)
        {
            if (direction == "Mask" || direction == "ValueMask")
            {
                return Direction.Down;
            }
            else if (direction == "Down" || direction == "131")
            {
                return Direction.Mask;
            }
            else if (direction == "Left" || direction == "133")
            {
                return Direction.Right;
            }
            else if (direction == "Right" || direction == "129")
            {
                return Direction.Left;
            }
            else if (direction == "North" || direction == "Running")
            {
                return Direction.South;
            }
            else if (direction == "South" || direction == "132")
            {
                return Direction.North;
            }
            else if (direction == "East" || direction == "130")
            {
                return Direction.West;
            }
            else if (direction == "West" || direction == "134")
            {
                return Direction.East;
            }
            else
            {
                return Direction.Mask;
            }
        }

        public static Direction ChangeAltitudeDown(string direction)
        {
            if (direction == $"{Direction.ValueMask}")
            {
                return Direction.Mask;
            }
            else if (direction == "131")
            {
                return Direction.Down;
            }
            else if (direction == "133")
            {
                return Direction.Left;
            }
            else if (direction == "129")
            {
                return Direction.Right;
            }
            else if (direction == $"{Direction.Running}")
            {
                return Direction.North;
            }
            else if (direction == "132")
            {
                return Direction.South;
            }
            else if (direction == "130")
            {
                return Direction.East;
            }
            else if (direction == "134")
            {
                return Direction.West;
            }
            else
            {
                return Direction.Mask;
            }
        }
    }
}


what im trying is to check if player is facing East direction like below;
it throws errors ;D
C#:
[CODE=csharp]if (DateTime.UtcNow - m.LastMoveTime <= m.ComputeMovementSpeed(m.Direction) && m.Direction == m.Direction.East && c.IsChildOf(m.Backpack) && pm.Hidden == false)

CS0176: Line 641: Member 'Server.Direction.East' cannot be accessed with an
instance reference; qualify it with a type name instead
 
Last edited:
The error tells you that m.Direction.East is not an instance variable
since you want to compare the actual instance variable m.Direction to the enum Direction

Therefor it is just m.Direction == Direction.East
 
Back