PlusEMU Support thread.

Status
Not open for further replies.

jordeyyy

New Member
Sep 28, 2012
1
0
wf_act_give_reward
I do have a working wf_act_give_reward code.
Add this to your GiveRewardBox.cs
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;

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 = PlusEnvironment.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().SendNotification("De prijs is vandaag niet meer te halen! Sorry!");
                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, "Oeps! Het lijkt erop dat je deze Badge al hebt!", 0, User.LastBubble));
                    else
                    {
                        Player.GetBadgeComponent().GiveBadge(code, true, Player.GetClient());
                        Player.GetClient().SendNotification("He! Je hebt zojuist een badge gekregen!");
                    }
                }
                else
                {
                    ItemData ItemData = null;

                    if (!PlusEnvironment.GetGame().GetItemManager().GetItem(int.Parse(code), out ItemData))
                    {
                        Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, "Geen bekende item met 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().SendNotification("Je hebt zojuist een beloning gekregen! Check je inventaris!");
                    }
                }
            }

            if (!premied)
            {
                Player.GetClient().SendNotification("Je hebt deze keer geen prijs gekregen! Volgende keer beter!");
            }
            else if (amountLeft > 1)
            {
                amountLeft--;
                this.StringData.Split('-')[2] = amountLeft.ToString();
            }

            return true;
        }
    }
}
Only problem i have at the moment is that the Limit of uses and the limit of uses per user isn't working yet.. so if anyone knows how to fix that that would be great.
 

NeedForSpreed

Member
May 18, 2014
326
71
what skype username. i can fix it when i have time
You know you're not allowed to offer help via skype, it's a new rule. Please read/re-read the rules. :)
6f392bb251cafa3d82d0f47a8be43de2.jpg
 

MayoMayn

BestDev
Oct 18, 2016
1,423
683
yo, I'm having bit of a trouble to get sockets working. No errors were shown when the function was executed, but nothing happened. I've tried various different commands and data, but still nothing. Any one who actually got this to work?
PHP:
function MUS($command, $data="") {

    $MUSdata = $command . chr(1) . $data;
    $socket = socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp')) or die ('Could not create socket.\n');
    socket_connect($socket, 'VPS_IP', 30001) or die('Could not connect socket.\n');
    socket_send($socket, $MUSdata, strlen($MUSdata), MSG_DONTROUTE) or die('Could not send socket data.\n');
    socket_close($socket);

}

MUS("kill", "EXON");
btw, is it possible to run a command that gives users a certain item and badge aswell as update stats in usertable? Got it sorted out in PHP, but since people would have to reload their client, I'd rather use sockets, if they'd actually work..
 

MayoMayn

BestDev
Oct 18, 2016
1,423
683
What I mean is, that it progresses to a new level every 5-10 minutes, so that when I've in reality been online for ~60 minutes, it counts me as I've been online for ~3600 minutes
 

Hayy, anyone knows why this doesn't work in PlusEmu?
Why it doesn't work? Check the wired statement dude, "user walks on" you simply don't walk onto something if it gets summoned beneath you. You need to do a "if furni has users" and then a "user collision" which teleports them back.
 
Status
Not open for further replies.

Users who are viewing this thread

Top