Exemple #1
0
        public string Type(string[] @params, MooNetClient invokerClient)
        {
            if (invokerClient == null)
            {
                return("You can not invoke this command from console.");
            }

            if (invokerClient.InGameClient == null)
            {
                return("You can only invoke this command while ingame.");
            }

            var player = invokerClient.InGameClient.Player;
            var name   = "Dye";
            var amount = 1;


            if (@params == null)
            {
                return("You need to specify a item type!");
            }

            name = @params[0];

            var type = ItemGroup.FromString(name);

            if (type == null)
            {
                return("The type given is not a valid item type.");
            }

            if (@params.Count() == 1 || !Int32.TryParse(@params[1], out amount))
            {
                amount = 1;
            }

            if (amount > 100)
            {
                amount = 100;
            }

            for (int i = 0; i < amount; i++)
            {
                var position = new Vector3D(player.Position.X + (float)RandomHelper.NextDouble() * 20f,
                                            player.Position.Y + (float)RandomHelper.NextDouble() * 20f,
                                            player.Position.Z);

                var item = ItemGenerator.GenerateRandom(player, type);
                item.EnterWorld(position);
            }

            return(string.Format("Spawned {0} items with type: {1}", amount, name));
        }