Casino Bot

May 1, 2015
470
154
Hi,
Quick little release the idea was from a member on here i think @Damien. i just coded it.
This is my first bot so please do leave feedback / criticism below.
You will have to create the bot (furniture) itself as i don't do that.
I have it setup to only work if you're on the trusted system which will be different for your emulator so set it up however you wish.
I don't offer support on this as you just add the class (don't forget to add it in your BotAIType.cs & BotUtility.cs)
Now that we have all that out of the way, here's the bot.
Code:
using System;
using System.Drawing;

using Plus.HabboHotel.GameClients;
using Plus.HabboHotel.Rooms.AI.Speech;
using Plus.Communication.Packets.Outgoing.Rooms.Chat;
using Plus.HabboHotel.Rooms.AI.Responses;
using Plus.Utilities;
using Plus.Database.Interfaces;

namespace Plus.HabboHotel.Rooms.AI.Types
{
    class CasinoBot : BotAI
    {
        private int VirtualId;

        public CasinoBot(int VirtualId)
        {
            this.VirtualId = VirtualId;
        }

        public override void OnSelfEnterRoom()
        {
        }

        public override void OnSelfLeaveRoom(bool Kicked)
        {
        }

        public override void OnUserEnterRoom(RoomUser User)
        {
        }


        public override void OnUserLeaveRoom(GameClient Client)
        {
        }

        public override void OnUserSay(RoomUser User, string Message)
        {
            if (User == null || User.GetClient() == null || User.GetClient().GetHabbo() == null)
                return;

            if (Gamemap.TileDistance(GetRoomUser().X, GetRoomUser().Y, User.X, User.Y) > 5)
                return;

            if (User.GetClient().GetHabbo().Trusted)
            {
                User.GetClient().SendWhisper("You cannot use this bot because you're not trusted!");
                return;
            }

            string Item = Message.Split(' ')[5]; // split the item from the question
            string Username = Message.Split(' ')[2]; //Does altercationz have a throne?

            GameClient Target = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Message.Split(' ')[5]);
            if (Target == null)
            {
                User.GetClient().SendWhisper("User is offline.");
                return;
            }

            int Total = 0;
            using (IQueryAdapter Adapter = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                Adapter.SetQuery("SELECT COUNT(*) FROM items i JOIN furniture f ON (i.base_item = f.id) WHERE f.public_name = @item AND i.user_id = @userid");
                Adapter.AddParameter("userid", Target.GetHabbo().Id);
                Adapter.AddParameter("item", Message.Split(' ')[5]);
                Total = Adapter.getInteger();
            }

            if (Total >= 0)
            {
                User.GetClient().SendWhisper("The user " + Username + " has no " + Item + "'s!");
                return;
            }

            GetRoomUser().Chat("The user " + Username + " has " + Total + " " + Item + "'s!", false, GetRoomUser().LastBubble);
        }

        public override void OnUserShout(RoomUser User, string Message)
        {
        }

        public override void OnTimerTick()
        {
        }
    }
}
Enjoy.
 
Last edited:

Wickd

The first member of the Knights of the Pink Table
Jan 15, 2013
1,936
612
Oh whoa this is a very cool new feature you guys added, thanks for the share! :D

P.S Might wanna explain what the BOT actually does for the ones who can't read the code :p
 
May 1, 2015
470
154
It checks the user's inventory when you ask the bot the following question
"Does user have a throne"? or any rare.
 
May 1, 2015
470
154
I would but i don't work with furniture so i can't create the bot and add it to the catalogue but I know it works.
Whoever uses this please do post a screenshot.
 

C0MB4T122

New Member
Aug 15, 2016
25
0
I would but i don't work with furniture so i can't create the bot and add it to the catalogue but I know it works.
Whoever uses this please do post a screenshot.

I want to add this in plusemu R2 and make screens!
But where to put the code?
I put the code in Plus.HabboHotel.Rooms.AI.Types but is there nothing more?
is this all i have to do? nothing in db?
 
Last edited:

Kust123

New Member
Jan 5, 2015
1
1
WTF, isn't this the workaround I did when I saw Damien's BOT?
W/e, let's pretend the code / method is yours, anyway, what I did was trash, the most efficient way would be using Linq, as Damien did for his original idea.

This could be improved a lot, as it will only read one reference for one furni, by this I mean that you can only call 'VIP' por example a Club Sofa, if it had been done with a proper dictionnary for rares and stuff it'd be even more sick. I was also trying to implement images somehow from the small icons and use html for those using the new chat format, could be sick somehow.

Cheers.
 

Jaden

not so active
Aug 24, 2014
886
263
Agreed with @Kust123.

Their would be no reason to check for a users furniture if they're offline so using SQL in this instance is redundant. You should just use (not necessarily LINQ) but the methods provided in the emulator to check if a user has a certain item in their inventory because all of that is cached in the player instance.

There's a boolean function in the InventoryComponent called UserHoldsItem.
 
May 1, 2015
470
154
WTF, isn't this the workaround I did when I saw Damien's BOT?
W/e, let's pretend the code / method is yours, anyway, what I did was trash, the most efficient way would be using Linq, as Damien did for his original idea.

This could be improved a lot, as it will only read one reference for one furni, by this I mean that you can only call 'VIP' por example a Club Sofa, if it had been done with a proper dictionnary for rares and stuff it'd be even more sick. I was also trying to implement images somehow from the small icons and use html for those using the new chat format, could be sick somehow.

Cheers.
I have no idea who you are, I just did this quickly last night I'll look into using Linq. Thanks guys.
 

Damien

Don't need glasses if you can C#
Feb 26, 2012
434
647
LDQUJOBlds.gif


This is mine if anyone's wondering what it looks like client side. Same concept just coded differently.
 
Last edited:

Jaden

not so active
Aug 24, 2014
886
263
@Damien mind letting us know how to create the bot itself (furniture) cause I'm not sure how to do that part.
Are you talking about the bot appearing in your inventory or showing up in the room?

If option #2:
A bot uses the same RoomUser instance as a regular player, start from there.

This is the command i wrote to send police bots to my room, I reckon you can cherry pick from that.


p.s. to change the tile the bot spawns try manipulating the doorX and doorY variables in the function that deploys the bot to the room (RoomUserManager lines 72-78) or just use the MoveTo function associated with tthe bot's RoomUser instance.
 

Users who are viewing this thread

Top