Editing this code

Results 1 to 3 of 3
  1. #1
    Loyalty Vaulient is offline
    MemberRank
    May 2012 Join Date
    MalaysiaLocation
    1,796Posts

    Editing this code

    Code:
            internal void UnIdle()
            {
                this.IdleTime = 0;
    
                if (this.IsAsleep)
                {
                    this.IsAsleep = false;
                    GetRoom().SendMessage(new SleepComposer(this, false));
                }
            }
    
            internal void Dispose()
            {
                Statusses.Clear();
                mRoom = null;
                mClient = null;
            }
    
            internal void Chat(GameClient Session, string Message, bool Shout, int colour = 0)
            {
                if (IsPet || IsBot)
                {
                    InvokedChatMessage messageB;
                    messageB = new InvokedChatMessage(this, Message, Shout, colour);
                    GetRoom().QueueChatMessage(messageB);
                    return;
                }
    
                if (Session != null)
                {
                    if (Session.GetHabbo().Rank < 4)
                    {
                        if (GetRoom().RoomMuted)
                            return;
                    }
                }
                
                UnIdle();
    
                Users.Habbo clientUser = GetClient().GetHabbo();
                if (clientUser.Muted)
                {
                    GetClient().SendNotif("You are muted.");
                    return;
                }
                if (GetRoom().MutedUsers.ContainsKey(Session.GetHabbo().Id))
                {
                    if (GetRoom().MutedUsers[Session.GetHabbo().Id] < SilverwaveEnvironment.GetUnixTimestamp())
                        GetRoom().MutedUsers.Remove(Session.GetHabbo().Id);
                    else {
                        Session.SendNotif("You are muted!");
                        return;
                    }
    
                }
    
                if (Message.StartsWith(":") && Session != null && ChatCommandHandler.Parse(Session, Message.Substring(1)))
                {
                    if (Session.GetHabbo().Rank > 5)
                    {
                        SilverwaveEnvironment.GetGame().GetModerationTool().LogStaffEntry(Session.GetHabbo().Username, string.Empty, "Chat command", string.Format("Issued chat command {0}", Message));
                    }
                    return;
                }
    
    
                uint rank = 1;
                InvokedChatMessage message;
                if (!IsBot)
                {
                    if (!mRoom.IsWorkingChat)
                    {
                        mRoom.RoomChat.Add(new Chatlog(HabboId, LanguageLocale.CheckForBannedPhrases(Message) ? "BANNED PHRASE: " + Message : Message, SilverwaveEnvironment.GetUnixTimestamp()));
                    }
                    else
                    {
                        mRoom.Added.Add(new Chatlog(HabboId, LanguageLocale.CheckForBannedPhrases(Message) ? "BANNED PHRASE: " + Message : Message, SilverwaveEnvironment.GetUnixTimestamp()));
                    }
                }
    
                if (LanguageLocale.CheckForBannedPhrases(Message) && GetClient().GetHabbo().Rank < 4)
                {
                    GetClient().GetHabbo().BannedPhraseCount++;
                    if (GetClient().GetHabbo().BannedPhraseCount >= Convert.ToInt32(SilverwaveEnvironment.GetDBConfig().DBData["spambans.limit"]))
                    {
    
                        if (GetClient() != null && !String.IsNullOrWhiteSpace(Message))
                        {
                            try
                            {
                                GameClient TargetUser = SilverwaveEnvironment.GetGame().GetClientManager().GetClientByUsername(GetClient().GetHabbo().Username);
                                SilverwaveEnvironment.GetGame().GetBanManager().BanUser(TargetUser, "System", 788922000, "Spamming the following: " + Message, true, false);
                                return;
                            }
                            catch (Exception e) { Console.WriteLine(e); }
                        }
                    }
                    message = new InvokedChatMessage(this, Message, Shout, colour);
                    return;
                }
    
                Message = LanguageLocale.FilterSwearwords(Message);
                if (Session != null && Session.GetHabbo() != null)
                    rank = Session.GetHabbo().Rank;
                TimeSpan SinceLastMessage = DateTime.Now - clientUser.spamFloodTime;
                if (SinceLastMessage.TotalSeconds > clientUser.spamProtectionTime && clientUser.spamProtectionBol == true)
                {
                    FloodCount = 0;
                    clientUser.spamProtectionBol = false;
                    clientUser.spamProtectionAbuse = 0;
                }
                else
                {
                    if (SinceLastMessage.TotalSeconds > 4)
                        FloodCount = 0;
                }
    
                if (SinceLastMessage.TotalSeconds < clientUser.spamProtectionTime && clientUser.spamProtectionBol == true)
                {
                    ServerMessage Packet = new ServerMessage(Outgoing.FloodFilter);
                    int timeToWait = clientUser.spamProtectionTime - SinceLastMessage.Seconds;
                    Packet.AppendInt32(timeToWait); //Blocked for X sec
                    GetClient().SendMessage(Packet);
    
                    if (SilverwaveEnvironment.spamBans == true)
                    {
                        clientUser.spamProtectionAbuse++;
                        GameClient toBan;
                        toBan = SilverwaveEnvironment.GetGame().GetClientManager().GetClientByUsername(Session.GetHabbo().Username);
                        if (clientUser.spamProtectionAbuse >= SilverwaveEnvironment.spamBans_limit)
                        {
                            SilverwaveEnvironment.GetGame().GetBanManager().BanUser(toBan, "SPAM*ABUSE", 800, LanguageLocale.GetValue("flood.banmessage"), false, false);
                        }
                        else
                        {
                            toBan.SendNotif(LanguageLocale.GetValue("flood.pleasewait").Replace("%secs%", Convert.ToString(timeToWait)));
                        }
                    }
                    return;
                }
    
     
    
                if (SinceLastMessage.TotalSeconds < 20 && FloodCount > 5 && rank < 5)
                {
                    ServerMessage Packet = new ServerMessage(Outgoing.FloodFilter);
                    clientUser.spamProtectionCount += 1;
                    if (clientUser.spamProtectionCount % 2 == 0)
                    {
                        clientUser.spamProtectionTime = (5 * clientUser.spamProtectionCount);
                    }
                    else
                    {
                        clientUser.spamProtectionTime = 1 * (clientUser.spamProtectionCount - 1);
                    }
                    clientUser.spamProtectionBol = true;
                    Packet.AppendInt32(clientUser.spamProtectionTime - SinceLastMessage.Seconds); //Blocked for X sec
                    GetClient().SendMessage(Packet);
                    return;
                }
    So I tried to make it so that users can spam at least like 5 times and get flooded for 5 seconds , but this code keeps doing the same thing , allows a user to spam 3 times , and gets flooded 10 seconds. Is there anything wrong with this?


  2. #2
    Apprentice MyPrecious is offline
    MemberRank
    Apr 2013 Join Date
    18Posts

    Re: Editing this code

    I am guessing you are ranked higher than 5 so try spaming as rank 1 or 2 see if it works out.

  3. #3
    Loyalty Vaulient is offline
    MemberRank
    May 2012 Join Date
    MalaysiaLocation
    1,796Posts

    Re: Editing this code

    I'm ranked 2 when i was trying it out.



Advertisement