RemoveBadge does not work

Runyard

New Member
Feb 4, 2018
11
3
Hello community, I come back with a problem because, I have the command RemoveBadge which does not work (the code) it always puts that the badge does not exist (whereas it exists) or be that it removed it (whereas no) I had found it here (from Altercationz), but did not work on plusemu .. could you make me re code it, to make it work? thank you
 

Banana

New Member
Feb 21, 2018
11
0
There is no error, here is the code i use:

Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Plus.HabboHotel.GameClients;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator
{
    class RemoveBadgeCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_remove_badge"; }
        }

        public string Parameters
        {
            get { return "%username% %badge%"; }
        }

        public string Description
        {
            get { return "Remove a badge from a player"; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length != 3)
            {
                Session.SendWhisper("Please enter a username and the code of the badge you want to remove!");
                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.SendNotification("You have had the badge " + Params[2] + " removed from you!");
                    else
                        Session.SendWhisper("You have succesfully removed the badge  " + Params[2] + " from yourself!");
                }
                else
                    Session.SendWhisper("Oops, that user does not have that badge!");
                return;
            }
            else
            {
                Session.SendWhisper("That user cannot be found!");
                return;
            }
        }
    }
}
 

AssLikeThat

Posting Freak
Jan 27, 2013
765
154
There is no error, here is the code i use:

Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Plus.HabboHotel.GameClients;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator
{
    class RemoveBadgeCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_remove_badge"; }
        }

        public string Parameters
        {
            get { return "%username% %badge%"; }
        }

        public string Description
        {
            get { return "Remove a badge from a player"; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length != 3)
            {
                Session.SendWhisper("Please enter a username and the code of the badge you want to remove!");
                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.SendNotification("You have had the badge " + Params[2] + " removed from you!");
                    else
                        Session.SendWhisper("You have succesfully removed the badge  " + Params[2] + " from yourself!");
                }
                else
                    Session.SendWhisper("Oops, that user does not have that badge!");
                return;
            }
            else
            {
                Session.SendWhisper("That user cannot be found!");
                return;
            }
        }
    }
}


Try mine, works fine.

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_takebadge"; }

        }



        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;

            }

        }

    }

}

EDIT: Actually looking at that, it's basically the same..

Make sure command_remove_badge is added into your permissions_commands
 

Users who are viewing this thread

Top