Plus EMU - Toll System

May 1, 2015
470
154
Hi,
As requested by @Brand here is a working toll system, that only allows one toll per room due to diamonds / credits farming.
I was going to make a toll manager and fetch them all that way and allow many tolls per room, but don't want people gaining too much from this,
you can re-code it to allow many per room - completely up to you.
The cost can only be 1-15 diamonds, setting it to 0 cancels the toll.
I'm only releasing this because it isn't that much of a unique feature and doesn't mean anything to me at all.
Firstly, add this to your roomdata.cs
Code:
public bool HasTollSet;
public int TollAmount;
Then further down add this,
this.HasTollSet = PlusEnvironment.EnumToBool(Row["toll_set"].ToString());
 this.TollAmount = Convert.ToInt32(Row["toll_amount"]);
Just under this.PetMorphsAllowed = PlusEnvironment.EnumToBool(Row["pet_morphs_allowed"].ToString());
Add the following to InteractorOneWayGate.cs
Code:
 Room Room = User.GetClient().GetHabbo().CurrentRoom;
                RoomUser RoomOwner = Room.GetRoomUserManager().GetRoomUserByHabbo(Room.OwnerId);
                if (Room.HasTollSet)
                {
                    int TollCost = Room.TollAmount;
                    if (User.GetClient().GetHabbo().Credits < TollCost)
                    {
                        User.GetClient().SendWhisper("You can not enter this gate because you do not have enough diamonds!");
                        return;
                    }
                    else
                    {
                        User.GetClient().SendWhisper("There is a toll on this gate! " + TollCost + " diamonds will be taken from your balance.");
                        User.GetClient().GetHabbo().Diamonds -= TollCost;
                        User.GetClient().SendMessage(new HabboActivityPointNotificationComposer(User.GetClient().GetHabbo().Diamonds, TollCost, 5));
                        // reward owner with toll
                        RoomOwner.GetClient().GetHabbo().Diamonds += TollCost;
                        RoomOwner.GetClient().SendMessage(new HabboActivityPointNotificationComposer(RoomOwner.GetClient().GetHabbo().Diamonds, TollCost, 5));
                    }
                }
Now finally, the set toll command.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Plus.HabboHotel.GameClients;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun
{
    class SetTollCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_set_toll"; }
        }
        public string Parameters
        {
            get { return "%price%"; }
        }
        public string Description
        {
            get { return "Set a toll on your one way gate"; }
        }
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("You must enter a price for your one way gate!");
                return;
            }

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            int Cost;
            Cost = int.Parse(Params[1]);

            if (!Room.CheckRights(Session, true))
                return;

            if (Cost < 0 || Cost > 15)
            {
                Session.SendWhisper("The toll amount can only be 1-15 diamonds.");
                return;
            }

            if (Cost == 0)
            {
                Session.SendWhisper("You have successfully removed your toll.");
                Room.HasTollSet = false;
                Room.TollAmount = 0;
                return;
            }
            else
            {
                Session.SendNotification("You have succesfully set a toll of " + Cost + " diamonds on your one way gate.\r\n" +
                    "To Remove a toll, please use :toll 0 - only one poll per room is allowed.");
                Room.HasTollSet = true;
                Room.TollAmount = Cost;
                return;
            }
        }
    }
}
Then add toll_set as an enum to your rooms table as well as toll_amount as an int.
That's all, enjoy.
P.S @Brand you're welcome :up:
 
Last edited:

yoyok

Member
Apr 24, 2013
197
24
There is no check (pop-up/alert, accept -5 diamonds or decline) if a user go accidentally through a gate?
You'll lose your diamonds anyway.
 

HolaBox

New Member
Feb 20, 2017
27
2
Where abouts does the code go for InteractorOneWayGate.cs? and would this work?
PHP:
ALTER TABLE `rooms` ADD `toll_set` int(11) NOT NULL
ALTER TABLE `rooms` ADD `toll_amount` enum(11) NOT NULL
 

Stee

Oh hot damn. This is my jam.
Jun 28, 2011
285
159
Where abouts does the code go for InteractorOneWayGate.cs? and would this work?
PHP:
ALTER TABLE `rooms` ADD `toll_set` int(11) NOT NULL
ALTER TABLE `rooms` ADD `toll_amount` enum(11) NOT NULL

I had to use this.
PHP:
ALTER TABLE `rooms` ADD `toll_set` int(11) NOT NULL
ALTER TABLE `rooms` ADD `toll_amount` int(11) NOT NULL
 

Users who are viewing this thread

Top