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
After that, add this to Item.cs under the other cases
Next, you want to open your Habbo.cs, and add these two to the top along with the other lines that look fairly similar.
After that, go down until you see your properties, and paste these two.
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.
Lastly is adding your command, i'll just give the one I use to save you the hassle of coding one.
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.
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)
{
}
}
}
Code:
case InteractionType.SLOTS:
return new InteractorSlots();
C#:
private int integerSlot = 0;
private long lastSpun = 0;
C#:
public int SlotsInteractation
{
get { return this.integerSlot; }
set { this.integerSlot = value; }
}
public long SlotLastSpun
{
get { return this.lastSpun; }
set { this.lastSpun = value; }
}
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;
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.");
}
}
}
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: