Plus Emulator Slot Machine Interaction

Hypothesis

Programmer
Jan 6, 2019
524
361
Hi there DevBest, today I will be releasing a slot machine interaction type. The way I had it at my hotel was it set an amount based on a command called :gamble, and when you would set an amount then interact with the interact-able furniture item, which just so happen to be slot machines as that was the concept, anyways basically it would randomize your odds and divide those odds by 2, and determine a set amount of cards, each card sequence had a different percentage added to the amount you'd bet. Basically you'd have a chance to increase your credits just by gambling, I know a hotel by the name of RageRP had this function in the casinos, same with HoloRP and NGH, I believe Habboon has this function as well. I did not fully create this interactor on my own, I had quite a bit of help with the randomization of the odds, the person who helped me with the sequence knows who they are. Anyways, here's the release.
Create a new CS file called InteractorSlots.cs in your Interactor folder and paste this into it and save
C#:
using System;

using Plus.HabboHotel.Rooms;
using Plus.HabboHotel.GameClients;
using Plus.Communication.Packets.Outgoing.Inventory.Purse;
using Plus.Communication.Packets.Outgoing.Rooms.Chat;

namespace Plus.HabboHotel.Items.Interactor
{
    public class InteractorSlots : IFurniInteractor
    {
        public void OnPlace(GameClient Session, Item Item)
        {
            Item.ExtraData = "0";
            Item.InteractingUser = 0;
        }

        public void OnRemove(GameClient Session, Item Item)
        {
            Item.ExtraData = "0";
            Item.InteractingUser = 0;
        }

        public void OnTrigger(GameClient Session, Item Item, int Request, bool HasRights)
        {
            if (Session == null)
                return;

            RoomUser User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (User == null)
                return;

            if (Gamemap.TilesTouching(Item.GetX, Item.GetY, User.X, User.Y))
            {
                if (Session.GetHabbo().SlotsInteractation == 0)
                {
                    Session.SendWhisper("There was an error with your amount.", 3);
                    return;
                }
                if (Session.GetHabbo().SlotLastSpun != 0)
                {
                    if (Session.GetHabbo().SlotLastSpun > PlusEnvironment.Now())
                    {
                        Session.SendWhisper("Betting Cooldown!", 3);
                        return;
                    }
                }
                    if (Session.GetHabbo().Credits >= Session.GetHabbo().SlotsInteractation)
                    {
                        Item.ExtraData = "1";
                        Item.UpdateState();
                        Item.RequestUpdate(4, true);
                        Session.GetHabbo().SlotLastSpun = PlusEnvironment.Now() + 1000;
                        //13 options Min: 0 Max: 13 (0-12)
                        String[] slotOptions = { "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "King", "Queen" };

                        Random randCard = new Random();
                        int Card1 = randCard.Next(0, 13);
                        int Card2 = randCard.Next(0, 13);
                        int Card3 = randCard.Next(0, 13);

                        String SlotCard1 = slotOptions[Card1];
                        String SlotCard2 = slotOptions[Card2];
                        String SlotCard3 = slotOptions[Card3];

                        int CreditsWon = 0;

                        if (Card1 == Card2 && Card2 == Card3 && Card3 == Card1)
                        {
                            CreditsWon = randCard.Next(Session.GetHabbo().SlotsInteractation, (Session.GetHabbo().SlotsInteractation * 2));
                        }
                        else if (Card1 == Card2 || Card2 == Card3 || Card1 == Card3)
                        {
                            CreditsWon = randCard.Next(Session.GetHabbo().SlotsInteractation, (Session.GetHabbo().SlotsInteractation + (Session.GetHabbo().SlotsInteractation / 2)));
                        }
                        else
                        {
                            CreditsWon = 0;
                        }
                        Session.SendWhisper("SLOT MACHINE: " + SlotCard1 + " " + SlotCard2 + " " + SlotCard3 + " You have won: " + CreditsWon + " credits!");
                        Session.GetHabbo().Credits = Session.GetHabbo().Credits - Session.GetHabbo().SlotsInteractation;
                        Session.GetHabbo().Credits = Session.GetHabbo().Credits + CreditsWon;
                        Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits));
                }
                    else
                    {
                        Session.SendWhisper("Your credit amount is too large.", 3);
                        return;
                    }
            }
            else
            {
                User.MoveTo(Item.SquareInFront);
            }
      
        }

        public void OnWiredTrigger(Item Item)
        {
        }
    }
}
After that, add this to Item.cs under the other cases
Code:
case InteractionType.SLOTS:
                        return new InteractorSlots();
Next, you want to open your Habbo.cs, and add these two to the top along with the other lines that look fairly similar.
C#:
private int integerSlot = 0;
private long lastSpun = 0;
After that, go down until you see your properties, and paste these two.
C#:
public int SlotsInteractation
        {
            get { return this.integerSlot; }
            set { this.integerSlot = value; }
}

public long SlotLastSpun
        {
            get { return this.lastSpun; }
            set { this.lastSpun = value; }
        }
After this, you wanna go to your InteractionType.cs, then add another enum to the end of the function, and call it SLOTS
after you have that, go to the very last interaction type, in my case in FX_Provider, so before the default type, add this.
C#:
  case "slots":
                    return InteractionType.SLOTS;
Lastly is adding your command, i'll just give the one I use to save you the hassle of coding one.
C#:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using Plus.Database.Interfaces;
using Plus.Database.Adapter;
using Plus.HabboHotel.Users.UserDataManagement;
using Plus.HabboHotel.Rooms;
using Plus.HabboHotel.Items;
using Plus.Communication.Packets.Outgoing.Inventory.Purse;
using Plus.Communication.Packets.Outgoing.Notifications;
using Plus.Communication.Packets.Outgoing.Rooms.Notifications;
using Plus.Communication.Packets.Outgoing.Rooms.Session;
namespace Plus.HabboHotel.Rooms.Chat.Commands.User
{
    class GambleCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_enable"; }
        }

        public string Parameters
        {
            get { return ""; }
        }

        public string Description
        {
            get { return "Gamble with the slot machine"; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room CurrentRoom, string[] Params)
        {
            if (Session == null)
                return;

            int Bet = 0;

            try
            {
                Bet = int.Parse(Params[1]);
            }
            catch
            {
                Session.SendWhisper("The amount you entered is invalid.", 3);
                return;
            }
            if(Bet < 1 || Bet > 500000)
            {
                Session.SendWhisper("You can bet anything from 1 credit to 500000 credits.", 3);
                return;
            }

            if (Session.GetHabbo().Credits < Bet)
            {
                Session.SendWhisper("You do not have enough credits to proceed with this bet.", 3);
                return;
            }

            Session.GetHabbo().SlotsInteractation = Bet;
            Session.SendWhisper("You have set your slot bet to " + Bet + " credits, double-click the slot to gamble.");
        }
    }
}
To get it working basically just go into your furniture table and choose a furniture you like, then make the interaction type SLOTS after that you should be good, if your table has the column set to use ENUM, then just open your structure and add SLOTS to your enum options.
Thanks for reading, I hope this was helpful, if you have any issues, make a comment, I'll gladly help you or maybe someone else might be able to.
 
Last edited:

Hypothesis

Programmer
Jan 6, 2019
524
361
No bro, lol, you put the variables in the wrong place.
Search for private int _vipRank; in Habbo.cs and below it add these
C#:
private int integerSlot = 0;
private long lastSpun = 0;
not at the top lol
I'm assuming you put the other ones wrongly as well, so here's where to add the other ones if you have more trouble.
Search for this in the same file.
C#:
public string Gender
        {
            get { return this._gender; }
            set { this._gender = value; }
        }
you'll probably just have to search for public string Gender then under that entire function, add these.
C#:
public int SlotsInteractation
        {
            get { return this.integerSlot; }
            set { this.integerSlot = value; }
}

public long SlotLastSpun
        {
            get { return this.lastSpun; }
            set { this.lastSpun = value; }
        }
Sorry, I probably should've been more specific in the thread for all the newbies, but anyone else that doesn't know where to put them, there you go :)
 

Hypothesis

Programmer
Jan 6, 2019
524
361
@wizaardz25 As stated in the tutorial, you need to set the interaction type of an item in your furniture table to SLOTS, to make it work as a slot when you double click it.
 

wizaardz25

New Member
Dec 2, 2017
21
2
@Hypothesis why does it not working when i have done slots in furni table and i double click on the slot furni but it doesnt give anything back ? please help i have done everything else
 

Hypothesis

Programmer
Jan 6, 2019
524
361
@Hypothesis why does it not working when i have done slots in furni table and i double click on the slot furni but it doesnt give anything back ? please help i have done everything else
Your error is right there, your PlusEnvironment doesn't contain a variable for the usage of 'Now,' not sure why, all releases have that I believe, here add this to Plus Environment, somewhere in the middle with similar looking lines.
C#:
public static long Now()
        {
            TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
            double unixTime = ts.TotalMilliseconds;
            return (long)unixTime;
        }
 

Rystbo

-Hotel Owner, -Customs Developer, -Arcturus
Apr 16, 2018
390
200
I cant get it to work either, followed instructions to a t- maybe im placing the command in the wrong spot? Where do you create it at?
 

Hypothesis

Programmer
Jan 6, 2019
524
361
@Rystbo Can you give me more specific questions, what do you mean it doesn't work, how doesn't it work, any errors? If it seems to be this difficult I might just help people over Teamviewer, but it's pretty basic honestly. Add me on Discord ᒍoe#0001 if you need help, i'll get back to you at some point today, going to class.
 
Last edited:

Rystbo

-Hotel Owner, -Customs Developer, -Arcturus
Apr 16, 2018
390
200
@Rystbo Can you give me more specific questions, what do you mean it doesn't work, how doesn't it work, any errors? If it seems to be this difficult I might just help people over Teamviewer, but it's pretty basic honestly. Add me on Discord Joseph#8099 if you need help, i'll get back to you at some point today, going to class.
I sent a request over discord(paradisehotel) thanks
 

Hypothesis

Programmer
Jan 6, 2019
524
361
Everyone, I apologize, I forgot one other piece of code, add this to your Item.cs
Make sure you add it in the correct place, where you see the other case methods.
C#:
case InteractionType.SLOTS:
                        return new InteractorSlots();
No wonder so many people couldn't get it working, lol. I have updated the thread by the way with this information.
 

Rystbo

-Hotel Owner, -Customs Developer, -Arcturus
Apr 16, 2018
390
200
Everyone, I apologize, I forgot one other piece of code, add this to your Item.cs
Make sure you add it in the correct place, where you see the other case methods.
C#:
case InteractionType.SLOTS:
                        return new InteractorSlots();
No wonder so many people couldn't get it working, lol. I have updated the thread by the way with this information.

Be more specific on items.cs when i open it there is no similar case methods, only when i open items.cs in wired. it has the correct ones, i have a catalogitems.cs also but doesn't contain similar methods
 

Hypothesis

Programmer
Jan 6, 2019
524
361
Be more specific on items.cs when i open it there is no similar case methods, only when i open items.cs in wired. it has the correct ones, i have a catalogitems.cs also but doesn't contain similar methods
It's not called Items.cs, it's called Item.cs
 

Users who are viewing this thread

Top