[FSOD] /spawnon

Posts 1–5 of 5 · Page 1 of 1
[FSOD] /spawnon
Despite how inactive I've been on MPGH, I suppose I'll contribute again
Creds to @OmegaBM for helping me out especially when I stopped developing for a year and quit pservers

Things been sitting in my admin commands collecting dust, cheers fellas

Code:
    internal class SpawnOnCommand : Command    {
        public SpawnOnCommand()
            : base("spawnon", 6)
        {
        }


        protected override bool Process(Player player, RealmTime time, string[] args)
        {
            if (string.IsNullOrEmpty(args[0]))
            {
                player.SendHelp("Usage: /spawnon <Player> <Int> <Entity>");
                return false;
            }


            foreach (Client i in player.Manager.Clients.Values)
            {


                if (i.Account.Name.EqualsIgnoreCase(args[0]))
                {
                    int num;
                    if (args[1].Length > 0 && int.TryParse(args[1], out num)) //multi
                    {
                        string name = string.Join(" ", args.Skip(2).ToArray());
                        ushort objType;
                        Dictionary<string, ushort> icdatas = new Dictionary<string, ushort>(
                            player.Manager.GameData.IdToObjectType,
                            StringComparer.OrdinalIgnoreCase);
                            if (!icdatas.TryGetValue(name, out objType) ||
                                !player.Manager.GameData.ObjectDescs.ContainsKey(objType))
                            {
                                player.SendInfo("Unknown entity!");
                                return false;
                            }
                            else
                            {
                                for (int u = 0; u < num; u++)
                                {
                                    Entity entity = Entity.Resolve(player.Manager, objType);
                                    entity.Move(i.Player.X, i.Player.Y);
                                    i.Player.Owner.EnterWorld(entity);
                                }
                                player.SendInfo("Sent " + i.Player.Name + " " + string.Join(" ", args.Skip(1).ToArray()) + "'s");
                                return true;
                        }
                    }
                }
                else
                {
                    if (i.Account.Name.EqualsIgnoreCase(args[0]))
                    {
                        {
                            string name = string.Join(" ", args.Skip(1).ToArray());
                            ushort objType;
                            Dictionary<string, ushort> icdatas = new Dictionary<string, ushort>(
                                player.Manager.GameData.IdToObjectType,
                                StringComparer.OrdinalIgnoreCase);
                            if (!icdatas.TryGetValue(name, out objType) ||
                                !player.Manager.GameData.ObjectDescs.ContainsKey(objType))
                            { }
                            Entity entity = Entity.Resolve(player.Manager, objType);
                            entity.Move(i.Player.X, i.Player.Y);
                            i.Player.Owner.EnterWorld(entity);
                        }
                        player.SendInfo("Sent " + i.Player.Name + " " + string.Join(" ", args.Skip(1).ToArray()));
                        return true;
                    }
                }
            }
            return false;
        }

    }


 
Known Bugs
You can fix this yourself as I am too lazy to do it

- When you do /spawnon <player> <entity>
it will not tell you that you forgot to add an integer between the player and entity
(I believe I attempted to fix it a while ago when I first made this, it's probably incomplete or incorrect)


If you have any questions, read my signature and make your move, skypes trash anyways


- - - Updated - - -

Also don't forget to change
Quote Originally Posted by Desire View Post
: base("spawnon", 6)
to the rank integer that you want assigned to
I believe the purpose of this is to test for hacks? Or just purely to troll.
Quote Originally Posted by Anime View Post
I believe the purpose of this is to test for hacks? Or just purely to troll.
I am an abusive owner
<3 Nice, but whats this exactly for.??
Read above. Don't shit post to increase post count.
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us