[Plus EMU] Give Reward Wired Fix?

Bran

habcrush.pw
Mar 13, 2017
1,784
1,600
hey guys, i'm wondering if anyone has a fix for the give reward wired? it saves and everything but i just get this no matter what probability i put in :S
You must be registered for see images attach

You must be registered for see images attach

no matter what probability number i put from 1 - 100 it doesn't work? i'm using my edited Plus EMU R1​
 

Bran

habcrush.pw
Mar 13, 2017
1,784
1,600
Post the code you've got please
GiveWiredBox
Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Collections.Concurrent;

using Plus.Communication.Packets.Incoming;
using Plus.HabboHotel.Rooms;
using Plus.HabboHotel.Users;
using Plus.Communication.Packets.Outgoing.Rooms.Chat;
using Plus.Communication.Packets.Outgoing.Inventory.Furni;
using Plus.Communication.Packets.Outgoing.Catalog;
using Plus.Communication.Packets.Outgoing.Rooms.Notifications;

namespace Plus.HabboHotel.Items.Wired.Boxes.Effects
{
    class GiveRewardBox : IWiredItem
    {
        public Room Instance { get; set; }
        public Item Item { get; set; }
        public WiredBoxType Type { get { return WiredBoxType.EffectGiveReward; } }
        public ConcurrentDictionary<int, Item> SetItems { get; set; }
        public string StringData { get; set; }
        public bool BoolData { get; set; }
        public string ItemsData { get; set; }

        public GiveRewardBox(Room Instance, Item Item)
        {
            this.Instance = Instance;
            this.Item = Item;
            this.SetItems = new ConcurrentDictionary<int, Item>();
        }

        public void HandleSave(ClientPacket Packet)
        {
            int Unknown = Packet.PopInt();
            int Often = Packet.PopInt();
            bool Unique = (Packet.PopInt() == 1);
            int Limit = Packet.PopInt();
            int Often_No = Packet.PopInt();
            string Reward = Packet.PopString();

            this.BoolData = Unique;
            this.StringData = Reward + "-" + Often + "-" + Limit;
        }

        public bool Execute(params object[] Params)
        {
            if (Params == null || Params.Length == 0)
                return false;

            // Habbo Owner = HabboEnvironment.GetHabboById(Item.UserID);
            // if (Owner == null || !Owner.GetPermissions().HasRight("room_item_wired_rewards"))
            // return false;

            Habbo Player = (Habbo)Params[0];
            if (Player == null || Player.GetClient() == null)
                return false;

            RoomUser User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Username);
            if (User == null)
                return false;

            if (String.IsNullOrEmpty(StringData))
                return false;

            int amountLeft = int.Parse(this.StringData.Split('-')[2]);
            int often = int.Parse(this.StringData.Split('-')[1]);
            bool unique = this.BoolData;

            bool premied = false;

            if (amountLeft < 1)
            {
                Player.GetClient().SendWhisper("There are no more prizes, come back later.");
                return true;
            }

            foreach (var dataStr in (this.StringData.Split('-')[0]).Split(';'))
            {
                var dataArray = dataStr.Split(',');

                var isbadge = dataArray[0] == "0";
                var code = dataArray[1];
                var percentage = int.Parse(dataArray[2]);

                var random = PlusEnvironment.GetRandomNumber(0, 100);

                if (!unique && percentage < random)
                    continue;
                premied = true;

                if (isbadge)
                {
                    if (Player.GetBadgeComponent().HasBadge(code))
                        Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, "Oops, apparently you've already received this badge!", 0, User.LastBubble));
                    else
                    {
                        Player.GetBadgeComponent().GiveBadge(code, true, Player.GetClient());
                        Player.GetClient().SendMessage(new RoomNotificationComposer("prizeBadge", "message", "You've just recieved a badge!"));
                    }
                }
                else
                {
                    ItemData ItemData = null;

                    if (!PlusEnvironment.GetGame().GetItemManager().GetItem(int.Parse(code), out ItemData))
                    {
                        Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, "Could not get Item ID: " + code, 0, User.LastBubble));
                        return false;
                    }

                    Item Item = ItemFactory.CreateSingleItemNullable(ItemData, Player.GetClient().GetHabbo(), "", "", 0, 0, 0);


                    if (Item != null)
                    {
                        Player.GetClient().GetHabbo().GetInventoryComponent().TryAddItem(Item);
                        Player.GetClient().SendMessage(new FurniListNotificationComposer(Item.Id, 1));
                        Player.GetClient().SendMessage(new PurchaseOKComposer());
                        Player.GetClient().SendMessage(new FurniListAddComposer(Item));
                        Player.GetClient().SendMessage(new FurniListUpdateComposer());
                        Player.GetClient().SendMessage(new RoomNotificationComposer("prizePresent", "message", "You've just recieved a present!"));
                    }
                }
            }

            if (!premied)
            {
                Player.GetClient().SendWhisper("Opps something is wrong!");
            }
            else if (amountLeft > 0)
            {
                amountLeft--;
                this.StringData.Split('-')[2] = amountLeft.ToString();
            }

            return true;
        }
    }
}
 

JayC

Always Learning
Aug 8, 2013
5,504
1,401
This is super confusing, but here is a breakdown of the layout for the current code:

[reward]-[often]-[amount]

[reward] - What the user gets
[often] - Not Used
[amount] - The total amount of rewards to be given out. Will subtract itself

Then your [reward] gets broken down further:

By separating with a semi-colon you can add multiple rewards [reward1];[reward2];[reward3]

Then to put in your reward it goes as follows:

[1],[2],[3]

Section 1: Type "0" for it to be a badge, otherwise you can leave it blank or put "1" so you know its a furniture.
Section 2: Code - Badge Code or furniture ID
Section 3: Percentage. If you put 50, you have a 50% chance of it working.

The top of this wired box does nothing. Total rewards limit, does nothing.
You can select 'Unique Rewards' to turn the probability of section 3 in the item turned off.

Here is an example of how to give 25 items with the ID of 217 in the furniture table, a 50% chance of receiving:

1,217,50-0-25

Here is an example of how to give 90 bundles of a badge named ADMIN with an item of 217 with 100% chance
1,217,100;0,ADMIN,100-0-90
 

Bran

habcrush.pw
Mar 13, 2017
1,784
1,600
This is super confusing, but here is a breakdown of the layout for the current code:

[reward]-[often]-[amount]

[reward] - What the user gets
[often] - Not Used
[amount] - The total amount of rewards to be given out. Will subtract itself

Then your [reward] gets broken down further:

By separating with a semi-colon you can add multiple rewards [reward1];[reward2];[reward3]

Then to put in your reward it goes as follows:

[1],[2],[3]

Section 1: Type "0" for it to be a badge, otherwise you can leave it blank or put "1" so you know its a furniture.
Section 2: Code - Badge Code or furniture ID
Section 3: Percentage. If you put 50, you have a 50% chance of it working.

The top of this wired box does nothing. Total rewards limit, does nothing.
You can select 'Unique Rewards' to turn the probability of section 3 in the item turned off.

Here is an example of how to give 25 items with the ID of 217 in the furniture table, a 50% chance of receiving:

1,217,50-0-25

Here is an example of how to give 90 bundles of a badge named ADMIN with an item of 217 with 100% chance
1,217,100;0,ADMIN,100-0-90
wat, i already know about the probability and stuff but it just doesn't work lmao
 

Users who are viewing this thread

Top