[FIXES] uberEmulator

Status
Not open for further replies.

RastaLulz

fight teh power
Staff member
May 3, 2010
3,934
3,933
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

Credits: Shorty/Habchop
 

RastaLulz

fight teh power
Staff member
May 3, 2010
3,934
3,933
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>());

Credits: MDK
 

RastaLulz

fight teh power
Staff member
May 3, 2010
3,934
3,933
Walk diagonal

Search:
Code:
InitMovements(4)

Replace:
Code:
InitMovements(0)

Credits: lorigio
 

RastaLulz

fight teh power
Staff member
May 3, 2010
3,934
3,933
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;
        }
    }
}

Credits: Bjork
 

RastaLulz

fight teh power
Staff member
May 3, 2010
3,934
3,933
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
    }
}

Credits: Bjork
 

RastaLulz

fight teh power
Staff member
May 3, 2010
3,934
3,933
Here's my pet.cs
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.

Here's my petbot.cs
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)

        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("ded");
            Pet.Statusses.Remove("jmp");
            Pet.Statusses.Remove("beg"); //Not tested - Kryptos
        }

        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 >= 3)
                            // 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();

                            //Add Status
                            Pet.Statusses.Add("slt", Pet.Z.ToString());

                            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 >=3)
                            //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": //It probably doesn't work, but I tried.
                            if (Pet.PetData.Level >= 5)
                            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 >= 5)
                            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);
                           
                        #endregion

                        #region follow right
                        case "follow right":
                            if (Pet.PetData.Level >= 5)
                             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(false); // Remove Nutrition
                    Pet.PetData.PetNutrition(false); // 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(false); // Remove 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--;
            }
        }
    }
}
Pet's training commands it has: Free, Here, Sit, Lay, Dead, Sleep, Jump, Silent, Beg, Stand, Speak, Follow, Follow left, Follow right(Follow, Follow right and Follow left work like "Here".
Try it. If you got some errors please PM me so I can fix it.

And if you want it to actually follow you, perhaps try something like:
Code:
if (User.MoveTo(X, Y))
  {
    Pet.MoveTo(NewX, NewY);
  }

Credits: Kryptos
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,199
3,934
@Above they're already done like you reqeusted, read the quotes and the code in the code boxes.
 
Status
Not open for further replies.

Users who are viewing this thread

Top