Swift Emulator Fixes

zMagenta

Posting Freak
Jul 15, 2011
1,414
682
Hello! As most people are using Swift Emulator, I thought I'd release the fixes for them here, just for the DevBest users. I will credit each fix to the rightful coder.

--------------------

Command - :givecrystals
1 - Search in HabboHotel/misc/ChatCommandHandler.cs for
Code:
internal void giveCrystals()
2 - replace the void with this
Code:
internal void giveCrystals()
        {
            GameClient clientByUsername = null;
            Room currentRoom = this.Session.GetHabbo().CurrentRoom;
            clientByUsername = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(this.Params[1]);
            if (clientByUsername != null)
            {
                int num;
                if (int.TryParse(this.Params[2], out num))
                {
                    clientByUsername.GetHabbo().Crystals += num;
                    clientByUsername.GetHabbo().GiveUserCrystals(int.Parse(this.Params[2]));
                    clientByUsername.GetHabbo().UpdateDiamondsBalance();
                    clientByUsername.SendNotif(this.Session.GetHabbo().Username + LanguageLocale.GetValue("crystal.awardmessage1") + num.ToString() + LanguageLocale.GetValue("crystal.awardmessage2"));
                    this.Session.SendNotif(LanguageLocale.GetValue("crystal.updateok"));
                }
                else
                {
                    this.Session.SendNotif(LanguageLocale.GetValue("input.intonly"));
                }
            }
            else
            {
                this.Session.SendNotif(LanguageLocale.GetValue("input.usernotfound"));
            }
        }

3 - Now search in HabboHotel/Habbo/Users/Habbo.cs for this
Code:
internal void UpdateActivityPointsBalance(int NotifAmount)

4 - Add above it, this
Code:
internal void UpdateDiamondsBalance()
        {
            this.mClient.GetMessageHandler().GetResponse().Init(Outgoing.ActivityPoints);
            this.mClient.GetMessageHandler().GetResponse().AppendInt32(1);
            this.mClient.GetMessageHandler().GetResponse().AppendInt32(105);
            this.mClient.GetMessageHandler().GetResponse().AppendInt32(this.Crystals);
            this.mClient.GetMessageHandler().SendResponse();
        }internal void UpdateDiamondsBalance()
        {
            this.mClient.GetMessageHandler().GetResponse().Init(Outgoing.ActivityPoints);
            this.mClient.GetMessageHandler().GetResponse().AppendInt32(1);
            this.mClient.GetMessageHandler().GetResponse().AppendInt32(105);
            this.mClient.GetMessageHandler().GetResponse().AppendInt32(this.Crystals);
            this.mClient.GetMessageHandler().SendResponse();
        }

5 - Add this to your bin/Debug/System/locale.ini
Code:
crystal.awardmessage1=  has awarded you
crystal.awardmessage2= crystals!
crystal.updateok=Crystal balance updated successfully.

6 - Add this to your bin/Debug/System/commands_register.ini file
Code:
giveCrystals=59

7 - Add this to your bin/Debug/System/commands.ini file
Code:
[giveCrystals]
giveCrystals.minrank=5
giveCrystals.description=Give Crystals
giveCrystals.prefix=
giveCrystals.input=crystals
giveCrystals.clubs=

--------------------

Core - FilterWord edit

1 - Go to core/LanguageLocale.cs and replace for this for
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Database_Manager.Database.Session_Details.Interfaces;
using System.Data;
using System.Text.RegularExpressions;
 
namespace Butterfly.Core
{
    class LanguageLocale
    {
        private static Dictionary<string, string> values;
        internal static bool welcomeAlertEnabled;
        internal static string welcomeAlert;
 
        private static List<string> swearwords;
 
        internal static void Init()
        {
            values = IniReader.ReadFile(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, @"System/locale.ini"));
            InitWelcomeMessage();
        }
 
        internal static void InitSwearWord()
        {
            swearwords = new List<string>();
            DataTable dTable;
            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT word FROM room_swearword_filter");
                dTable = dbClient.getTable();
            }
 
            string swearWord;
            foreach (DataRow dRow in dTable.Rows)
            {
                swearWord = (string)dRow[0];
                swearwords.Add(swearWord);
            }
 
        }
 
        private static void InitWelcomeMessage()
        {
            Dictionary<string, string> configFile = IniReader.ReadFile(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, @"System/welcome_config.ini"));
            welcomeAlertEnabled = configFile["welcome.alert.enabled"] == "true";
 
            if (welcomeAlertEnabled)
            {
                welcomeAlert = File.ReadAllText(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, @"System/welcome_message.ini"));
            }
        }
 
        private static string ReplaceEx(string original,
                    string pattern, string replacement)
        {
            int count, position0, position1;
            count = position0 = position1 = 0;
            string upperString = original.ToUpper();
            string upperPattern = pattern.ToUpper();
            int inc = (original.Length / pattern.Length) *
                      (replacement.Length - pattern.Length);
            char[] chars = new char[original.Length + Math.Max(0, inc)];
            while ((position1 = upperString.IndexOf(upperPattern,
                                              position0)) != -1)
            {
                for (int i = position0; i < position1; ++i)
                    chars[count++] = original[i];
                for (int i = 0; i < replacement.Length; ++i)
                    chars[count++] = replacement[i];
                position0 = position1 + pattern.Length;
            }
            if (position0 == 0) return original;
            for (int i = position0; i < original.Length; ++i)
                chars[count++] = original[i];
            return new string(chars, 0, count);
        }
 
        internal static string FilterSwearwords(string original)
        {
 
            foreach (string word in swearwords)
            {
                original = ReplaceEx(original, word, "bobba");
            }
            return original;
        }
 
        internal static string GetValue(string value)
        {
            if (!values.ContainsKey(value))
            {
                throw new MissingLocaleException("Missing language locale for [" + value + "]");
            }
            return values[value];
        }
 
        class MissingLocaleException : Exception
        {
            public MissingLocaleException(string message)
                : base(message)
            {
 
            }
        }
    }
}
The next is for people without the filter turned on.

2 - Go to HabboHotel/Rooms/RoomUser.cs and search for
Code:
//Message = LanguageLocale.FilterSwearwords(Message);
and remove the '//'

--------------------

Core - ChatLogs being logged into the DB

1 - Go to your HabboHotel/Rooms/RoomUser.cs and put this
Code:
if (!this.IsPet && !this.IsBot)
            {
                using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    adapter.setQuery("INSERT INTO chatlogs (user_id, room_id, message, timestamp, user_name) VALUES (@user, @room, [URL='http://devbest.com/members/message.10634/']Message[/URL], [URL='http://devbest.com/members/time.25891/']Time[/URL], [URL='http://devbest.com/members/username.1633/']Username[/URL])");
                    adapter.addParameter("user", Session.GetHabbo().Id);
                    adapter.addParameter("room", RoomId);
                    adapter.addParameter("message", Message);
                    adapter.addParameter("time", ButterflyEnvironment.GetUnixTimestamp());
                    adapter.addParameter("username", Session.GetHabbo().Username);
                    adapter.runQuery();
                }
            }
above
Code:
Message = LanguageLocale.FilterSwearwords(Message);

--------------------

Furni - One way gate fix

1 - Search in HabboEvents/Incoming.cs find
Code:
Incoming.OneWayGate = 1151;
change to
Code:
Incoming.OneWayGate = 3999;

Whole Emulator Download / More information

If you do not know how to do this, you can download the fixed version. Click one of the links below. Please be aware this does not contain the crystals fix!





(Thanks to )
Enjoy the fixes - I'll update more once I find them.
 

Lotus

Legacy, it's all anyone leaves behind.
Jun 8, 2012
1,637
501
Great Work again! Also could there be a release for people that don't know how to do this maybe?
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,194
3,901
Nice share, but that is a silly way of saving chatlogs. They should be saved either on room unload or after x amount of messages.
 

Users who are viewing this thread

Top