Official uberEmulator Development Thread [C#, R49+, MySQL]

Page 1 of 3 123 LastLast
Results 1 to 15 of 38
  1. #1
    Gamma RastaLulz is offline
    MemberRank
    Dec 2007 Join Date
    EarthLocation
    3,328Posts

    Official uberEmulator Development Thread [C#, R49+, MySQL]

    Official uberEmulator Development Thread

    Quick Links:
    - Original uberEmulator Development Thread
    - uberEmulator Help Thread

    Thread Overview:
    Seeing that uberEmulator is an open source software, it is only fair that the community develops the software together. Rather than having multiple private developments by various users, as this is of no real help to the community. This thread will also hopefully organize all uberEmu development, as it it quite disorganized at the moment with various edits going on at the moment.

    Use this thread to:
    • Discuss Issues
    • Post Fixes
    • Develop uberEMU


    Do NOT use this thread to:
    • Ask for help.
    • Post good job, etc (this is a development thread - use the thanks button).

      Users found doing so will be infracted


    Fixes and sources will be posted below and kept up to date:
    - uberEmulator R1
    Last edited by Donkjam; 21-06-10 at 12:55 AM.


  2. #2
    8-bit Bitch Slapper Alpha Ducky is offline
    MemberRank
    Mar 2007 Join Date
    In My HouseLocation
    2,436Posts
    Quote Originally Posted by obrienray1 View Post
    I have a problem with register on my ubercms and i even downloaded the register page and put it in the right place but it still doesn't work any help?
    Wow -.-

    Quote Originally Posted by RastaLulz View Post
    Do NOT use this thread to:
    • Ask for help.


    But anyways.
    Here are some fixes.
    Credits to Shorty/Habchop

    Room Alert - Sending Message Adding to Caution Count Fix
    Search for "public void RoomAlert("
    Find:
    Code:
                    using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                    {
                        dbClient.ExecuteQuery("UPDATE user_info SET cautions = cautions + 1 WHERE " + QueryBuilder.ToString() + " LIMIT " + j);
                    }
    Replace with:
    Code:
                if (Caution)
                {
                    using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                    {
                        dbClient.ExecuteQuery("UPDATE user_info SET cautions = cautions + 1 WHERE " + QueryBuilder.ToString() + " LIMIT " + j);
                    }
    
                }
    Drink Machines - Giving out drinks if you double click at the side of them.
    Search for: case "vendingmachine":
    Find:
    Code:
                        case "vendingmachine":
    
                            if (this.ExtraData == "1")
                            {
                                User = GetRoom().GetRoomUserByHabbo(InteractingUser);
    
                                if (User != null)
                                {
                                    User.UnlockWalking();
    
                                    int randomDrink = GetBaseItem().VendingIds[UberEnvironment.GetRandomNumber(0, (GetBaseItem().VendingIds.Count - 1))];
                                    User.CarryItem(randomDrink);
                                }
    
                                this.InteractingUser = 0;
                                this.ExtraData = "0";
    
                                UpdateState(false, true);
                            break;
    Replace with:
    Code:
                        case "vendingmachine":
    
                            if (this.ExtraData == "1")
                            {
                                User = GetRoom().GetRoomUserByHabbo(InteractingUser);
    
                                if (User != null && User.Coordinate == SquareInFront)
                                {
                                    int randomDrink = GetBaseItem().VendingIds[UberEnvironment.GetRandomNumber(0, (GetBaseItem().VendingIds.Count - 1))];
                                    User.CarryItem(randomDrink);
                                }
    
                                this.InteractingUser = 0;
                                this.ExtraData = "0";
    
                                User.UnlockWalking();
                                UpdateState(false, true);
                            }
    
                            break;
    Teleport - Teleport moves you out if it isn't linked.
    Search for "// This tele is not linked, so let's gtfo."
    Find:
    Code:
                                            // This tele is not linked, so let's gtfo.
    
                                            User.UnlockWalking();
                                            InteractingUser = 0;
    Replace with:
    Code:
                                            // This tele is not linked, so let's gtfo.
                                            // Open the door
                                            keepDoorOpen = true;
    
                                            User.UnlockWalking();
                                            InteractingUser = 0;
    
                                            // Move out of the tele
                                            User.MoveTo(SquareInFront);
    In marketplace.cs
    Code:
    		    Message.AppendUInt((uint)Row["offer_id"]);
                        Message.AppendInt32(1);
                        Message.AppendInt32(int.Parse(Row["item_type"].ToString()));
                        Message.AppendInt32((int)Row["sprite_id"]); // Sprite ID
                        Message.AppendStringWithBreak(""); // Extra Chr (R52)
                        Message.AppendInt32((int)Row["total_price"]); // Price
                        Message.AppendInt32((int)Row["sprite_id"]); // ??
                        Message.AppendInt32((int)Row["total_price"]); // Avg
                        Message.AppendInt32(0); // Offers
    Last edited by Alpha Ducky; 27-07-10 at 03:27 AM.

  3. #3
    Account Upgraded | Title Enabled! MDK is offline
    MemberRank
    Apr 2010 Join Date
    ScotlandLocation
    445Posts

    Re: Official uberEmulator Development Thread [C#, R49+, MySQL]

    Alright, well most of the problems are crashes with the server, and users being unable to fix the crashes. It's really confusing and I have no idea how Roy managed to do this to the server without smoking some heavy shit :P

    Anyway... Code snippets which should fix SOME of the disconnections/errors, you name it.

    ----

    Navigate to Room.cs in your UberEmulator folder, and open it up in C++ or wherever... Find:
    Code:
    Event = null;
    Replace with:
    Code:
    Event = new RoomEvent(0, null, null, 0, new List<string>());

  4. #4
    Novice lorigio is offline
    MemberRank
    Jun 2010 Join Date
    2Posts

    Re: Official uberEmulator Development Thread [C#, R49+, MySQL]

    Walk diagonal

    Search:
    Code:
    InitMovements(4)
    Replace:
    Code:
    InitMovements(0)
    If anyone post the fix the crash is the most important.
    Sorry for the english but I'm Italian.
    Last edited by lorigio; 22-06-10 at 03:32 PM.

  5. #5
    En Français? Bjork is offline
    MemberRank
    Apr 2007 Join Date
    854Posts
    No more DC's in Marketplace page?

    Replace Marketplace.cs with:

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    
    using Uber.HabboHotel.GameClients;
    using Uber.HabboHotel.Items;
    using Uber.Storage;
    using Uber.Messages;
    
    namespace Uber.HabboHotel.Catalogs
    {
        class Marketplace
        {
            public Boolean CanSellItem(UserItem Item)
            {
                if (!Item.GetBaseItem().AllowTrade || !Item.GetBaseItem().AllowMarketplaceSell)
                {
                    return false;
                }
    
                return true;
            }
    
            public void SellItem(GameClient Session, uint ItemId, int SellingPrice)
            {
                UserItem Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId);
    
                if (Item == null || SellingPrice > 10000 || !CanSellItem(Item))
                {
                    Session.GetMessageHandler().GetResponse().Init(610);
                    Session.GetMessageHandler().GetResponse().AppendBoolean(false);
                    Session.GetMessageHandler().SendResponse();
    
                    return;
                }
    
                int Comission = CalculateComissionPrice(SellingPrice);
                int TotalPrice = SellingPrice + Comission;
                int ItemType = 1;
    
                if (Item.GetBaseItem().Type == "i")
                {
                    ItemType++;
                }
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    dbClient.AddParamWithValue("public_name", Item.GetBaseItem().PublicName);
                    dbClient.AddParamWithValue("extra_data", Item.ExtraData);
                    dbClient.ExecuteQuery("INSERT INTO catalog_marketplace_offers (item_id,user_id,asking_price,total_price,public_name,sprite_id,item_type,timestamp,extra_data) VALUES ('" + Item.BaseItem + "','" + Session.GetHabbo().Id + "','" + SellingPrice + "','" + TotalPrice + "',@public_name,'" + Item.GetBaseItem().SpriteId + "','" + ItemType + "','" + UberEnvironment.GetUnixTimestamp() + "',@extra_data)");
                }
    
                Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);
    
                Session.GetMessageHandler().GetResponse().Init(610);
                Session.GetMessageHandler().GetResponse().AppendBoolean(true);
                Session.GetMessageHandler().SendResponse();
            }
    
            public int CalculateComissionPrice(float SellingPrice)
            {
                return (int)Math.Ceiling((float)(SellingPrice / 100));
            }
    
            public Double FormatTimestamp()
            {
                return UberEnvironment.GetUnixTimestamp() - 172800;
            }
    
            public ServerMessage SerializeOffers(int MinCost, int MaxCost, String SearchQuery, int FilterMode)
            {
                // IgI`UJUIIY~JX]gXoAJISA
    
                DataTable Data = null;
                StringBuilder WhereClause = new StringBuilder();
                string OrderMode = "";
    
                WhereClause.Append("WHERE state = '1' AND timestamp >= '" + FormatTimestamp());
    
                if (MinCost >= 0)
                {
                    WhereClause.Append("' AND total_price >= '" + MinCost);
                }
    
                if (MaxCost >= 0)
                {
                    WhereClause.Append("' AND total_price <= '" + MaxCost);
                }
    
                switch (FilterMode)
                {
                    case 1:
                    default:
    
                        OrderMode = "' ORDER BY asking_price DESC";
                        break;
    
                    case 2:
    
                        OrderMode = "' ORDER BY asking_price ASC";
                        break;
                }
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    dbClient.AddParamWithValue("search_query", "%" + SearchQuery + "%");
    
                    if (SearchQuery.Length >= 1)
                    {
                        WhereClause.Append(" AND public_name LIKE @search_query");
                    }
    
                    Data = dbClient.ReadDataTable("SELECT * FROM catalog_marketplace_offers " + WhereClause.ToString() + " " + OrderMode + " LIMIT 100");
                }
    
                ServerMessage Message = new ServerMessage(615);
    
                if (Data != null)
                {
                    Message.AppendInt32(Data.Rows.Count);
    
                    foreach (DataRow Row in Data.Rows)
                    {
                        Message.AppendUInt((uint)Row["offer_id"]);
                        Message.AppendInt32(1);
                        Message.AppendInt32(int.Parse(Row["item_type"].ToString()));
                        Message.AppendInt32((int)Row["sprite_id"]); // Sprite ID
                        Message.AppendStringWithBreak(""); // Extra Chr (R52)
                        Message.AppendInt32((int)Row["total_price"]); // Price
                        Message.AppendInt32((int)Row["sprite_id"]); // ??
                        Message.AppendInt32((int)Row["total_price"]); // Avg
                        Message.AppendInt32(0); // Offers 
                    }
                }
                else
                {
                    Message.AppendInt32(0);
                }
    
                return Message;
            }
    
            public ServerMessage SerializeOwnOffers(uint HabboId)
            {
                DataTable Data = null;
                int Profits = 0;
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    Data = dbClient.ReadDataTable("SELECT * FROM catalog_marketplace_offers WHERE user_id = '" + HabboId + "'");
                    String RawProfit = dbClient.ReadDataRow("SELECT SUM(asking_price) FROM catalog_marketplace_offers WHERE state = '2' AND user_id = '" + HabboId + "'")[0].ToString();
    
                    if (RawProfit.Length > 0)
                    {
                        Profits = int.Parse(RawProfit);
                    }
                }
    
                ServerMessage Message = new ServerMessage(616);
                Message.AppendInt32(Profits);
    
                if (Data != null)
                {
                    Message.AppendInt32(Data.Rows.Count);
    
                    foreach (DataRow Row in Data.Rows)
                    {
                        // IhHI`n~^II[EFPN[OKPA
    
                        int MinutesLeft = (int)Math.Floor((((Double)Row["timestamp"] + 172800) - UberEnvironment.GetUnixTimestamp()) / 60);
                        int state = int.Parse(Row["state"].ToString());
    
                        if (MinutesLeft <= 0)
                        {
                            state = 3;
                            MinutesLeft = 0;
                        }
    
                        Message.AppendUInt((uint)Row["offer_id"]);
                        Message.AppendInt32(state); // 1 = active, 2 = sold, 3 = expired
                        Message.AppendInt32(int.Parse(Row["item_type"].ToString())); // always 1 (??)
                        Message.AppendInt32((int)Row["sprite_id"]);
                        Message.AppendInt32((int)Row["total_price"]); // ??
                        Message.AppendInt32(MinutesLeft);
                        Message.AppendInt32((int)Row["sprite_id"]);
                    }
                }
                else
                {
                    Message.AppendInt32(0);
                }
    
                return Message;
            }
        }
    }
    Worked for me, so should work for you ;)

    I had a problem with "View Chatlogs" in Moderation Tool:

    Here is a fix, He should work :)

    Replace ModerationTool.cs:

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    
    using Uber.HabboHotel.Rooms;
    using Uber.HabboHotel.GameClients;
    using Uber.Messages;
    using Uber.Storage;
    
    namespace Uber.HabboHotel.Support
    {
        class ModerationTool
        {
            #region General
    
            private List<SupportTicket> Tickets;
    
            public List<string> UserMessagePresets;
            public List<string> RoomMessagePresets;
    
            public ModerationTool()
            {
                Tickets = new List<SupportTicket>();
                UserMessagePresets = new List<string>();
                RoomMessagePresets = new List<string>();
            }
    
            public ServerMessage SerializeTool()
            {
                ServerMessage Message = new ServerMessage(531);
                Message.AppendInt32(-1);
                Message.AppendInt32(UserMessagePresets.Count);
    
                lock (UserMessagePresets)
                {
                    foreach (String Preset in UserMessagePresets)
                    {
                        Message.AppendStringWithBreak(Preset);
                    }
                }
    
                Message.AppendInt32(0);
                Message.AppendInt32(14);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
    
                Message.AppendInt32(RoomMessagePresets.Count);
    
                lock (RoomMessagePresets)
                {
                    foreach (String Preset in RoomMessagePresets)
                    {
                        Message.AppendStringWithBreak(Preset);
                    }
                }
    
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendStringWithBreak("test");
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendStringWithBreak("test");
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendInt32(1);
                Message.AppendStringWithBreak("test");
    
                return Message;
            }
    
            #endregion
    
            #region Message Presets
    
            public void LoadMessagePresets()
            {
                UserMessagePresets.Clear();
                RoomMessagePresets.Clear();
    
                DataTable Data = null;
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    Data = dbClient.ReadDataTable("SELECT type,message FROM moderation_presets WHERE enabled = '1'");
                }
    
                if (Data == null)
                {
                    return;
                }
    
                foreach (DataRow Row in Data.Rows)
                {
                    String Message = (String)Row["message"];
    
                    switch (Row["type"].ToString().ToLower())
                    {
                        case "message":
    
                            UserMessagePresets.Add(Message);
                            break;
    
                        case "roommessage":
    
                            RoomMessagePresets.Add(Message);
                            break;
                    }
                }
            }
    
            #endregion
    
            #region Support Tickets
    
            public void LoadPendingTickets()
            {
                Tickets.Clear();
    
                DataTable Data = null;
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    Data = dbClient.ReadDataTable("SELECT id,score,type,status,sender_id,reported_id,moderator_id,message,room_id,room_name,timestamp FROM moderation_tickets WHERE status = 'open' OR status = 'picked'");
                }
    
                if (Data == null)
                {
                    return;
                }
    
                foreach (DataRow Row in Data.Rows)
                {
                    SupportTicket Ticket = new SupportTicket((uint)Row["id"], (int)Row["score"], (int)Row["type"], (uint)Row["sender_id"], (uint)Row["reported_id"], (String)Row["message"], (uint)Row["room_id"], (String)Row["room_name"], (Double)Row["timestamp"]);
    
                    if (Row["status"].ToString().ToLower() == "picked")
                    {
                        Ticket.Pick((uint)Row["moderator_id"], false);
                    }
    
                    Tickets.Add(Ticket);
                }
            }
    
            public void SendNewTicket(GameClient Session, int Category, uint ReportedUser, String Message)
            {
                if (Session.GetHabbo().CurrentRoomId <= 0)
                {
                    return;
                }
    
                RoomData Data = UberEnvironment.GetGame().GetRoomManager().GenerateNullableRoomData(Session.GetHabbo().CurrentRoomId);
    
                uint TicketId = 0;
                
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    dbClient.AddParamWithValue("message", Message);
                    dbClient.AddParamWithValue("name", Data.Name);
    
                    dbClient.ExecuteQuery("INSERT INTO moderation_tickets (score,type,status,sender_id,reported_id,moderator_id,message,room_id,room_name,timestamp) VALUES (1,'" + Category + "','open','" + Session.GetHabbo().Id + "','" + ReportedUser + "','0',@message,'" + Data.Id + "',@name,'" + UberEnvironment.GetUnixTimestamp() + "')");
                    dbClient.ExecuteQuery("UPDATE user_info SET cfhs = cfhs + 1 WHERE user_id = '" + Session.GetHabbo().Id + "' LIMIT 1");
    
                    TicketId = (uint)dbClient.ReadDataRow("SELECT id FROM moderation_tickets WHERE sender_id = '" + Session.GetHabbo().Id + "' ORDER BY id DESC LIMIT 1")[0];
                }
    
                SupportTicket Ticket = new SupportTicket(TicketId, 1, Category, Session.GetHabbo().Id, ReportedUser, Message, Data.Id, Data.Name, UberEnvironment.GetUnixTimestamp());
    
                Tickets.Add(Ticket);
    
                SendTicketToModerators(Ticket);
            }
    
            public void SendOpenTickets(GameClient Session)
            {
                lock (Tickets)
                {
                    foreach (SupportTicket Ticket in Tickets)
                    {
                        if (Ticket.Status != TicketStatus.OPEN && Ticket.Status != TicketStatus.PICKED)
                        {
                            continue;
                        }
    
                        Session.SendMessage(Ticket.Serialize());
                    }
                }
            }
    
            public SupportTicket GetTicket(uint TicketId)
            {
                lock (Tickets)
                {
                    foreach (SupportTicket Ticket in Tickets)
                    {
                        if (Ticket.TicketId == TicketId)
                        {
                            return Ticket;
                        }
                    }
                }
    
                return null;
            }
    
            public void PickTicket(GameClient Session, uint TicketId)
            {
                SupportTicket Ticket = GetTicket(TicketId);
    
                if (Ticket == null || Ticket.Status != TicketStatus.OPEN)
                {
                    return;
                }
    
                Ticket.Pick(Session.GetHabbo().Id, true);
                SendTicketToModerators(Ticket);
            }
    
            public void ReleaseTicket(GameClient Session, uint TicketId)
            {
                SupportTicket Ticket = GetTicket(TicketId);
    
                if (Ticket == null || Ticket.Status != TicketStatus.PICKED || Ticket.ModeratorId != Session.GetHabbo().Id)
                {
                    return;
                }
    
                Ticket.Release(true);
                SendTicketToModerators(Ticket);
            }
    
            public void CloseTicket(GameClient Session, uint TicketId, int Result)
            {
                SupportTicket Ticket = GetTicket(TicketId);
    
                if (Ticket == null || Ticket.Status != TicketStatus.PICKED || Ticket.ModeratorId != Session.GetHabbo().Id)
                {
                    return;
                }
    
                GameClient Client = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(Ticket.SenderId);
    
                TicketStatus NewStatus;
                int ResultCode;
    
                switch (Result)
                {
                    case 1:
    
                        ResultCode = 1;
                        NewStatus = TicketStatus.INVALID;
                        break;
    
                    case 2:
    
                        ResultCode = 2;
                        NewStatus = TicketStatus.ABUSIVE;
    
                        using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                        {
                            dbClient.ExecuteQuery("UPDATE user_info SET cfhs_abusive = cfhs_abusive + 1 WHERE user_id = '" + Ticket.SenderId + "' LIMIT 1");
                        }
    
                        break;
    
                    case 3:
                    default:
    
                        ResultCode = 0;
                        NewStatus = TicketStatus.RESOLVED;
                        break;
                }
    
                if (Client != null)
                {
                    Client.GetMessageHandler().GetResponse().Init(540);
                    Client.GetMessageHandler().GetResponse().AppendInt32(ResultCode);
                    Client.GetMessageHandler().SendResponse();
                }
    
                Ticket.Close(NewStatus, true);
                SendTicketToModerators(Ticket);
            }
    
            public Boolean UsersHasPendingTicket(uint Id)
            {
                lock (Tickets)
                {
                    foreach (SupportTicket Ticket in Tickets)
                    {
                        if (Ticket.SenderId == Id && Ticket.Status == TicketStatus.OPEN)
                        {
                            return true;
                        }
                    }
                }
    
                return false;
            }
    
            public void DeletePendingTicketForUser(uint Id)
            {
                lock (Tickets)
                {
                    foreach (SupportTicket Ticket in Tickets)
                    {
                        if (Ticket.SenderId == Id)
                        {
                            Ticket.Delete(true);
                            SendTicketToModerators(Ticket);
                            return;
                        }
                    }
                }
            }
    
            public void SendTicketToModerators(SupportTicket Ticket)
            {
                UberEnvironment.GetGame().GetClientManager().BroadcastMessage(Ticket.Serialize(), "fuse_mod");
            }
    
            #endregion
    
            #region Room Moderation
    
            public void PerformRoomAction(GameClient ModSession, uint RoomId, Boolean KickUsers, Boolean LockRoom, Boolean InappropriateRoom)
            {
                Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(RoomId);
    
                if (Room == null)
                {
                    return;
                }
    
                if (LockRoom)
                {
                    Room.State = 1;
    
                    using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                    {
                        dbClient.ExecuteQuery("UPDATE rooms SET state = 'locked' WHERE id = '" + Room.RoomId + "' LIMIT 1");
                    }
                }
    
                if (InappropriateRoom)
                {
                    Room.Name = "Inappropriate to Hotel Managament";
                    Room.Description = "Inappropriate to Hotel Management";
                    Room.Tags.Clear();
    
                    using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                    {
                        dbClient.ExecuteQuery("UPDATE rooms SET caption = 'Inappropriate to Hotel Management', description = 'Inappropriate to Hotel Management', tags = '' WHERE id = '" + Room.RoomId + "' LIMIT 1");
                    }
                }
    
                if (KickUsers)
                {
                    lock (Room.UserList)
                    {
                        List<RoomUser> ToRemove = new List<RoomUser>();
    
                        foreach (RoomUser User in Room.UserList)
                        {
                            if (User.IsBot || User.GetClient().GetHabbo().Rank >= ModSession.GetHabbo().Rank)
                            {
                                continue;
                            }
    
                            ToRemove.Add(User);
                        }
    
                        for (int i = 0; i < ToRemove.Count; i++)
                        {
                            Room.RemoveUserFromRoom(ToRemove[i].GetClient(), true, false);
                        }
                    }
                }
            }
    
            public void RoomAlert(uint RoomId, Boolean Caution, String Message)
            {
                Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(RoomId);
    
                if (Room == null || Message.Length <= 1)
                {
                    return;
                }
    
                StringBuilder QueryBuilder = new StringBuilder();
                int j = 0;
    
                lock (Room.UserList)
                {
                    foreach (RoomUser User in Room.UserList)
                    {
                        if (User.IsBot)
                        {
                            continue;
                        }
    
                        User.GetClient().SendNotif(Message, Caution);
    
                        if (j > 0)
                        {
                            QueryBuilder.Append(" OR ");
                        }
    
                        QueryBuilder.Append("user_id = '" + User.GetClient().GetHabbo().Id + "'");
                        j++;
                    }
                }
    
                if (Caution)
                {
                    using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                    {
                        dbClient.ExecuteQuery("UPDATE user_info SET cautions = cautions + 1 WHERE " + QueryBuilder.ToString() + " LIMIT " + j);
                    }
    
                }
            }
    
            public ServerMessage SerializeRoomTool(RoomData Data)
            {
                Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Data.Id);
                uint OwnerId = 0;
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    try
                    {
                        OwnerId = (uint)dbClient.ReadDataRow("SELECT id FROM users WHERE username = '" + Data.Owner + "' LIMIT 1")[0];
                    }
                    catch (Exception) { }
                }
    
                ServerMessage Message = new ServerMessage(538);
                Message.AppendUInt(Data.Id);
                Message.AppendInt32(Data.UsersNow); // user count
    
                if (Room != null)
                {
                    Message.AppendBoolean((Room.GetRoomUserByHabbo(Data.Owner) != null));
                }
                else
                {
                    Message.AppendBoolean(false);
                }
    
                Message.AppendUInt(OwnerId);
                Message.AppendStringWithBreak(Data.Owner);
                Message.AppendUInt(Data.Id);
                Message.AppendStringWithBreak(Data.Name);
                Message.AppendStringWithBreak(Data.Description);
                Message.AppendInt32(Data.TagCount);
    
                foreach (string Tag in Data.Tags)
                {
                    Message.AppendStringWithBreak(Tag);
                }
    
                if (Room != null)
                {
                    Message.AppendBoolean(Room.HasOngoingEvent);
    
                    if (Room.Event != null)
                    {
                        Message.AppendStringWithBreak(Room.Event.Name);
                        Message.AppendStringWithBreak(Room.Event.Description);
                        Message.AppendInt32(Room.Event.Tags.Count);
    
                        lock (Room.Event.Tags)
                        {
                            foreach (string Tag in Room.Event.Tags)
                            {
                                Message.AppendStringWithBreak(Tag);
                            }
                        }
                    }
                }
                else
                {
                    Message.AppendBoolean(false);
                }
    
                return Message;
            }
    
            #endregion
    
            #region User Moderation
    
            public void KickUser(GameClient ModSession, uint UserId, String Message, Boolean Soft)
            {
                GameClient Client = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(UserId);
    
                if (Client == null || Client.GetHabbo().CurrentRoomId < 1 || Client.GetHabbo().Id == ModSession.GetHabbo().Id)
                {
                    return;
                }
    
                if (Client.GetHabbo().Rank >= ModSession.GetHabbo().Rank)
                {
                    ModSession.SendNotif("You do not have permission to kick that user.");
                    return;
                }
    
                Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Client.GetHabbo().CurrentRoomId);
    
                if (Room == null)
                {
                    return;
                }
    
                Room.RemoveUserFromRoom(Client, true, false);
    
                if (!Soft)
                {
                    Client.SendNotif(Message);
    
                    using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                    {
                        dbClient.ExecuteQuery("UPDATE user_info SET cautions = cautions + 1 WHERE user_id = '" + UserId + "' LIMIT 1");
                    }
                }
            }
    
            public void AlertUser(GameClient ModSession, uint UserId, String Message, Boolean Caution)
            {
                GameClient Client = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(UserId);
    
                if (Client == null || Client.GetHabbo().Id == ModSession.GetHabbo().Id)
                {
                    return;
                }
    
                if (Caution && Client.GetHabbo().Rank >= ModSession.GetHabbo().Rank)
                {
                    ModSession.SendNotif("You do not have permission to caution that user, sending as a regular message instead.");
                    Caution = false;
                }
    
                Client.SendNotif(Message, Caution);
    
                if (Caution)
                {
                    using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                    {
                        dbClient.ExecuteQuery("UPDATE user_info SET cautions = cautions + 1 WHERE user_id = '" + UserId + "' LIMIT 1");
                    }
                }
            }
    
            public void BanUser(GameClient ModSession, uint UserId, int Length, String Message)
            {
                GameClient Client = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(UserId);
    
                if (Client == null || Client.GetHabbo().Id == ModSession.GetHabbo().Id)
                {
                    return;
                }
    
                if (Client.GetHabbo().Rank >= ModSession.GetHabbo().Rank)
                {
                    ModSession.SendNotif("You do not have permission to ban that user.");
                    return;
                }
    
                Double dLength = Length;
    
                UberEnvironment.GetGame().GetBanManager().BanUser(Client, ModSession.GetHabbo().Username, dLength, Message, false);
            }
    
            #endregion
    
            #region User Info
    
            public ServerMessage SerializeUserInfo(uint UserId)
            {
                DataRow User = null;
                DataRow Info = null;
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    User = dbClient.ReadDataRow("SELECT * FROM users WHERE id = '" + UserId + "' LIMIT 1");
                    Info = dbClient.ReadDataRow("SELECT * FROM user_info WHERE user_id = '" + UserId + "' LIMIT 1");
                }
    
                if (User == null)
                {
                    throw new ArgumentException();
                }
    
                ServerMessage Message = new ServerMessage(533);
    
                Message.AppendUInt((uint)User["id"]);
                Message.AppendStringWithBreak((string)User["username"]);
    
                if (Info != null)
                {
                    Message.AppendInt32((int)Math.Ceiling((UberEnvironment.GetUnixTimestamp() - (Double)Info["reg_timestamp"]) / 60)); 
                    Message.AppendInt32((int)Math.Ceiling((UberEnvironment.GetUnixTimestamp() - (Double)Info["login_timestamp"]) / 60));
                }
                else
                {
                    Message.AppendInt32(0);
                    Message.AppendInt32(0);
                }
    
                if (User["online"].ToString() == "1")
                {
                    Message.AppendBoolean(true);
                }
                else
                {
                    Message.AppendBoolean(false);
                }
    
                if (Info != null)
                {
                    Message.AppendInt32((int)Info["cfhs"]);
                    Message.AppendInt32((int)Info["cfhs_abusive"]);
                    Message.AppendInt32((int)Info["cautions"]);
                    Message.AppendInt32((int)Info["bans"]); 
                }
                else
                {
                    Message.AppendInt32(0); // cfhs
                    Message.AppendInt32(0); // abusive cfhs
                    Message.AppendInt32(0); // cautions
                    Message.AppendInt32(0); // bans
                }
    
                return Message;
            }
    
            public ServerMessage SerializeRoomVisits(uint UserId)
            {
                DataTable Data = null;
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    Data = dbClient.ReadDataTable("SELECT room_id,hour,minute FROM user_roomvisits WHERE user_id = '" + UserId + "' ORDER BY entry_timestamp DESC LIMIT 50");
                }
    
                ServerMessage Message = new ServerMessage(537);
                Message.AppendUInt(UserId);
                Message.AppendStringWithBreak(UberEnvironment.GetGame().GetClientManager().GetNameById(UserId));
    
                if (Data != null)
                {
                    Message.AppendInt32(Data.Rows.Count);
    
                    foreach (DataRow Row in Data.Rows)
                    {
                        RoomData RoomData = UberEnvironment.GetGame().GetRoomManager().GenerateNullableRoomData((uint)Row["room_id"]);
    
                        Message.AppendBoolean(RoomData.IsPublicRoom);
                        Message.AppendUInt(RoomData.Id);
                        Message.AppendStringWithBreak(RoomData.Name);
                        Message.AppendInt32((int)Row["hour"]);
                        Message.AppendInt32((int)Row["minute"]);
                    }
                }
                else
                {
                    Message.AppendInt32(0);
                }
    
                return Message;
            }
    
            #endregion
    
            #region Chatlogs
    
            public ServerMessage SerializeUserChatlog(uint UserId)
            {
                DataTable Visits = null;
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    Visits = dbClient.ReadDataTable("SELECT room_id,entry_timestamp,exit_timestamp FROM user_roomvisits WHERE user_id = '" + UserId  + "' ORDER BY entry_timestamp DESC LIMIT 5");
                }
    
                ServerMessage Message = new ServerMessage(536);
                Message.AppendUInt(UserId);
                Message.AppendStringWithBreak(UberEnvironment.GetGame().GetClientManager().GetNameById(UserId));
    
                if (Visits != null)
                {
                    Message.AppendInt32(Visits.Rows.Count);
    
                    foreach (DataRow Visit in Visits.Rows)
                    {
                        DataTable Chatlogs = null;
    
                        if ((Double)Visit["exit_timestamp"] <= 0.0)
                        {
                            Visit["exit_timestamp"] = UberEnvironment.GetUnixTimestamp();
                        }
    
                        using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                        {
                            Chatlogs = dbClient.ReadDataTable("SELECT user_id,user_name,hour,minute,message FROM chatlogs WHERE room_id = '" + (uint)Visit["room_id"] + "' AND timestamp > '" + (Double)Visit["entry_timestamp"] + "' AND timestamp < '" + (Double)Visit["exit_timestamp"] + "' ORDER BY timestamp DESC");
                        }
    
                        RoomData RoomData = UberEnvironment.GetGame().GetRoomManager().GenerateNullableRoomData((uint)Visit["room_id"]);
    
                        Message.AppendBoolean(RoomData.IsPublicRoom);
                        Message.AppendUInt(RoomData.Id);
                        Message.AppendStringWithBreak(RoomData.Name);
    
                        if (Chatlogs != null)
                        {
                            Message.AppendInt32(Chatlogs.Rows.Count);
    
                            foreach (DataRow Log in Chatlogs.Rows)
                            {
                                Message.AppendInt32((int)Log["hour"]);
                                Message.AppendInt32((int)Log["minute"]);
                                Message.AppendUInt((uint)Log["user_id"]);
                                Message.AppendStringWithBreak((string)Log["user_name"]);
                                Message.AppendStringWithBreak((string)Log["message"]);
                            }
                        }
                        else
                        {
                            Message.AppendInt32(0);
                        }
                    }
                }
                else
                {
                    Message.AppendInt32(0);
                }
    
                return Message;
            }
    
            public ServerMessage SerializeTicketChatlog(SupportTicket Ticket, RoomData RoomData, Double Timestamp)
            {
                DataTable Data = null;
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    Data = dbClient.ReadDataTable("SELECT user_id,user_name,hour,minute,message FROM chatlogs WHERE room_id = '" + RoomData.Id + "' AND timestamp >= '" + (Timestamp - 300) + "' AND timestamp <= '" + Timestamp + "' ORDER BY timestamp DESC");
                }
    
                ServerMessage Message = new ServerMessage(534);
                Message.AppendUInt(Ticket.TicketId);
                Message.AppendUInt(Ticket.SenderId);
                Message.AppendUInt(Ticket.ReportedId);
                Message.AppendBoolean(RoomData.IsPublicRoom);
                Message.AppendUInt(RoomData.Id);
                Message.AppendStringWithBreak(RoomData.Name);
    
                if (Data != null)
                {
                    Message.AppendInt32(Data.Rows.Count);
    
                    foreach (DataRow Row in Data.Rows)
                    {
                        Message.AppendInt32((int)Row["hour"]);
                        Message.AppendInt32((int)Row["minute"]);
                        Message.AppendUInt((uint)Row["user_id"]);
                        Message.AppendStringWithBreak((String)Row["user_name"]);
                        Message.AppendStringWithBreak((String)Row["message"]);
                    }
                }
                else
                {
                    Message.AppendInt32(0);
                }
    
                return Message;
            }
    
            public ServerMessage SerializeRoomChatlog(uint RoomId)
            {
                Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(RoomId);
    
                if (Room == null)
                {
                    throw new ArgumentException();
                }
    
                Boolean IsPublic = false;
    
                if (Room.Type.ToLower() == "public")
                {
                    IsPublic = true;
                }
    
                DataTable Data = null;
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    Data = dbClient.ReadDataTable("SELECT user_id,user_name,hour,minute,message FROM chatlogs WHERE room_id = '" + Room.RoomId + "' ORDER BY timestamp DESC LIMIT 150");
                }
    
                ServerMessage Message = new ServerMessage(535);
                Message.AppendBoolean(IsPublic);
                Message.AppendUInt(Room.RoomId);
                Message.AppendStringWithBreak(Room.Name);
    
                if (Data != null)
                {
                    Message.AppendInt32(Data.Rows.Count);
    
                    foreach (DataRow Row in Data.Rows)
                    {
                        Message.AppendInt32((int)Row["hour"]);
                        Message.AppendInt32((int)Row["minute"]);
                        Message.AppendUInt((uint)Row["user_id"]);
                        Message.AppendStringWithBreak((string)Row["user_name"]);
                        Message.AppendStringWithBreak((string)Row["message"]);
                    }
                }
                else
                {
                    Message.AppendInt32(0);
                }
    
                return Message;
            }
    
            #endregion
        }
    }
    Last edited by MDK; 09-07-10 at 10:14 PM.

  6. #6
    prjRev.com Kryptos is offline
    MemberRank
    Feb 2010 Join Date
    Planet EarthLocation
    579Posts

    config [Development] Official uberEmulator Development Thread [C#, R49+, MySQL]

    uberEmulator - Pets


    Pet.cs 100%

    Spoiler:

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    
    using Uber.HabboHotel.Rooms;
    using Uber.Messages;
    using Uber.Storage;
    
    namespace Uber.HabboHotel.Pets
    {
        class Pet
        {
            public uint PetId;
            public uint OwnerId;
            public int VirtualId;
    
            public uint Type;
            public string Name;
            public string Race;
            public string Color;
    
            public int Expirience;
            public int Energy;
            public int Nutrition;
    
            public uint RoomId;
            public int X;
            public int Y;
            public double Z;
    
            public int Respect;
    
            public double CreationStamp;
            public bool PlacedInRoom;
    
            public int[] experienceLevels = new int[] { 100, 200, 400, 600, 1000, 1300, 1800, 2400, 3200, 4300, 7200, 8500, 10100, 13300, 17500, 23000, 51900 }; // ty scott
    
            public Room Room
            {
                get
                {
                    if (!IsInRoom)
                    {
                        return null;
                    }
    
                    return UberEnvironment.GetGame().GetRoomManager().GetRoom(RoomId);
                }
            }
    
            public bool IsInRoom
            {
                get
                {
                    return (RoomId > 0);
                }
            }
    
            public int Level
            {
                get
                {
                    for (int level = 0; level < experienceLevels.Length; ++level)
                    {
                        if (Expirience < experienceLevels[level])
                            return level + 1;
                    }
                    return experienceLevels.Length + 1;
                }
            }
    
            public int MaxLevel
            {
                get
                {
                    return 20;
                }
            }
    
            public int ExpirienceGoal
            {
                get
                {
                    return experienceLevels[Level - 1];
                }
            }
    
            public int MaxEnergy
            {
                get
                {
                    return 100;
                }
            }
    
            public int MaxNutrition
            {
                get
                {
                    return 150;
                }
            }
    
            public int Age
            {
                get
                {
                    return (int)Math.Floor((UberEnvironment.GetUnixTimestamp() - CreationStamp) / 86400);
                }
            }
    
            public string Look
            {
                get
                {
                    return Type + " " + Race + " " + Color;
                }
            }
    
            public string OwnerName
            {
                get
                {
                    return UberEnvironment.GetGame().GetClientManager().GetNameById(OwnerId);
                }
            }
    
    
            public Pet(uint PetId, uint OwnerId, uint RoomId, string Name, uint Type, string Race, string Color, int Expirience, int Energy, int Nutrition, int Respect, double CreationStamp, int X, int Y, double Z)
            {
                this.PetId = PetId;
                this.OwnerId = OwnerId;
                this.RoomId = RoomId;
                this.Name = Name;
                this.Type = Type;
                this.Race = Race;
                this.Color = Color;
                this.Expirience = Expirience;
                this.Energy = Energy;
                this.Nutrition = Nutrition;
                this.Respect = Respect;
                this.CreationStamp = CreationStamp;
                this.X = X;
                this.Y = Y;
                this.Z = Z;
                this.PlacedInRoom = false;
            }
    
            public void OnRespect()
            {
                Respect++;
    
                ServerMessage Message = new ServerMessage(440);
                Message.AppendUInt(PetId);
                Message.AppendInt32(Expirience + 10);
                Room.SendMessage(Message);
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    dbClient.AddParamWithValue("petid", PetId);
                    dbClient.ExecuteQuery("UPDATE user_pets SET respect = respect + 1 WHERE id = @petid LIMIT 1");
                }
    
                if (Expirience <= 51900)
                {
                    AddExpirience(10);
                }
            }
    
            public void AddExpirience(int Amount)
            {
                Expirience = Expirience + Amount;
    
                if (Expirience >= 51900)
                {
                    return;
                }
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    dbClient.AddParamWithValue("petid", PetId);
                    dbClient.AddParamWithValue("expirience", Expirience);
                    dbClient.ExecuteQuery("UPDATE user_pets SET expirience = @expirience WHERE id = @petid LIMIT 1");
                }
    
                if (Room != null)
                {
                    ServerMessage Message = new ServerMessage(609);
                    Message.AppendUInt(PetId);
                    Message.AppendInt32(VirtualId);
                    Message.AppendInt32(Amount);
                    Room.SendMessage(Message);
    
                    if (Expirience > ExpirienceGoal)
                    {
                        // Level the pet
    
                        ServerMessage ChatMessage = new ServerMessage(24);
                        ChatMessage.AppendInt32(VirtualId);
                        ChatMessage.AppendStringWithBreak("*leveled up to level " + Level + " *");
                        ChatMessage.AppendInt32(0);
    
                        Room.SendMessage(ChatMessage);
                    }
                }
    
            }
    
            public void PetEnergy(bool Add)
            {
                int MaxE;
    
                if (Add)
                {
                    if (this.Energy == 100) // If Energy is 100, no point.
                        return;
    
                    if (this.Energy > 85) { MaxE = this.MaxEnergy - this.Energy; } else { MaxE = 10; }
    
                }
                else { MaxE = 15; } // Remove Max Energy as 15
    
                int r = UberEnvironment.GetRandomNumber(4, MaxE);
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    if (!Add)
                    {
                        this.Energy = this.Energy - r;
    
                        if (this.Energy < 0)
                        {
                            dbClient.AddParamWithValue("pid", PetId);
                            dbClient.ExecuteQuery("UPDATE user_pets SET energy = 1 WHERE id = @pid LIMIT 1");
    
                            this.Energy = 1;
    
                            r = 1;
                        }
    
                        dbClient.AddParamWithValue("r", r);
                        dbClient.AddParamWithValue("petid", PetId);
                        dbClient.ExecuteQuery("UPDATE user_pets SET energy = energy - @r WHERE id = @petid LIMIT 1");
    
                    } else {
                        dbClient.AddParamWithValue("r", r);
                        dbClient.AddParamWithValue("petid", PetId);
                        dbClient.ExecuteQuery("UPDATE user_pets SET energy = energy + @r WHERE id = @petid LIMIT 1");
    
                        this.Energy = this.Energy + r;
                    }
                }
            }
    
            public void PetNutrition(bool Add)
            {
                int MaxN;
    
                if (Add)
                {
                    if (this.Nutrition == 150) // If Nutrition is 150, no point.
                        return;
    
                    if (this.Nutrition > 125) { MaxN = this.MaxNutrition - this.Nutrition; } else { MaxN = 10; }
    
                }
                else { MaxN = 15; } // Remove Max Nutrition as 15
    
                int r = UberEnvironment.GetRandomNumber(5, 50);
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    if (!Add)
                    {
                        this.Nutrition = this.Nutrition - r;
    
                        if (this.Nutrition < 0)
                        {
                            dbClient.AddParamWithValue("pid", PetId);
                            dbClient.ExecuteQuery("UPDATE user_pets SET nutrition = 1 WHERE id = @pid LIMIT 1");
    
                            this.Nutrition = 1;
    
                            r = 1;
                        }
    
                        dbClient.AddParamWithValue("r", r);
                        dbClient.AddParamWithValue("petid", PetId);
                        dbClient.ExecuteQuery("UPDATE user_pets SET nutrition = nutrition - @r WHERE id = @petid LIMIT 1");
    
                    }
                    else
                    {
                        dbClient.AddParamWithValue("r", r);
                        dbClient.AddParamWithValue("petid", PetId);
                        dbClient.ExecuteQuery("UPDATE user_pets SET nutrition = nutrition + @r WHERE id = @petid LIMIT 1");
    
                        this.Nutrition = this.Nutrition + r;
                    }
                }
            }
    
            public void SerializeInventory(ServerMessage Message)
            {
                Message.AppendUInt(PetId);
                Message.AppendStringWithBreak(Name);
                Message.AppendStringWithBreak(Look);
                Message.AppendBoolean(false);
            }
    
            public ServerMessage SerializeInfo()
            {
                // IYbtmFZoefKPEY]AXdAPhPhHPh0 008 D98961SBhRPZA[lFmybad
                ServerMessage Nfo = new ServerMessage(601);
                Nfo.AppendUInt(PetId);
                Nfo.AppendStringWithBreak(Name);
                Nfo.AppendInt32(Level);
                Nfo.AppendInt32(MaxLevel);
                Nfo.AppendInt32(Expirience);
                Nfo.AppendInt32(ExpirienceGoal);
                Nfo.AppendInt32(Energy);
                Nfo.AppendInt32(MaxEnergy);
                Nfo.AppendInt32(Nutrition);
                Nfo.AppendInt32(MaxNutrition);
                Nfo.AppendStringWithBreak(Look);
                Nfo.AppendInt32(Respect);
                Nfo.AppendUInt(OwnerId);
                Nfo.AppendInt32(Age);
                Nfo.AppendStringWithBreak(OwnerName);
                return Nfo;
            }
        }
    }

    Credits to Meth0d, Shorty and like a 2% me for adding Nutrition.

    Hey, here's my petbot.cs with Almost all commands. No errors.
    Tested by Vista4Life.
    Put this as your Petbot.cs
    Spoiler:

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    using Uber.Messages;
    
    using Uber.HabboHotel.Rooms;
    using Uber.HabboHotel.Pathfinding;
    
    namespace Uber.HabboHotel.RoomBots
    {
        class PetBot : BotAI
        {
            private int SpeechTimer;
            private int ActionTimer;
            private int EnergyTimer;
    
            // TO-DO: This needs cleaning up BADLY, If anyone wants to attempt cleaning up my mess, go for it (Y) (Pets 100% done - Kryptos)
            // All credits go to Kryptos || Meth0d || Shorty.
    
            public PetBot(int VirtualId)
            {
                this.SpeechTimer = new Random((VirtualId ^ 2) + DateTime.Now.Millisecond).Next(10, 60);
                this.ActionTimer = new Random((VirtualId ^ 2) + DateTime.Now.Millisecond).Next(10, 30 + VirtualId);
                this.EnergyTimer = new Random((VirtualId ^ 2) + DateTime.Now.Millisecond).Next(10, 60);
            }
    
            private void RemovePetStatus()
            {
                RoomUser Pet = GetRoomUser();
    
                // Remove Status
                Pet.Statusses.Remove("sit");
                Pet.Statusses.Remove("lay");
                Pet.Statusses.Remove("snf");
                Pet.Statusses.Remove("eat");
                Pet.Statusses.Remove("ded");
                Pet.Statusses.Remove("jmp");
                Pet.Statusses.Remove("ply"); 
            }
    
            public override void OnSelfEnterRoom()
            {
                int randomX = UberEnvironment.GetRandomNumber(0, GetRoom().Model.MapSizeX);
                int randomY = UberEnvironment.GetRandomNumber(0, GetRoom().Model.MapSizeY);
                GetRoomUser().MoveTo(randomX, randomY);
            }
    
            public override void OnSelfLeaveRoom(bool Kicked) { }
    
            public override void OnUserEnterRoom(Rooms.RoomUser User)
            {
                if (User.GetClient().GetHabbo().Username.ToLower() == GetRoomUser().PetData.OwnerName.ToLower())
                {
                    GetRoomUser().Chat(null, "*drools over master*", false);
                }
            }
    
            public override void OnUserLeaveRoom(GameClients.GameClient Client) { }
    
            #region Commands
            public override void OnUserSay(Rooms.RoomUser User, string Message)
            {
                RoomUser Pet = GetRoomUser();
    
                if (Message.ToLower().Equals(Pet.PetData.Name.ToLower()))
                {
                    Pet.SetRot(Rotation.Calculate(Pet.X, Pet.Y, User.X, User.Y));
                    return;
                }
    
                if (Message.ToLower().StartsWith(Pet.PetData.Name.ToLower() + " ") && User.GetClient().GetHabbo().Username.ToLower() == GetRoomUser().PetData.OwnerName.ToLower())
                {
                    string Command = Message.Substring(Pet.PetData.Name.ToLower().Length + 1);
    
                    int r = UberEnvironment.GetRandomNumber(1, 8); // Made Random
    
                    if (Pet.PetData.Energy > 10 && r < 6 || Pet.PetData.Level > 15)
                    {
                        RemovePetStatus(); // Remove Status
    
                        switch (Command)
                        {
                            // TODO - Level you can use the commands at... Done - Kryptos
    
                            #region free
                            case "free":
                                if (Pet.PetData.Level >= 1)
                                RemovePetStatus();
    
                                int randomX = UberEnvironment.GetRandomNumber(0, GetRoom().Model.MapSizeX);
                                int randomY = UberEnvironment.GetRandomNumber(0, GetRoom().Model.MapSizeY);
    
                                Pet.MoveTo(randomX, randomY);
    
                                Pet.PetData.AddExpirience(10); // Give XP
    
                                break;
                            #endregion
    
                            #region here
                            case "come":
                            case "here":
                                if (Pet.PetData.Level > 1)
                                RemovePetStatus();
    
                                int NewX = User.X;
                                int NewY = User.Y;
    
                                ActionTimer = 30; // Reset ActionTimer
    
                                #region Rotation
                                if (User.RotBody == 4)
                                {
                                    NewY = User.Y + 1;
                                }
                                else if (User.RotBody == 0)
                                {
                                    NewY = User.Y - 1;
                                }
                                else if (User.RotBody == 6)
                                {
                                    NewX = User.X - 1;
                                }
                                else if (User.RotBody == 2)
                                {
                                    NewX = User.X + 1;
                                }
                                else if (User.RotBody == 3)
                                {
                                    NewX = User.X + 1;
                                    NewY = User.Y + 1;
                                }
                                else if (User.RotBody == 1)
                                {
                                    NewX = User.X + 1;
                                    NewY = User.Y - 1;
                                }
                                else if (User.RotBody == 7)
                                {
                                    NewX = User.X - 1;
                                    NewY = User.Y - 1;
                                }
                                else if (User.RotBody == 5)
                                {
                                    NewX = User.X - 1;
                                    NewY = User.Y + 1;
                                }
                                #endregion
    
                                Pet.PetData.AddExpirience(20); // Give XP
    
                                Pet.MoveTo(NewX, NewY);
                                break;
                            #endregion
    
                            #region sit
                            case "sit":
                                if (Pet.PetData.Level >= 1)
                                // Remove Status
                                RemovePetStatus();
    
                                Pet.PetData.AddExpirience(10); // Give XP
    
                                // Add Status
                                Pet.Statusses.Add("sit", Pet.Z.ToString());
                                ActionTimer = 25;
                                EnergyTimer = 10;
                                break;
                            #endregion
    
                            #region lay
                            case "lay":
                            case "down":
                                if (Pet.PetData.Level >= 1)
                                // Remove Status
                                RemovePetStatus();
    
                                // Add Status
                                Pet.Statusses.Add("lay", Pet.Z.ToString());
    
                                Pet.PetData.AddExpirience(10); // Give XP
    
                                ActionTimer = 30;
                                EnergyTimer = 5;
                                break;
                            #endregion
    
                            #region dead
                            case "play dead":
                            case "dead":
                                if (Pet.PetData.Level >= 1)
                                // Remove Status
                                RemovePetStatus();
    
                                // Add Status   
                                Pet.Statusses.Add("ded", Pet.Z.ToString());
    
                                Pet.PetData.AddExpirience(20); // Give XP
    
                                // Don't move to speak for a set amount of time.
                                SpeechTimer = 45;
                                ActionTimer = 30;
    
                                break;
                            #endregion
    
                            #region sleep
                            case "sleep":
                                if (Pet.PetData.Level >= 1)
                                // Remove Status
                                RemovePetStatus();
    
                                Pet.Chat(null, "ZzzZZZzzzzZzz", false);
                                Pet.Statusses.Add("lay", Pet.Z.ToString());
    
                                Pet.PetData.AddExpirience(10); // Give XP
    
                                // Don't move to speak for a set amount of time.
                                EnergyTimer = 5;
                                SpeechTimer = 30;
                                ActionTimer = 45;
                                break;
                            #endregion
    
                            #region jump
                            case "jump":
                                if (Pet.PetData.Level >= 1)
                                // Remove Status
                                RemovePetStatus();
    
                                // Add Status   
                                Pet.Statusses.Add("jmp", Pet.Z.ToString());
    
                                Pet.PetData.AddExpirience(10); // Give XP
    
                                // Don't move to speak for a set amount of time.
                                EnergyTimer = 5;
                                SpeechTimer = 10;
                                ActionTimer = 5;
                                break;
                            #endregion
    
                            #region Silent
                            case "silent":
                                if (Pet.PetData.Level >= 1)
                                //Remove Status
                                RemovePetStatus();
    
                                Pet.PetData.AddExperience(10); //Give XP
    
                                // Don't move to speak for a set amount of time.
                                SpeechTimer = 60;  
                            #endregion
    
                            #region beg
                            case "beg":
                                if (Pet.PetData.Level >=1)
                                //Remove Status
                                RemovePetStatus();
                                //Add Status
                                Pet.Statusses.Add("beg", Pet.Z.ToString());
                                ActionTimer = 25;
                                EnergyTimer = 10;
                                Pet.PetData.AddExperience(10);
                                break;
                            #endregion
    
                            #region stand
                            case "stand":
                                if (Pet.PetData.Level >= 1)
                                //Add Status
                                Pet.Statusses.Remove("sit", Pet.Z.ToString());
                                
                                Pet.PetData.AddExperience(10);
                                break;
                                #endregion
    
                            #region speak
                            case "speak":
                                if (Pet.PetData.Level >= 1)
                               //Remove Status
                                RemovePetStatus();
    
                               if (Pet.PetData.Type == 0 || Pet.PetData.Type == 3)
                               {
                                   GetRoomUser().Chat(null, "Woof! Woof", false);
                               }
                               else if (Pet.PetData.Type == 1)
                               {
                                   GetRoomUser().Chat(null, "meow...meOW", false);
                               }
                               else if (Pet.PetData.Type == 2)
                               {
                                   GetRoomUser().Chat(null, "Rrrr....Grrrrrg....", false);
                               }
                               else if (Pet.PetData.Type == 3)
                                {
                                    GetRoomUser().Chat(null, "woooooooof", false);
                                }
                               else if (Pet.PetData.Type == 4)
                               {
                                   GetRoomUser.Chat(null, "Rawrrr!", false);
                               }
                               else if (Pet.PetData.Type == 5)
                                {
                                    GetRoomUser().Chat(null, "Oink Oink..", false);
                                }
                               break;
                            #endregion
    
                            #region follow
                            case "follow": 
                                if (Pet.PetData.Level >= 1)
                                RemovePetStatus();
    
                                int NewX = User.X;
                                int NewY = User.Y;
    
                                ActionTimer = 30; // Reset ActionTimer
    
                                #region Rotation
                                if (User.RotBody == 4)
                                {
                                    NewY = User.Y - 1;
                                }
                                else if (User.RotBody == 0)
                                {
                                    NewY = User.Y + 1;
                                }
                                else if (User.RotBody == 6)
                                {
                                    NewX = User.X + 1;
                                }
                                else if (User.RotBody == 2)
                                {
                                    NewX = User.X + 1;
                                }
                                else if (User.RotBody == 3)
                                {
                                    NewX = User.X - 1;
                                    NewY = User.Y - 1;
                                }
                                else if (User.RotBody == 1)
                                {
                                    NewX = User.X - 1;
                                    NewY = User.Y + 1;
                                }
                                else if (User.RotBody == 7)
                                {
                                    NewX = User.X + 1;
                                    NewY = User.Y + 1;
                                }
                                else if (User.RotBody == 5)
                                {
                                    NewX = User.X + 1;
                                    NewY = User.Y - 1;
                                }
                                #endregion
    
                                Pet.PetData.AddExpirience(20); // Give XP
    
                                Pet.MoveTo(NewX, NewY);
                                
                                break;
                            #endregion
    
                            #region follow left
                            case "follow left":
                                if (Pet.PetData.Level >= 1)
                                RemovePetStatus();
    
                                int NewX = User.X;
                                int NewY = User.Y;
    
                                ActionTimer = 30; // Reset ActionTimer
    
                                #region Rotation
                                if (User.RotBody == 4)
                                {
                                    NewY = User.X + 1;
                                }
                                else if (User.RotBody == 0)
                                {
                                    NewY = User.X - 1;
                                }
                                else if (User.RotBody == 6)
                                {
                                    NewX = User.Y - 1;
                                }
                                else if (User.RotBody == 2)
                                {
                                    NewX = User.Y + 1;
                                }
                                else if (User.RotBody == 3)
                                {
                                    NewX = User.Y + 1;
                                    NewY = User.X + 1;
                                }
                                else if (User.RotBody == 1)
                                {
                                    NewX = User.Y + 1;
                                    NewY = User.X - 1;
                                }
                                else if (User.RotBody == 7)
                                {
                                    NewX = User.Y - 1;
                                    NewY = User.X - 1;
                                }
                                else if (User.RotBody == 5)
                                {
                                    NewX = User.Y - 1;
                                    NewY = User.X + 1;
                                }
                                #endregion
    
                                Pet.PetData.AddExpirience(20); // Give Xp
                             
                                Pet.MoveTo(NewX, NewY);
                                
                                break;
                            #endregion
    
                            #region follow right
                            case "follow right":
                                if (Pet.PetData.Level >= 1)
                                 RemovePetStatus();
    
                                int NewX = User.X;
                                int NewY = User.Y;
    
                                ActionTimer = 30; // Reset ActionTimer
    
                                #region Rotation
                                if (User.RotBody == 4)
                                {
                                    NewY = User.X - 1;
                                }
                                else if (User.RotBody == 0)
                                {
                                    NewY = User.X + 1;
                                }
                                else if (User.RotBody == 6)
                                {
                                    NewX = User.Y + 1;
                                }
                                else if (User.RotBody == 2)
                                {
                                    NewX = User.Y + 1;
                                }
                                else if (User.RotBody == 3)
                                {
                                    NewX = User.Y - 1;
                                    NewY = User.X - 1;
                                }
                                else if (User.RotBody == 1)
                                {
                                    NewX = User.Y - 1;
                                    NewY = User.X + 1;
                                }
                                else if (User.RotBody == 7)
                                {
                                    NewX = User.X + 1;
                                    NewY = User.Y + 1;
                                }
                                else if (User.RotBody == 5)
                                {
                                    NewX = User.Y + 1;
                                    NewY = User.X - 1;
                                }
                                #endregion
    
                                Pet.PetData.AddExpirience(20); // Give XP
                             
                                Pet.MoveTo(NewX, NewY);
                                
                                break;
                            #endregion
    
                            default:
                                string[] Speech = { "*confused*", "What?", "Huh?", "What is that?", "hmm..?" };
    
                                Random RandomSpeech = new Random();
                                Pet.Chat(null, Speech[RandomSpeech.Next(0, Speech.Length - 1)], false);
                                break;
                        }
                        Pet.PetData.PetEnergy(false); // Remove Energy
                        Pet.PetData.PetEnergy(false); // Remove Energy
                        Pet.PetData.PetNutrition(true); // Remove Nutrition
                        Pet.PetData.PetNutrition(true); // Remove Nutrition
                    }
                    else
                    {
    
                        RemovePetStatus(); // Remove Status
    
                        if (Pet.PetData.Energy < 10)
                        {
                            string[] Speech = { "ZzZzzzzz", "*sleeps*", "Tired... *sleeps*", "ZzZzZZzzzZZz", "zzZzzZzzz", "... Yawnn ..", "ZzZzzZ" };
    
                            Random RandomSpeech = new Random();
                            Pet.Chat(null, Speech[RandomSpeech.Next(0, Speech.Length - 1)], false);
    
                            Pet.Statusses.Add("lay", Pet.Z.ToString());
    
                            SpeechTimer = 50;
                            ActionTimer = 45;
                            EnergyTimer = 5;
    
                        }
                        else
                        {
    
                            string[] Speech = { "*sigh*", "*refuses*", " ... ", "Who do you think you are?", "you do it", "Grr!", "*laughs*", "Why?" };
    
                            Random RandomSpeech = new Random();
                            Pet.Chat(null, Speech[RandomSpeech.Next(0, Speech.Length - 1)], false);
    
                            Pet.PetData.PetEnergy(false); // Remove Energy
                            Pet.PetData.PetNutrition(true); // Add Nutrition
                        }
                    }
                }
                Pet = null;
            }
            #endregion
    
            public override void OnUserShout(Rooms.RoomUser User, string Message) { }
    
            public override void OnTimerTick()
            {
                #region Speech
                if (SpeechTimer <= 0)
                {
                    RoomUser Pet = GetRoomUser();
    
                    if (Pet != null)
                    {
                        Random RandomSpeech = new Random();
                        RemovePetStatus();
    
                        if (Pet.PetData.Type == 0 || Pet.PetData.Type == 3) // Dog & Terrier
                        {
                            string[] Speech = { "woof woof woof!!!", "hooooowl", "wooooof!", "Woof Woof!", "sit", "lay", "snf", "Woof" };
    
                            string rSpeech = Speech[RandomSpeech.Next(0, Speech.Length - 1)];
    
                            if (rSpeech.Length != 3)
                            {
                                Pet.Chat(null, rSpeech, false);
                            }
                            else
                            {
                                Pet.Statusses.Add(rSpeech, Pet.Z.ToString());
                            }
    
                        }
                        else if (Pet.PetData.Type == 1)
                        { // Cat
    
                            string[] Speech = { "meow", "meow...meOW", "muew..muew", "lay", "sit", "lay" };
    
                            string rSpeech = Speech[RandomSpeech.Next(0, Speech.Length - 1)];
    
                            if (rSpeech.Length != 3)
                            {
                                Pet.Chat(null, rSpeech, false);
                            }
                            else
                            {
                                Pet.Statusses.Add(rSpeech, Pet.Z.ToString());
                            }
    
                        }
                        else if (Pet.PetData.Type == 2)
                        { // Crocodile
    
                            string[] Speech = { "Rrrr....Grrrrrg....", "*Mellow*", "Tick tock tick....", "*feels like eating my owner*", "Nom Nom Nom", ".. Yawwnn!", "snf" };
    
                            string rSpeech = Speech[RandomSpeech.Next(0, Speech.Length - 1)];
    
                            if (rSpeech.Length != 3)
                            {
                                Pet.Chat(null, rSpeech, false);
                            }
                            else
                            {
                                Pet.Statusses.Add(rSpeech, Pet.Z.ToString());
                            }
    
                        }
                        else if (Pet.PetData.Type == 4)
                        { // Bear
    
                            string[] Speech = { "*pack of fresh salmon please*", "Rawrrr!", "*sniff sniff*", "Yawnnnn..", "Rawr! ... Rawrrrrr?", "snf" };
    
                            string rSpeech = Speech[RandomSpeech.Next(0, Speech.Length - 1)];
    
                            if (rSpeech.Length != 3)
                            {
                                Pet.Chat(null, rSpeech, false);
                            }
                            else
                            {
                                Pet.Statusses.Add(rSpeech, Pet.Z.ToString());
                            }
    
                        }
                        else if (Pet.PetData.Type == 5)
                        { // Pig
    
                            string[] Speech = { "Oink Oink..", "*Mellow*", "Sniff... Sniff..", "snf", "Oink!", "snf", "lay", "oink" };
    
                            string rSpeech = Speech[RandomSpeech.Next(0, Speech.Length - 1)];
    
                            if (rSpeech.Length != 3)
                            {
                                Pet.Chat(null, rSpeech, false);
                            }
                            else
                            {
                                Pet.Statusses.Add(rSpeech, Pet.Z.ToString());
                            }
    
                        }
                        Pet = null;
                    }
                    SpeechTimer = UberEnvironment.GetRandomNumber(20, 120);
                }
                else
                {
                    SpeechTimer--;
                }
                #endregion
    
                if (ActionTimer <= 0)
                {
                    // Remove Status
                    RemovePetStatus();
    
                    int randomX = UberEnvironment.GetRandomNumber(0, GetRoom().Model.MapSizeX);
                    int randomY = UberEnvironment.GetRandomNumber(0, GetRoom().Model.MapSizeY);
                    GetRoomUser().MoveTo(randomX, randomY);
    
                    ActionTimer = UberEnvironment.GetRandomNumber(15, 40 + GetRoomUser().PetData.VirtualId);
                }
                else
                {
                    ActionTimer--;
                }
    
                if (EnergyTimer <= 0)
                {
                    RemovePetStatus(); // Remove Status
    
                    RoomUser Pet = GetRoomUser();
    
                    Pet.PetData.PetEnergy(true); // Add Energy
    
                    EnergyTimer = UberEnvironment.GetRandomNumber(30, 120); // 2 Min Max
                }
                else
                {
                    EnergyTimer--;
                }
            }
        }
    }



    uberEmulator - Footballs

    Currently in development



    Enjoy! - Kryptos
    Last edited by Kryptos; 10-07-10 at 10:34 PM.

  7. #7
    Lurking since '06 1ntel is offline
    MemberRank
    Jul 2006 Join Date
    401Posts
    UberEMU Room Alert Crash Fix (If bot is present in the room)

    Find
    Code:
    case "roomalert":
    Then go down to
    Code:
                                foreach (RoomUser RoomUser in TargetRoom.UserList)
                                {
    After that place:
    Code:
                                    if (RoomUser.IsBot)
                                    {
                                        continue;
                                    }
    Done by me (pretty simple tbh)

    EDIT: Nearlly got a fix for following a friend when on Hotel View - I will post below once i know its working 100%

    This could be causing some freeze issues, try this out guys:

    In Net -> TcpConnectionManager find:
    Code:
    private readonly int MAX_SIMULTANEOUS_CONNECTIONS = 100;
    Replace with:
    Code:
    private readonly int MAX_SIMULTANEOUS_CONNECTIONS = 500;
    500 is the recommended amount of TCP Simultaneous Connections to use on any machine, any higher and you likely kill the machines internet.

    Give this a try :)
    Last edited by MDK; 09-07-10 at 10:15 PM.

  8. #8
    Lurking since '06 1ntel is offline
    MemberRank
    Jul 2006 Join Date
    401Posts

    Re: Official uberEmulator Development Thread [C#, R49+, MySQL]

    Room event fix (a cause for error)
    Currently the way it seems to be coded is it is made to create a room with null name, null description, null tags but in category 0, looks like whoever did this thought category 0 didn't exist, but it does, its "Hottest Rooms" category, anyway here is the fix:

    Search and Replace All:
    Code:
    this.Event = new RoomEvent(0, null, null, 0, new List<string>());
    With:
    Code:
    this.event = null;
    Easy! It no longer will create blank events (i have had this issue but this fix stops it)

    EDIT: I just realised MDK posted to replace that null with his! LOL, it causes issues for me with his code i didnt notice i was fixing stuff up on someones emu.
    Last edited by 1ntel; 09-07-10 at 02:04 PM.

  9. #9
    Account Upgraded | Title Enabled! MDK is offline
    MemberRank
    Apr 2010 Join Date
    ScotlandLocation
    445Posts

    Re: Official uberEmulator Development Thread [C#, R49+, MySQL]

    Alright I just done a massive clean-up to this thread and removed most of the spam remaining, but others have done a good job already. I merged a few posts together as it was just making it all confusing on who's doing what, so it should help a little.

    I'm going to ask for people to stop using this thread as a help desk and stop posting links to other threads here. Can you please just stick to posting code snippets or showing your development here.

    I'm also going to suggest spoilers so it doesn't look so messy, but I'd love it if people can MAYBE post some snippets (if they're huge) on somewhere like pastebin.

    Cheers, MDK.

  10. #10
    Proficient Member BeanHLFM is offline
    MemberRank
    Apr 2009 Join Date
    164Posts

    thumbs up Re: Official uberEmulator Development Thread [C#, R49+, MySQL]

    Crash Fix - a small amount of it...


    Go to Net > TcpConnection.cs

    Find

    Code:
            private readonly int RCV_BUFFER_SIZE = 512;
            private readonly int RCV_MILLI_DELAY = 1;
    replace it with

    Code:
            private readonly int RCV_BUFFER_SIZE = 512;
            private readonly int RCV_MILLI_DELAY = 0;
    I did it with my emulator and i aint had a problem since!

  11. #11
    ส็็็็็็็ Bloodraven is offline
    MemberRank
    Sep 2009 Join Date
    AntarcticaLocation
    2,414Posts

    Re: Official uberEmulator Development Thread [C#, R49+, MySQL]

    Wile i was searching for something related to ubercms i found this on pastebin:

    PHP Code:
    using System;
     
    namespace 
    PluginInterface
    {
        public interface 
    IUberPlugin
        
    {
            
    IUberPluginHost Host getset; }
     
            
    /// <summary>
            /// The name of the plugin.
            /// </summary>
            
    string Name get; }
            
    /// <summary>
            /// The description of the plugin.
            /// </summary>
            
    string Description get; }
            
    /// <summary>
            /// The author of the plugin.
            /// </summary>
            
    string Author get; }
            
    /// <summary>
            /// The version of the plugin.
            /// </summary>
            
    string Version get; }
     
            
    /// <summary>
            /// This function is called every time the plugin is initialized by the plugin host. It should initialize every process and register handlers, etc.
            /// </summary>
            
    void Initialize();
            
    /// <summary>
            /// This function is called when the plugin host disposes of the plugin. It should clean up everything and unregister any packet handlers if needed.
            /// </summary>
            
    void Dispose();
     
            
    /// <summary>
            /// This function is called every time a registered request is received by the server. First plugin loaded is the first plugin served. Default server packets handlers come last.
            /// </summary>
            /// <param name="Habbo�d">The ID of the user affected by this request. May be null in exceptional cases (eg. if the user has not logged in yet).</param>
            /// <param name="HeaderId">The header of the request received (decoded base 64).</param>
            /// <param name="Data">The full data of the request received.</param>
            /// <returns>If true is returned, default or other plugin packet handlers will be passed on this packet as well in the order specified in the function description. If false is returned, nothing else is done with this request after the plugin is done with it.</returns>
            
    Boolean HandlePacket(uint HabboIdint HeaderIdbyte[] Data);
        }
     
        public interface 
    IUberPluginHost
        
    {
            
    /// <summary>
            /// Allows a plugin to register a packet handler.
            /// </summary>
            /// <param name="PluginName">The caps-insensitive name of the plugin, can be any plugin - not neccesarily the current plugin.</param>
            /// <param name="HeaderId">The Base64 header of the request.</param>
            
    void RegisterPacketHandler(String PluginNameint HeaderId);
            
    /// <summary>
            /// Allows a plugin to unregister a packet handler.
            /// </summary>
            /// <param name="PluginName">The caps-insensitive name of the plugin, can be any plugin - not neccesarily the current plugin.</param>
            /// <param name="HeaderId">The Base64 header of the request.</param>
            
    void UnregisterPacketHandler(String PluginNameint HeaderId);
        }

    Its the plugin interface, or atleast apart of it. might be useful. I might just add this to my edit of uber.

  12. #12
    8-bit Bitch Slapper Alpha Ducky is offline
    MemberRank
    Mar 2007 Join Date
    In My HouseLocation
    2,436Posts

    Re: Official uberEmulator Development Thread [C#, R49+, MySQL]

    matty13 - OS

    Basically, what happens is, if many users are online buying items at the same time, duplicate entry's of items is going to happen, i have tested it and it happens.

    This happens because MySQL Caches SELECT Queries, and sometimes returns a same item id value from the cache!

    Simply turn off cache query in my.ini or simply, edit this code.

    Find:
    Code:
    public uint GenerateItemId()
    Replace this:
    Code:
    i = (uint)dbClient.ReadDataRow("SELECT id_generator FROM item_id_generator LIMIT 1")[0];
    With this code:
    Code:
    i = (uint)dbClient.ReadDataRow("SELECT SQL_NO_CACHE id_generator FROM item_id_generator LIMIT 1;")[0];
    Stops it from returning the same item id from the cache.

  13. #13
    8-bit Bitch Slapper Alpha Ducky is offline
    MemberRank
    Mar 2007 Join Date
    In My HouseLocation
    2,436Posts

    Re: Official uberEmulator Development Thread [C#, R49+, MySQL]

    Here are some unfinished snippets for people to finish.

    Pets:
    Code:
                Pet.Statusses.Remove("sit");
                Pet.Statusses.Remove("lay");
                Pet.Statusses.Remove("snf");
                Pet.Statusses.Remove("eat");
                Pet.Statusses.Remove("drk");
                Pet.Statusses.Remove("ded");
                Pet.Statusses.Remove("jmp");
                Pet.Statusses.Remove("flw");
                Pet.Statusses.Remove("ply");
    Code:
                            #region nest
                            case "nest":
                                RemovePetStatus();
    
                                int NewBasketX = Pet.PetData.BasketX;
                                int NewBasketY = Pet.PetData.BasketY;
    
                                ActionTimer = 30;
                                Pet.PetData.AddExpirience(10);
                                Pet.MoveTo(NewBasketX, NewBasketY);
                                break;
                            #endregion
    Code:
                            #region Silent
                            case "silent":
                                RemovePetStatus();
                                Pet.PetData.AddExpirience(10);
                                SpeechTimer = 60;
                                break;
                            #endregion
    Code:
                            #region eat
                            case "eat":
                                RemovePetStatus();
                                Pet.Statusses.Add("eat", Pet.Z.ToString());
                                GetRoomUser().Chat(null, "*Eats*", false);
                                ActionTimer = 30;
                                Pet.PetData.AddExpirience(10);
                                Pet.PetData.PetNutrition(true);
                                Pet.PetData.PetNutrition(true);
                                break;
                            #endregion
    Code:
                            #region drink
                            case "drink":
                                RemovePetStatus();
                                Pet.Statusses.Add("drk", Pet.Z.ToString());
                                GetRoomUser().Chat(null, "*Drinks*", false);
                                ActionTimer = 30;
                                Pet.PetData.AddExpirience(10);
                                Pet.PetData.PetNutrition(true);
                                Pet.PetData.PetNutrition(true);
                                Pet.PetData.PetNutrition(true);
                                break;
                            #endregion
    Code:
                            #region beg
                            case "beg":
                                RemovePetStatus();
                                Pet.Statusses.Add("beg", Pet.Z.ToString());
                                ActionTimer = 25;
                                EnergyTimer = 10;
                                Pet.PetData.AddExpirience(10);
                                break;
                            #endregion
    Code:
                            #region stand
                            case "stand":
                                Pet.Statusses.Remove("sit");
                                Pet.PetData.AddExpirience(10);
                                break;
                                #endregion
    Code:
                            #region speak
                            case "speak":
                                RemovePetStatus();
    
                               if (Pet.PetData.Type == 0 || Pet.PetData.Type == 3)
                               {
                                   GetRoomUser().Chat(null, "Woof! Woof", false);
                               }
                               else if (Pet.PetData.Type == 1)
                               {
                                   GetRoomUser().Chat(null, "meow...meOW", false);
                               }
                               else if (Pet.PetData.Type == 2)
                               {
                                   GetRoomUser().Chat(null, "Rrrr....Grrrrrg....", false);
                               }
                               else if (Pet.PetData.Type == 3)
                                {
                                    GetRoomUser().Chat(null, "woooooooof", false);
                                }
                               else if (Pet.PetData.Type == 4)
                               {
                                   GetRoomUser().Chat(null, "Rawrrr!", false);
                               }
                               else if (Pet.PetData.Type == 5)
                                {
                                    GetRoomUser().Chat(null, "Oink Oink..", false);
                                }
                               Pet.PetData.AddExpirience(10);
                               break;
                            #endregion
    Code:
                            #region follow
                            case "follow":
                                RemovePetStatus();
    
                                int NewFollowX = User.X;
                                int NewFollowY = User.Y;
    
                                ActionTimer = 30;
    
                                #region Rotation
                                if (User.RotBody == 4)
                                {
                                    NewFollowY = User.Y - 1;
                                }
                                else if (User.RotBody == 0)
                                {
                                    NewFollowY = User.Y + 1;
                                }
                                else if (User.RotBody == 6)
                                {
                                    NewFollowX = User.X + 1;
                                }
                                else if (User.RotBody == 2)
                                {
                                    NewFollowX = User.X + 1;
                                }
                                else if (User.RotBody == 3)
                                {
                                    NewFollowX = User.X - 1;
                                    NewFollowY = User.Y - 1;
                                }
                                else if (User.RotBody == 1)
                                {
                                    NewFollowX = User.X - 1;
                                    NewFollowY = User.Y + 1;
                                }
                                else if (User.RotBody == 7)
                                {
                                    NewFollowX = User.X + 1;
                                    NewFollowY = User.Y + 1;
                                }
                                else if (User.RotBody == 5)
                                {
                                    NewFollowX = User.X + 1;
                                    NewFollowY = User.Y - 1;
                                }
                                #endregion
    
                                Pet.PetData.AddExpirience(10);
    
                              //if (User.MoveTo(X, Y))
                              //  {
                              //      Pet.MoveTo(NewFollowX, NewFollowY);
                              //  }
                                break;
                            #endregion
    Code:
                            #region follow left
                            case "follow left":
                                RemovePetStatus();
    
                                int NewFollowLeftX = User.X;
                                int NewFollowLeftY = User.Y;
    
                                ActionTimer = 30;
    
                                #region Rotation
                                if (User.RotBody == 4)
                                {
                                    NewFollowLeftY = User.X + 1;
                                }
                                else if (User.RotBody == 0)
                                {
                                    NewFollowLeftY = User.X - 1;
                                }
                                else if (User.RotBody == 6)
                                {
                                    NewFollowLeftX = User.Y - 1;
                                }
                                else if (User.RotBody == 2)
                                {
                                    NewFollowLeftX = User.Y + 1;
                                }
                                else if (User.RotBody == 3)
                                {
                                    NewFollowLeftX = User.Y + 1;
                                    NewFollowLeftY = User.X + 1;
                                }
                                else if (User.RotBody == 1)
                                {
                                    NewFollowLeftX = User.Y + 1;
                                    NewFollowLeftY = User.X - 1;
                                }
                                else if (User.RotBody == 7)
                                {
                                    NewFollowLeftX = User.Y - 1;
                                    NewFollowLeftY = User.X - 1;
                                }
                                else if (User.RotBody == 5)
                                {
                                    NewFollowLeftX = User.Y - 1;
                                    NewFollowLeftY = User.X + 1;
                                }
                                #endregion
    
                                Pet.PetData.AddExpirience(10);
    
                                //if (User.MoveTo(X, Y))
                                //{
                                //    Pet.MoveTo(NewFollowLeftX, NewFollowLeftY);
                                //}
                                break;
                            #endregion
    Code:
                            #region follow right
                            case "follow right":
                                 RemovePetStatus();
    
                                int NewFollowRightX = User.X;
                                int NewFollowRightY = User.Y;
    
                                ActionTimer = 30;
    
                                #region Rotation
                                if (User.RotBody == 4)
                                {
                                    NewFollowRightY = User.X - 1;
                                }
                                else if (User.RotBody == 0)
                                {
                                    NewFollowRightY = User.X + 1;
                                }
                                else if (User.RotBody == 6)
                                {
                                    NewFollowRightX = User.Y + 1;
                                }
                                else if (User.RotBody == 2)
                                {
                                    NewFollowRightX = User.Y + 1;
                                }
                                else if (User.RotBody == 3)
                                {
                                    NewFollowRightX = User.Y - 1;
                                    NewFollowRightY = User.X - 1;
                                }
                                else if (User.RotBody == 1)
                                {
                                    NewFollowRightX = User.Y - 1;
                                    NewFollowRightY = User.X + 1;
                                }
                                else if (User.RotBody == 7)
                                {
                                    NewFollowRightX = User.X + 1;
                                    NewFollowRightY = User.Y + 1;
                                }
                                else if (User.RotBody == 5)
                                {
                                    NewFollowRightX = User.Y + 1;
                                    NewFollowRightY = User.X - 1;
                                }
                                #endregion
    
                                Pet.PetData.AddExpirience(10);
    
                              //if (User.MoveTo(X, Y))
                              //  {
                              //      Pet.MoveTo(NewX, NewY);
                              //  }
                                break;
                            #endregion
    Code:
                            #region play
                            case "play":
                                RemovePetStatus();
                                Pet.Statusses.Add("ply", Pet.Z.ToString());
                                GetRoomUser().Chat(null, "*Plays*", false);
                                ActionTimer = 30;
                                Pet.PetData.AddExpirience(10);
                                break;
                            #endregion
    Code:
            public void PetNutrition(bool Add)
            {
                int MaxN;
    
                if (Add)
                {
                    if (this.Nutrition == 150)
                    {
                        return;
                    }
    
                    if (this.Nutrition > 125) { MaxN = this.MaxNutrition - this.Nutrition; } else { MaxN = 10; }
                }
                else { MaxN = 15; }
    
                int r = UberEnvironment.GetRandomNumber(5, 50);
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    if (!Add)
                    {
                        this.Nutrition = this.Nutrition - r;
    
                        if (this.Nutrition < 0)
                        {
                            dbClient.AddParamWithValue("pid", PetId);
                            dbClient.ExecuteQuery("UPDATE user_pets SET nutrition = 1 WHERE id = @pid LIMIT 1");
    
                            this.Nutrition = 1;
    
                            r = 1;
                        }
    
                        dbClient.AddParamWithValue("r", r);
                        dbClient.AddParamWithValue("petid", PetId);
                        dbClient.ExecuteQuery("UPDATE user_pets SET nutrition = nutrition - @r WHERE id = @petid LIMIT 1");
    
                    }
                    else
                    {
                        dbClient.AddParamWithValue("r", r);
                        dbClient.AddParamWithValue("petid", PetId);
                        dbClient.ExecuteQuery("UPDATE user_pets SET nutrition = nutrition + @r WHERE id = @petid LIMIT 1");
    
                        this.Nutrition = this.Nutrition + r;
                    }
                }
            }

    Fball:

    Code:
                        case "fball":
    
                            return new InteractorFball();
    Code:
                        case "fball":
    
                            RoomItem fballItem = GetRoom().GetItem(fball);
    
                            int NewfballX = fballItem.X;
                            int NewfballY = fballItem.Y;
    
    
                            if (User.Coordinate == Coordinate)
    
                               if (User.RotBody == 4)
                               { NewfballY = fballItem.Y + 1; }
                               else
                               { NewfballY = fballItem.Y - 1; }
    
                               if (User.RotBody == 0)
                               { NewfballY = fballItem.Y - 1; }
                               else
                               { NewfballY = fballItem.Y + 1; }
    
                               if (User.RotBody == 6)
                               { NewfballX = fballItem.X - 1; }
                               else
                               { NewfballX = fballItem.X + 1; }
    
                               if (User.RotBody == 2)
                               { NewfballX = fballItem.X + 1; }
                               else
                               { NewfballX = fballItem.X - 1; }
    
                               if (User.RotBody == 3)
                               {
                                   NewfballX = fballItem.X + 1;
                                   NewfballY = fballItem.Y + 1;
                               }
                               else
                               {
                                   NewfballX = fballItem.X - 1;
                                   NewfballY = fballItem.Y - 1;
                               }
    
                               if (User.RotBody == 1)
                               {
                                   NewfballX = fballItem.X + 1;
                                   NewfballY = fballItem.Y - 1;
                               }
                               else
                               {
                                   NewfballX = fballItem.X - 1;
                                   NewfballY = fballItem.Y + 1;
                               }
    
                               if (User.RotBody == 7)
                               {
                                   NewfballX = fballItem.X - 1;
                                   NewfballY = fballItem.Y - 1;
                               }
                               else
                               {
                                   NewfballX = fballItem.X + 1;
                                   NewfballY = fballItem.Y + 1;
                               }
    
                               if (User.RotBody == 5)
                               {
                                   NewfballX = fballItem.X - 1;
                                   NewfballY = fballItem.Y + 1;
                               }
                               else
                               {
                                   NewfballX = fballItem.X + 1;
                                   NewfballY = fballItem.Y - 1;
                               }
    
                           break;
    Code:
        class InteractorFball : FurniInteractor
        {
            //some data here :P
        }
    TcpConnection:
    Code:
            #region Fields
            private readonly int RECEIVEDATA_BUFFER_SIZE = 512;
            private const int RCV_BUFFER_SIZE = 0x200;
            private readonly int RECEIVEDATA_MILLISECONDS_DELAY = 0;
            private readonly uint mID;
            public readonly uint Id;
            private readonly DateTime mCreatedAt;
            private Socket mSocket = null;
            private byte[] mDataBuffer;
            private AsyncCallback mDataReceivedCallback;
            private RouteReceivedDataCallback mRouteReceivedDataCallback;
            private bool mEncryptionStarted;
            private HabboHexRC4 mRc4;
            #endregion
    Code:
    private readonly int MAX_SIMULTANEOUS_CONNECTIONS = 500;
    Code:
    http://ion26.googlecode.com/svn/server/trunk/Net/Connections/IonTcpConnection.cs
    Infobus: (not tested)

    Code:
                string PollOption1 = null;
                string PollOption2 = null;
                string PollOption3 = null;
                string PollOption4 = null;
                string PollOption5 = null;
                string PollOption6 = null;
    Code:
                        case "bustest":
    
                            if (Session.GetHabbo().HasFuse("fuse_admin"))
                            {
                                ServerMessage Message = new ServerMessage(79);
    
                                PollOption1 = Params[1];
                                PollOption2 = Params[2];
                                PollOption3 = Params[3];
                                PollOption4 = Params[4];
                                PollOption5 = Params[5];
                                PollOption6 = Params[6];
    
                                Message.AppendStringWithBreak(PollOption1);
                                Message.AppendInt32(5);
    
                                Message.AppendInt32(133333);
                                Message.AppendStringWithBreak(PollOption2);
    
                                Message.AppendInt32(2);
                                Message.AppendStringWithBreak(PollOption3);
    
                                Message.AppendInt32(3);
                                Message.AppendStringWithBreak(PollOption4);
    
                                Message.AppendInt32(4);
                                Message.AppendStringWithBreak(PollOption5);
    
                                Message.AppendInt32(5);
                                Message.AppendStringWithBreak(PollOption6);
    
                                Session.GetHabbo().CurrentRoom.SendMessage(Message);
    
                                return true;
                            }
    
                            break;
    Pets Commands Panel:
    Code:
            private void GetTrainerPanel()
            {
                uint PetID = Request.PopWiredUInt();
                Pet PetData = Session.GetHabbo().GetInventoryComponent().GetPet(PetID);
                GetResponse().Init(605);
                GetResponse().AppendUInt(PetID);
                GetResponse().AppendString("PBHIJKPAQARASA");
                SendResponse();
            }
    Code:
    RequestHandlers[3004] = new RequestHandler(GetTrainerPanel);
    Got from toperwin on OS
    Last edited by Alpha Ducky; 11-08-10 at 12:20 AM.

  14. #14
    Member JCisgod is offline
    MemberRank
    Mar 2010 Join Date
    HeavenLocation
    52Posts

    Re: Official uberEmulator Development Thread [C#, R49+, MySQL]

    Quote Originally Posted by lorigio View Post
    Walk diagonal

    Search:
    Code:
    InitMovements(4)
    Replace:
    Code:
    InitMovements(0)
    If anyone post the fix the crash is the most important.
    Sorry for the english but I'm Italian.
    What is the name of the file you need to change?

  15. #15

    Re: Official uberEmulator Development Thread [C#, R49+, MySQL]

    Search these entry on your project



Page 1 of 3 123 LastLast

Advertisement