Ejemplo n.º 1
0
        private static bool Learn_OnCommand(CommandEventArgs e)
        {
            if (e.Length == 0)
            {
                e.SendMessage("Usage: .learn <ID>");
                return(false);
            }
            int id = e.GetInt32(0);

            e.Target.LearnSpell(Convert.ToInt32(id));
            e.SendMessage("Character \"{0}\" has learned spell with ID = \"{1}\"", e.Target.Name, id);
            return(true);
        }
Ejemplo n.º 2
0
 private static bool Password_OnCommand(CommandEventArgs e)
 {
     if (e.Length == 1)
     {
         e.Player.Player.Password = e.GetString(0);
         e.SendMessage("Your new password is: {0}", e.GetString(0));
         e.SendMessage("Don't forget it!");
         return(true);
     }
     else
     {
         e.SendMessage("Usage : .password <NewPassword>");
         return(false);
     }
 }
Ejemplo n.º 3
0
 private static bool Resurrect_OnCommand(CommandEventArgs e)
 {
     if (e.Target is Corps)
     {
         e.SendMessage("select a npc or player");
         return(true);
     }
     else
     {
         e.Target.HitPoints = e.Target.BaseHitPoints;
         e.Target.HitPointsUpdate(e.Target);
         e.SendMessage("mobile {0} resurrected", e.Target.Name);
         return(true);
     }
 }
Ejemplo n.º 4
0
 private static bool cmdlist_OnCommand(CommandEventArgs e)
 {
     e.Player.SendMessage("Server commands list: ");
     foreach (DictionaryEntry entry in Server.Scripts.Commands.Commands.Entries)
     {
         if (entry.Key is String)
         {
             if (e.AccessLevel <= e.Player.Player.AccessLevel)
             {
                 e.SendMessage("." + (string)entry.Key);
             }
         }
     }
     e.SendMessage("End of commands list.");
     return(true);
 }
Ejemplo n.º 5
0
        private static bool Get_OnCommand(CommandEventArgs e)
        {
            if (e.Length >= 1)
            {
                for (int i = 0; i < e.Length; i++)
                {
                    if (e.Target is Character)
                    {
                        if (!Server.Scripts.Properties.CharacterProperties.HasProperty(e.GetString(i)))
                        {
                        }
                        else if ((Server.Scripts.Properties.CharacterProperties.GetAccessLevel(e.GetString(i))) > e.Player.Player.AccessLevel)
                        {
                            e.SendMessage("You dont have access to read this property.");
                            //return false;
                        }
                        else
                        {
                            string val = Server.Scripts.Properties.CharacterProperties.GetValue(e.Target, e.GetString(i));
                            e.Player.SendMessage(e.GetString(i) + " : " + val);
                        }
                    }

                    if (!Server.Scripts.Properties.MobileProperties.HasProperty(e.GetString(i)))
                    {
                        e.SendMessage("This property dont exist.");
                        //return false;
                    }
                    else if ((Server.Scripts.Properties.MobileProperties.GetAccessLevel(e.GetString(i))) > e.Player.Player.AccessLevel)
                    {
                        e.SendMessage("You dont have access to read this property.");
                        //return false;
                    }
                    else
                    {
                        string val = Server.Scripts.Properties.MobileProperties.GetValue(e.Target, e.GetString(i));
                        e.Player.SendMessage(e.GetString(i) + " : " + val);
                    }
                }
                return(true);
            }
            else
            {
                e.SendMessage("Format: Get <propertyName> [ <propertyName> ...]");
                return(false);
            }
        }
Ejemplo n.º 6
0
 private static bool Locations_OnCommand(CommandEventArgs e)
 {
     foreach (object obj in World.Locations.Keys)
     {
         Position pos = (Position)World.Locations[obj];
         e.SendMessage("Location: {0}, X: {1}, Y: {2}, Z: {3}, MapId: {4}", obj.ToString(), pos.X, pos.Y, pos.Z, pos.MapId);
     }
     return(true);
 }
Ejemplo n.º 7
0
 private static bool Cast_OnCommand(CommandEventArgs e)
 {
     if (e.Length == 1)
     {
         try
         {
             e.Player.FakeCast(e.GetInt32(0), e.Target);
             return(true);
         }
         catch (Exception)
         {
             e.SendMessage("Invalid spell id or spell needs in target!");
             return(false);
         }
     }
     else
     {
         e.SendMessage("Usage: .Cast <Spell Id>");
         return(false);
     }
 }
Ejemplo n.º 8
0
        private static bool Go_OnCommand(CommandEventArgs e)
        {
            Character m = e.Player as Character;

            if (e.Length == 4)
            {
                float x, y, z;
                int   MapId;
                try
                {
                    x     = Convert.ToSingle(e.GetString(0));
                    y     = Convert.ToSingle(e.GetString(1));
                    z     = Convert.ToSingle(e.GetString(2));
                    MapId = Convert.ToInt32(e.GetString(3));
                    m.Teleport(x, y, z, MapId);
                    return(true);
                }
                catch (Exception)
                {
                }
            }
            else if (e.Length == 1)
            {
                if (World.Locations.ContainsKey(e.GetString(0)))
                {
                    Position position = (Position)World.Locations[e.GetString(0)];
                    m.Teleport(position.X, position.Y, position.Z, position.MapId);
                    return(true);
                }
                else
                {
                    e.SendMessage("Location {0} not found.", e.GetString(0));
                    return(false);
                }
            }

            e.SendMessage("Usage: .Go <X> <Y> <Z> <Map Id>");
            e.SendMessage("Usage: .Go <Location Name>");
            return(false);
        }
Ejemplo n.º 9
0
        private static bool Set_OnCommand(CommandEventArgs e)
        {
            if (e.Length >= 2)
            {
                for (int i = 0; (i + 1) < e.Length; i += 2)
                {
                    if (e.Target is Character)
                    {
                        if (!Server.Scripts.Properties.CharacterProperties.HasProperty(e.GetString(i)))
                        {
                        }
                        else if (e.Player.Player.AccessLevel < Server.Scripts.Properties.CharacterProperties.GetAccessLevel(e.GetString(i)))
                        {
                            e.SendMessage("You dont have access to change this property.");
                            continue;
                        }
                        else if (Server.Scripts.Properties.CharacterProperties.SetValue(e.Target, e.GetString(i), e.GetString(i + 1)))
                        {
                            e.SendMessage("Property \"{0}\" of character \"{2}\" set to value \"{1}\".", e.GetString(i), e.GetString(i + 1), e.Target.Name);
                            continue;
                        }
                    }

                    if (!Server.Scripts.Properties.MobileProperties.HasProperty(e.GetString(i)))
                    {
                        e.SendMessage("Property \"{0}\" on mobile \"{2}\" dont exist.", e.GetString(i), e.Target.Name);
                        continue;
                    }
                    else if (e.Player.Player.AccessLevel < Server.Scripts.Properties.MobileProperties.GetAccessLevel(e.GetString(i)))
                    {
                        e.SendMessage("You dont have access to change this property.");
                        continue;
                    }
                    else if (Server.Scripts.Properties.MobileProperties.SetValue(e.Target, e.GetString(i), e.GetString(i + 1)))
                    {
                        e.SendMessage("Property \"{0}\" of mobile \"{2}\" set to value \"{1}\".", e.GetString(i), e.GetString(i + 1), e.Target.Name);
                        continue;
                    }
                    else
                    {
                        e.SendMessage("Cannot set property \"{0}\" of mobile \"{2}\" to value \"{1}\".", e.GetString(i), e.GetString(i + 1), e.Target.Name);
                        continue;
                    }
                }
                return(true);
            }
            else
            {
                e.SendMessage("Format: Set <propertyName> <value> [...]");
                return(false);
            }
        }
Ejemplo n.º 10
0
        private static bool Inc_OnCommand(CommandEventArgs e)
        {
            if (e.Length >= 2)
            {
                for (int i = 0; (i + 1) < e.Length; i += 2)
                {
                    if (e.Target is Character)
                    {
                        string now = Server.Scripts.Properties.CharacterProperties.GetValue(e.Target, e.GetString(i));
                        if ((Utility.ToInt32(now) != 0) && (e.GetInt32(i + 1) != 0))
                        {
                            if (Server.Scripts.Properties.CharacterProperties.SetValue(e.Target, e.GetString(i), (Utility.ToInt32(now) + e.GetInt32(i + 1)).ToString()))
                            {
                                e.SendMessage("Property \"{0}\" of character \"{2}\" incresed on \"{1}\".", e.GetString(i), e.GetString(i + 1), e.Target.Name);
                                return(true);
                            }
                        }

                        if (!Server.Scripts.Properties.MobileProperties.HasProperty(e.GetString(i)))
                        {
                            e.SendMessage("Property \"{0}\" on mobile \"{1}\" dont exist.", e.GetString(i), e.Target.Name);
                            return(false);
                        }

                        now = Server.Scripts.Properties.MobileProperties.GetValue(e.Target, e.GetString(i));
                        if ((Utility.ToInt32(now) != 0) && (e.GetInt32(i + 1) != 0))
                        {
                            if (Server.Scripts.Properties.MobileProperties.SetValue(e.Target, e.GetString(i), (Utility.ToInt32(now) + e.GetInt32(i + 1)).ToString()))
                            {
                                e.SendMessage("Property \"{0}\" of mobile \"{2}\" incresed on \"{1}\".", e.GetString(i), e.GetString(i + 1), e.Target.Name);
                                return(true);
                            }
                            else
                            {
                                e.SendMessage("Cannot incrise property \"{0}\" of mobile \"{2}\" on value \"{1}\".", e.GetString(i), e.GetString(i + 1), e.Target.Name);
                                return(false);
                            }
                        }
                        else
                        {
                            e.SendMessage("\"{0}\" is not integer value", e.GetString(i + 1));
                            return(false);
                        }
                    }
                    else
                    {
                        if (!Server.Scripts.Properties.MobileProperties.HasProperty(e.GetString(i)))
                        {
                            e.SendMessage("Property \"{0}\" on mobile \"{1}\" dont exist.", e.GetString(i), e.Target.Name);
                            return(false);
                        }
                        string now = Server.Scripts.Properties.MobileProperties.GetValue(e.Target, e.GetString(i));
                        if ((Utility.ToInt32(now) != 0) && (e.GetInt32(i + 1) != 0))
                        {
                            if (Server.Scripts.Properties.MobileProperties.SetValue(e.Target, e.GetString(i), (Utility.ToInt32(now) + e.GetInt32(i + 1)).ToString()))
                            {
                                e.SendMessage("Property \"{0}\" of mobile \"{2}\" incresed on \"{1}\".", e.GetString(i), e.GetString(i + 1), e.Target.Name);
                                return(true);
                            }
                            else
                            {
                                e.SendMessage("Cannot incrise property \"{0}\" of mobile \"{2}\" on value \"{1}\".", e.GetString(i), e.GetString(i + 1), e.Target.Name);
                                return(false);
                            }
                        }
                        else
                        {
                            e.SendMessage("\"{0}\" is not integer value", e.GetString(i + 1));
                            return(false);
                        }
                    }
                }
                return(false);
            }
            else
            {
                e.SendMessage("Format: Inc <propertyName> <value> [<propertyName> <value> ...]");
                return(false);
            }
        }
Ejemplo n.º 11
0
 private static bool Where_OnCommand(CommandEventArgs e)
 {
     e.SendMessage("X = {0}, Y = {1}, Z = {2}, mapID = {3}", e.Player.X, e.Player.Y, e.Player.Z, e.Player.MapId);
     return(true);
 }
Ejemplo n.º 12
0
        private static bool Global_OnCommand(CommandEventArgs e)
        {
            if (e.Length == 0)
            {
                e.SendMessage("Need some parametrs");
                return(false);
            }
            int CorrectCount = 0;
            int AllCount     = 0;

            PropsChecker prop        = new PropsChecker();
            int          i           = -1;
            int          startSumbol = 0;

            if (e.GetString(0) == "if")
            {
                startSumbol = 8;
                for (i = 1; (i + 2) < e.Length; i += 3)
                {
                    if (e.GetString(i) == "then")
                    {
                        break;
                    }
                    if (!Server.Scripts.Properties.CharacterProperties.HasProperty(e.GetString(i)) && !Server.Scripts.Properties.MobileProperties.HasProperty(e.GetString(i)))
                    {
                        e.SendMessage("Wrong property \"{0}\" in if_then block", e.GetString(i));
                    }

                    if (!prop.AddProperty(e.GetString(i), e.GetString(i + 1), e.GetString(i + 2)))
                    {
                        e.SendMessage("Wrong sumbol(s) \"{0}\" in if_then block or incorrect type of value \"{1}\"", e.GetString(i + 1), e.GetString(i + 2));
                        return(false);
                    }
                    startSumbol += e.GetString(i).Length + e.GetString(i + 1).Length + e.GetString(i + 2).Length + 3;
                }
            }

            int startNum = i + 1;

            string str = ".";

            for (i = startNum; i < e.Length; i++)
            {
                if (HaveSpaces(e.GetString(i)))
                {
                    str += "\"";
                    str += e.GetString(i);
                    str += "\"";
                }
                else
                {
                    str += e.GetString(i);
                }
                if (i != e.Length - 1)
                {
                    str += " ";
                }
            }
            if (!Commands.HasCommand(e.GetString(startNum)))
            {
                e.SendMessage("Command \"{0}\" dont exist.", e.GetString(startNum));
                return(false);
            }
            if (Commands.TargetType(e.GetString(startNum)) == TargetType.None)
            {
                e.SendMessage("Command \"{0}\" dont have target variable.", e.GetString(startNum));
                return(false);
            }


            MobileList.MobileEnumerator enumerator = World.allMobiles.GetEnumerator();
            {
                try
                {
                    while (enumerator.MoveNext())
                    {
                        Mobile targ = (Mobile)enumerator.Current;
                        if (prop.Check(targ))
                        {
                            if (Commands.Handle(e.Player, targ, str, true))
                            {
                                CorrectCount++;
                            }
                            AllCount++;
                        }
                    }
                }
                finally
                {
                }
            }
            e.SendMessage(String.Format("Command correctly used on {0} of {1} Mobiles in the world", CorrectCount, AllCount));
            return(true);
        }
Ejemplo n.º 13
0
 private static bool Guid_OnCommand(CommandEventArgs e)
 {
     e.SendMessage("Guid: {0}", e.Player.Guid.ToString("X16"));
     return(true);
 }