RemoveBadge command

treebeard

Member
Jan 16, 2018
317
173
TakeBadgeCommand.cs

Code:
using System;

using System.Linq;

using System.Text;

using System.Collections.Generic;

using Plus.HabboHotel.Rooms.Chat.Commands;

using Plus.HabboHotel.GameClients;

using Plus.Communication.Packets.Outgoing.Inventory.Badges;





namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator

{

    class TakeBadgeCommand : IChatCommand

    {

        public string PermissionRequired

        {

            get { return "command_take_badge"; }

        }



        public string Parameters

        {

            get { return "%username% %badge%"; }

        }



        public string Description

        {

            get { return "Take a badge from a user."; }

        }



        public void Execute(GameClient Session, Room Room, string[] Params)

        {

            if (Params.Length != 3)

            {

                Session.SendWhisper("Please enter a username and the code of the badge you'd like to take!");

                return;

            }



            GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);

            if (TargetClient != null)

            {

                if (TargetClient.GetHabbo().GetBadgeComponent().HasBadge(Params[2]))

                {

                    TargetClient.GetHabbo().GetBadgeComponent().RemoveBadge(Params[2]);

                    if (TargetClient.GetHabbo().Id != Session.GetHabbo().Id)

                    {

                        TargetClient.SendPacket(new BadgesComposer(Session));

                        TargetClient.SendNotification(Session.GetHabbo().Username + " has removed the badge " + Params[2] + " from you!");

                    }

                    else

                    {

                        Session.SendWhisper("You have successfully removed the badge " + Params[2] + " from yourself!");

                        TargetClient.SendPacket(new BadgesComposer(TargetClient));

                    }

                }

                else

                    Session.SendWhisper("Oops, that user doesn't have this badge (" + Params[2] + ") !");

                return;

            }

            else

            {

                Session.SendWhisper("Oops, we couldn't find that target user!");

                return;

            }

        }

    }

}
 

Users who are viewing this thread

Top