Command Cooldown Help

Supermario

Member
Jan 5, 2016
99
0
Hey,

I am having problems with my cool down, basically when somebody uses a command It basically affects the whole Hotel. For a example. I use the Hug command on somebody, the cool down affects everybody, nobody is able to use any command until the cool down is over. I tried doing separate cool downs for each command, but It still affects the whole hotel? Any suggestions?

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

using Plus.HabboHotel.Rooms;
using Plus.HabboHotel.GameClients;
using Plus.Communication.Packets.Outgoing.Rooms.Chat;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun
{
    class HugCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_hug"; }
        }
        public string Parameters
        {
            get { return "%username%"; }
        }
        public string Description
        {
            get { return "Hug another user."; }
        }
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
                if (Params.Length == 1)
                {
                    Session.SendWhisper("Please enter the username of the person you want to Hug.");
                    return;
                }
                GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);
                if (TargetClient == null)
                {
                    Session.SendWhisper("The user was not found in the room, maybe they're offline.");
                    return;
                }
                RoomUser TargetUser = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Id);
                if (TargetUser == null)
                {
                    Session.SendWhisper("An error occured while finding that user, maybe they're offline or not in this room.");
                }
                if (TargetClient.GetHabbo().Username == Session.GetHabbo().Username)
                {
                    Session.SendWhisper("You cannot Hug yourself!");
                    return;
                }
            if (TargetUser.IsAsleep)
            {
                Session.SendWhisper("Oops, you cannot use this command on someone who is currently away from their Computer.");
                return;
            }
            RoomUser ThisUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
                if (ThisUser == null)
                    return;
            if (!((Math.Abs(TargetUser.X - ThisUser.X) >= 2) || (Math.Abs(TargetUser.Y - ThisUser.Y) >= 2)))
            {
                TimeSpan Cooldown = DateTime.Now - Plus.HabboHotel.Users.Habbo.HugCoolDown;
                if (Cooldown.Seconds >= 30)
                {
                    Room.SendMessage(new ShoutComposer(ThisUser.VirtualId, "| *Hugs " + Params[1] + "* |", 0, ThisUser.LastBubble = 16));
                        System.Threading.Thread.Sleep(1000);
                        Room.SendMessage(new ShoutComposer(TargetUser.VirtualId, "| *Is hugged and feeling loved* |", 0, ThisUser.LastBubble = 16));
                        System.Threading.Thread.Sleep(1000);
                        TargetUser.ApplyEffect(168);
                        System.Threading.Thread.Sleep(4000);
                        ThisUser.ApplyEffect(0);
                        ThisUser.UpdateNeeded = true;
                        TargetUser.ApplyEffect(0);
                        TargetUser.UpdateNeeded = true;
                        Plus.HabboHotel.Users.Habbo.HugCoolDown = DateTime.Now;
                    }
                    else
                    {
                        int num = checked(30 - Cooldown.Seconds);
                        Session.SendWhisper("Cooldown Mode: " + num + " seconds left until you can do that!", 0);
                        return;
                    }
                }        
            else
            {
                Session.SendWhisper("You're too far away! please try getting closer.");
                return;
            }
            }
        }
    }

Hug Cool Down code in Habbo.cs:
Code:
public static DateTime HugCoolDown;
 
bump
 

Pinkman

Posting Freak
Jul 27, 2016
814
193
Try this one mate,

using System;
using Plus.HabboHotel.Rooms;
using Plus.HabboHotel.GameClients;
using Plus.Communication.Packets.Outgoing.Rooms.Chat;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun
{
class Hug : IChatCommand
{
public string PermissionRequired
{
get { return "command_hug"; }
}
public string Parameters
{
get { return "%username%"; }
}
public string Description
{
get { return "Hug another user"; }
}
public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
{
if (Params.Length == 1)
{
Session.SendWhisper("You must enter a username!");
return;
}

GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);
if (TargetClient == null)
{
Session.SendWhisper("That user cannot be found, maybe they're offline or not in the room.");
return;
}

RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Id);
if (User == null)
{
Session.SendWhisper("The user cannot be found, maybe they're offline or not in the room.");
return;
}
RoomUser ThisUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
if (ThisUser == null)
return;

if (!((Math.Abs(User.X - ThisUser.X) >= 2 && (Math.Abs(User.Y - ThisUser.Y) >= 2))))
{

Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "*Hugs " + TargetClient.GetHabbo().Username + "*", 0, User.LastBubble));
User.ApplyEffect(9);
}
else
{
Session.SendWhisper("That user is too far away, try getting closer.");
return;
}
}
}
}


and
public static DateTime HugCoolDown; (Habbo.cs)
 
Here is more neat layed out.
Code:
using System;
using Plus.HabboHotel.Rooms;
using Plus.HabboHotel.GameClients;
using Plus.Communication.Packets.Outgoing.Rooms.Chat;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun
{
    class Hug : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_hug"; }
        }
        public string Parameters
        {
            get { return "%username%"; }
        }
        public string Description
        {
            get { return "Hug another user"; }
        }
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("You must enter a username!");
                return;
            }

            GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);
            if (TargetClient == null)
            {
                Session.SendWhisper("That user cannot be found, maybe they're offline or not in the room.");
                    return;
            }

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Id);
            if (User == null)
            {
                Session.SendWhisper("The user cannot be found, maybe they're offline or not in the room.");
                return;
            }
            RoomUser ThisUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (ThisUser == null)
                return;

            if (!((Math.Abs(User.X - ThisUser.X) >= 2 && (Math.Abs(User.Y - ThisUser.Y) >= 2))))
            {

                Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "*Hugs " + TargetClient.GetHabbo().Username + "*", 0, User.LastBubble));
                User.ApplyEffect(9);
            }
            else
            {
                Session.SendWhisper("That user is too far away, try getting closer.");
                return;
            }
        }
    }
}
 

Supermario

Member
Jan 5, 2016
99
0
Try this one mate,

using System;
using Plus.HabboHotel.Rooms;
using Plus.HabboHotel.GameClients;
using Plus.Communication.Packets.Outgoing.Rooms.Chat;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun
{
class Hug : IChatCommand
{
public string PermissionRequired
{
get { return "command_hug"; }
}
public string Parameters
{
get { return "%username%"; }
}
public string Description
{
get { return "Hug another user"; }
}
public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
{
if (Params.Length == 1)
{
Session.SendWhisper("You must enter a username!");
return;
}

GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);
if (TargetClient == null)
{
Session.SendWhisper("That user cannot be found, maybe they're offline or not in the room.");
return;
}

RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Id);
if (User == null)
{
Session.SendWhisper("The user cannot be found, maybe they're offline or not in the room.");
return;
}
RoomUser ThisUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
if (ThisUser == null)
return;

if (!((Math.Abs(User.X - ThisUser.X) >= 2 && (Math.Abs(User.Y - ThisUser.Y) >= 2))))
{

Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "*Hugs " + TargetClient.GetHabbo().Username + "*", 0, User.LastBubble));
User.ApplyEffect(9);
}
else
{
Session.SendWhisper("That user is too far away, try getting closer.");
return;
}
}
}
}


and
public static DateTime HugCoolDown; (Habbo.cs)
 
Here is more neat layed out.
Code:
using System;
using Plus.HabboHotel.Rooms;
using Plus.HabboHotel.GameClients;
using Plus.Communication.Packets.Outgoing.Rooms.Chat;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun
{
    class Hug : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_hug"; }
        }
        public string Parameters
        {
            get { return "%username%"; }
        }
        public string Description
        {
            get { return "Hug another user"; }
        }
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("You must enter a username!");
                return;
            }

            GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);
            if (TargetClient == null)
            {
                Session.SendWhisper("That user cannot be found, maybe they're offline or not in the room.");
                    return;
            }

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Id);
            if (User == null)
            {
                Session.SendWhisper("The user cannot be found, maybe they're offline or not in the room.");
                return;
            }
            RoomUser ThisUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (ThisUser == null)
                return;

            if (!((Math.Abs(User.X - ThisUser.X) >= 2 && (Math.Abs(User.Y - ThisUser.Y) >= 2))))
            {

                Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "*Hugs " + TargetClient.GetHabbo().Username + "*", 0, User.LastBubble));
                User.ApplyEffect(9);
            }
            else
            {
                Session.SendWhisper("That user is too far away, try getting closer.");
                return;
            }
        }
    }
}

Thanks for trying but where is the cool down for the command?
 

Users who are viewing this thread

Top