Exemplo n.º 1
0
        public static void Spawn(SharpBridge.Player player, object[] param)
        {
            uint weapon = (uint)param[0];

            if (weapon < 1 || weapon == 6 || weapon == 8 || weapon > 18)
            {
                player.sendMsg($"Weapon {weapon} is invalid. Use 1-5, 7, 9-18", ChatColor.ERROR);
                return;
            }

            Models.ItemTypesEF wClass = Game.ItemTypesManager.GetWeaponFromGameWeapon((byte)weapon);
            if (wClass == null)
            {
                player.sendMsg($"Not a database weapon", ChatColor.ERROR);
                return;
            }

            Game.Account acc = Game.AccountManager.Get(player.getID());
            acc.insertItem((short)weapon, 1, false);
            acc.insertItem(wClass.weapon.ammoItem, 200);

            Models.ItemEF bullets = acc.getItem(wClass.weapon.ammoItem);
            if (bullets == null)
            {
                return;                  //Overkill almost
            }
            player.giveWeapon(weapon, (uint)bullets.amount);
        }
Exemplo n.º 2
0
        public void setClothesFromString(SharpBridge.Player player)
        {
            Dictionary <uint, uint> dic = new Dictionary <uint, uint>();

            string[] pieces = user.clothes.Split(' ');
            try
            {
                if (pieces.Length >= 1)
                {
                    player.setSkinId(uint.Parse(pieces[0]));
                }

                for (uint i = 1; i < pieces.Length; i++)
                {
                    string[] parts = pieces[i].Split(',');
                    if (parts.Length != 2)
                    {
                        continue;
                    }

                    uint part = uint.Parse(parts[0]);
                    uint id   = uint.Parse(parts[1]);

                    if (part < 10)
                    {
                        player.setClothes(part, id);
                    }
                    else
                    {
                        player.setProperty(part - 10, id);
                    }
                }
            }
            catch (Exception) { }
        }
Exemplo n.º 3
0
        public static void ChangeSkin(SharpBridge.Player player, object[] param)
        {
            uint id = (uint)param[0];

            if (id > 350)
            {
                player.sendMsg($"{id} is not a valid skin ID", ChatColor.ERROR);
                return;
            }
            player.setSkinId(id);
        }
Exemplo n.º 4
0
        public void updateClothes(SharpBridge.Player player)
        {
            string s = SharpBridge.Skins.getIdByHash(player.getSkinModel()) + " ";

            for (uint i = 0; i < 12; i++)
            {
                uint val = i < 10 ? player.getClothes(i) : player.getProperty(i - 10);
                if (val == 0)
                {
                    continue;           //If default why bother
                }
                s += $"{i},{val} ";
            }
            user.clothes = s;
        }
Exemplo n.º 5
0
        //Skins 1-2 have the most variations for this command
        public static void ChangeProperty(SharpBridge.Player player, object[] param)
        {
            uint id = (uint)param[0];

            if (id < 1 || id > 2)
            {
                player.sendMsg($"{id} is not a valid property, use 1-2", ChatColor.ERROR);
                return;
            }

            uint variation = (uint)param[1];

            if (id < 1 || id > 100)
            {
                player.sendMsg($"{variation} is not a valid variation, use 1-100", ChatColor.ERROR);
                return;
            }
            player.setProperty(id - 1, variation - 1);
        }
Exemplo n.º 6
0
 public static void Disarm(SharpBridge.Player player, object[] param)
 {
     player.removeWeapon(0);
 }
Exemplo n.º 7
0
        public static void processCommand(int playerid, ref string cmd)
        {
            SharpBridge.Player player = SharpBridge.Entities.getPlayer(playerid);
            if (player == null)
            {
                return;
            }

            string[] s = cmd.ToLower().Split(' ');
            if (!CommandsManager.commands.ContainsKey(s[0]))
            {
                player.sendMsg($"'{s[0]}' is an invalid command", ChatColor.ERROR);
                return;
            }

            Command command = CommandsManager.commands[s[0]];

            if (command.loggedIn != Game.AccountManager.IsOnline(playerid))
            {
                player.sendMsg(command.loggedIn ? "You must /login first" : "You are already logged in", ChatColor.ERROR);
                return;
            }

            if (command.args == null)
            {
                command.command(player, null); //No need to check
                return;
            }

            object[] obj = new object[command.args.Length];
            try
            {
                for (int i = 0; i < command.args.Length; i++)
                {
                    char c = command.args[i];
                    if (c == 's')
                    {
                        obj[i] = s[i + 1];
                    }
                    else if (c == 'i')
                    {
                        obj[i] = Int32.Parse(s[i + 1]);
                    }
                    else if (c == 'u')
                    {
                        obj[i] = UInt32.Parse(s[i + 1]);
                    }
                    else if (c == 'f')
                    {
                        obj[i] = float.Parse(s[i + 1]);
                    }
                }
                //Invoke command
            }
            catch (Exception)
            {
                //Command parsing failed, show usage
                player.sendMsg(command.usage, ChatColor.ERROR);
                return;
            }
            command.command(player, obj);
        }
Exemplo n.º 8
0
 public static void SaveSkin(SharpBridge.Player player, object[] param)
 {
     Game.AccountManager.Get(player.getID()).updateClothes(player);
     player.sendMsg("Saved!", ChatColor.SUCCESS);
 }