Wired Give Reward - HabboEmulator

Status
Not open for further replies.

cammy

Member
May 15, 2014
481
238
Using Westys HabboEmulator - .

Does anyone have a fix for the staff wired give reward? It doesn't save. :( Maybe I'm filling it in wrong?

6a8yKug.png
 
Last edited:

cammy

Member
May 15, 2014
481
238
wired_id is 40. Yes it seems to be coded. I'm using westys HabboEmulator.

using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Collections.Concurrent;

using Emulator.Communication.Packets.Incoming;
using Emulator.HabboHotel.Rooms;

namespace Emulator.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>();

if (this.SetItems.Count > 0)
this.SetItems.Clear();
}

public void HandleSave(ClientPacket Packet)
{
if (this.SetItems.Count > 0)
this.SetItems.Clear();

int Unknown = Packet.PopInt();
int Time = Packet.PopInt();
string Message = Packet.PopString();

//this.StringData = Time + ";" + Message;
}

public bool Execute(params object[] Params)
{

return true;
}
}
}
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

namespace Emulator.HabboHotel.Items.Wired
{
static class WiredBoxTypeUtility
{
public static WiredBoxType FromWiredId(int Id)
{
switch (Id)
{
default:
return WiredBoxType.None;
case 1:
return WiredBoxType.TriggerUserSays;
case 2:
return WiredBoxType.TriggerStateChanges;
case 3:
return WiredBoxType.TriggerRepeat;
case 4:
return WiredBoxType.TriggerRoomEnter;
case 8:
return WiredBoxType.TriggerWalkOnFurni;
case 9:
return WiredBoxType.TriggerWalkOffFurni;
case 5:
return WiredBoxType.EffectShowMessage;
case 6:
return WiredBoxType.EffectTeleportToFurni;
case 7:
return WiredBoxType.EffectToggleFurniState;
case 10:
return WiredBoxType.EffectKickUser;
case 11:
return WiredBoxType.ConditionFurniHasUsers;
case 12:
return WiredBoxType.ConditionFurniHasFurni;
case 13:
return WiredBoxType.ConditionTriggererOnFurni;
case 14:
return WiredBoxType.EffectMatchPosition;
case 21:
return WiredBoxType.ConditionIsGroupMember;
case 22:
return WiredBoxType.ConditionIsNotGroupMember;
case 23:
return WiredBoxType.ConditionTriggererNotOnFurni;
case 24:
return WiredBoxType.ConditionFurniHasNoUsers;
case 25:
return WiredBoxType.ConditionIsWearingBadge;
case 26:
return WiredBoxType.ConditionIsWearingFX;
case 27:
return WiredBoxType.ConditionIsNotWearingBadge;
case 28:
return WiredBoxType.ConditionIsNotWearingFX;
case 29:
return WiredBoxType.ConditionMatchStateAndPosition;
case 30:
return WiredBoxType.ConditionUserCountInRoom;
case 31:
return WiredBoxType.ConditionUserCountDoesntInRoom;
case 32:
return WiredBoxType.EffectMoveAndRotate;
case 33:
return WiredBoxType.ConditionDontMatchStateAndPosition;
case 34:
return WiredBoxType.ConditionFurniTypeMatches;
case 35:
return WiredBoxType.ConditionFurniTypeDoesntMatch;
case 36:
return WiredBoxType.ConditionFurniHasNoFurni;
case 37:
return WiredBoxType.EffectMoveFurniToNearestUser;
case 38:
return WiredBoxType.EffectMoveFurniFromNearestUser;
case 39:
return WiredBoxType.EffectMuteTriggerer;
case 40:
return WiredBoxType.EffectGiveReward;

case 41:
return WiredBoxType.AddonRandomEffect;
case 42:
return WiredBoxType.TriggerGameStarts;
case 43:
return WiredBoxType.TriggerGameEnds;
case 44:
return WiredBoxType.TriggerUserFurniCollision;
case 45:
return WiredBoxType.EffectMoveFurniToNearestUser;
case 46:
return WiredBoxType.EffectExecuteWiredStacks;
case 47:
return WiredBoxType.EffectTeleportBotToFurniBox;
case 48:
return WiredBoxType.EffectBotChangesClothesBox;
case 49:
return WiredBoxType.EffectBotMovesToFurniBox;
case 50:
return WiredBoxType.EffectBotCommunicatesToAllBox;
case 51:
return WiredBoxType.EffectBotCommunicatesToUserBox;
case 52:
return WiredBoxType.EffectBotFollowsUserBox;
case 53:
return WiredBoxType.EffectBotGivesHanditemBox;
case 54:
return WiredBoxType.ConditionActorHasHandItemBox;
case 55:
return WiredBoxType.ConditionActorIsInTeamBox;
case 56:
return WiredBoxType.EffectAddActorToTeam;
case 57:
return WiredBoxType.EffectRemoveActorFromTeam;
case 58:
return WiredBoxType.TriggerUserSaysCommand;
case 59:
return WiredBoxType.EffectSetRollerSpeed;
case 60:
return WiredBoxType.EffectRegenerateMaps;
case 61:
return WiredBoxType.EffectGiveUserBadge;
case 64:
return WiredBoxType.HighscoreClassicAlltime;
}
}

public static int GetWiredId(WiredBoxType Type)
{
switch (Type)
{
case WiredBoxType.TriggerUserSays:
case WiredBoxType.TriggerUserSaysCommand:
case WiredBoxType.ConditionMatchStateAndPosition:
return 0;
case WiredBoxType.TriggerWalkOnFurni:
case WiredBoxType.TriggerWalkOffFurni:
case WiredBoxType.ConditionFurniHasUsers:
case WiredBoxType.ConditionFurniHasFurni:
case WiredBoxType.ConditionTriggererOnFurni:
return 1;
case WiredBoxType.EffectMatchPosition:
return 3;
case WiredBoxType.EffectMoveAndRotate:
case WiredBoxType.TriggerStateChanges:
return 4;
case WiredBoxType.ConditionUserCountInRoom:
return 5;
case WiredBoxType.ConditionActorIsInTeamBox:
case WiredBoxType.TriggerRepeat:
return 6;
case WiredBoxType.TriggerRoomEnter:
case WiredBoxType.EffectShowMessage:
return 7;
case WiredBoxType.TriggerGameStarts:
case WiredBoxType.TriggerGameEnds:
case WiredBoxType.EffectTeleportToFurni:
case WiredBoxType.EffectToggleFurniState:
case WiredBoxType.ConditionFurniTypeMatches:
return 8;
case WiredBoxType.EffectGiveUserBadge:
case WiredBoxType.EffectRegenerateMaps:
case WiredBoxType.EffectKickUser:
case WiredBoxType.EffectSetRollerSpeed:
return 7;
case WiredBoxType.EffectAddActorToTeam:
return 9;
case WiredBoxType.EffectRemoveActorFromTeam:
case WiredBoxType.ConditionIsGroupMember:
return 10;
case WiredBoxType.TriggerUserFurniCollision:
case WiredBoxType.ConditionIsWearingBadge:
case WiredBoxType.EffectMoveFurniToNearestUser:
return 11;
case WiredBoxType.ConditionIsWearingFX:
case WiredBoxType.EffectMoveFurniFromNearestUser:
return 12;
case WiredBoxType.ConditionFurniHasNoUsers:
return 14;
case WiredBoxType.ConditionTriggererNotOnFurni:
return 15;
case WiredBoxType.ConditionUserCountDoesntInRoom:
return 16;
case WiredBoxType.EffectGiveReward:
return 17;
case WiredBoxType.EffectExecuteWiredStacks:
case WiredBoxType.ConditionFurniHasNoFurni:
return 18;
case WiredBoxType.ConditionFurniTypeDoesntMatch:
return 19;
case WiredBoxType.EffectMuteTriggerer:
return 20;
case WiredBoxType.ConditionIsNotGroupMember:
case WiredBoxType.EffectTeleportBotToFurniBox:
return 21;
case WiredBoxType.ConditionIsNotWearingBadge:
case WiredBoxType.EffectBotMovesToFurniBox:
return 22;
case WiredBoxType.ConditionIsNotWearingFX:
case WiredBoxType.EffectBotCommunicatesToAllBox:
return 23;
case WiredBoxType.EffectBotGivesHanditemBox:
return 24;
case WiredBoxType.EffectBotFollowsUserBox:
case WiredBoxType.ConditionActorHasHandItemBox:
return 25;
case WiredBoxType.EffectBotChangesClothesBox:
return 26;
case WiredBoxType.EffectBotCommunicatesToUserBox:
return 27;
}
return 0;
}

public static List<int> ContainsBlockedTrigger(IWiredItem Box, ICollection<IWiredItem> Triggers)
{
List<int> BlockedItems = new List<int>();

if (Box.Type != WiredBoxType.EffectShowMessage && Box.Type != WiredBoxType.EffectMuteTriggerer && Box.Type != WiredBoxType.EffectTeleportToFurni && Box.Type != WiredBoxType.EffectKickUser && Box.Type != WiredBoxType.ConditionTriggererOnFurni)
return BlockedItems;

foreach (IWiredItem Item in Triggers)
{
if (Item.Type == WiredBoxType.TriggerRepeat)
{
if (!BlockedItems.Contains(Item.Item.GetBaseItem().SpriteId))
BlockedItems.Add(Item.Item.GetBaseItem().SpriteId);
else continue;
}
else continue;
}

return BlockedItems;
}

public static List<int> ContainsBlockedEffect(IWiredItem Box, ICollection<IWiredItem> Effects)
{
List<int> BlockedItems = new List<int>();

if (Box.Type != WiredBoxType.TriggerRepeat)
return BlockedItems;

bool HasMoveRotate = Effects.Where(x => x.Type == WiredBoxType.EffectMoveAndRotate).ToList().Count > 0;
bool HasMoveNear = Effects.Where(x => x.Type == WiredBoxType.EffectMoveFurniToNearestUser).ToList().Count > 0;

foreach (IWiredItem Item in Effects)
{
if (Item.Type == WiredBoxType.EffectKickUser || Item.Type == WiredBoxType.EffectMuteTriggerer || Item.Type == WiredBoxType.EffectShowMessage || Item.Type == WiredBoxType.EffectTeleportToFurni || Item.Type == WiredBoxType.EffectBotFollowsUserBox)
{
if (!BlockedItems.Contains(Item.Item.GetBaseItem().SpriteId))
BlockedItems.Add(Item.Item.GetBaseItem().SpriteId);
else continue;
}
else if((Item.Type == WiredBoxType.EffectMoveFurniToNearestUser && HasMoveRotate) || (Item.Type == WiredBoxType.EffectMoveAndRotate && HasMoveNear))
{
if (!BlockedItems.Contains(Item.Item.GetBaseItem().SpriteId))
BlockedItems.Add(Item.Item.GetBaseItem().SpriteId);
else continue;
}
}

return BlockedItems;
}
}
}
 
Last edited:

wavekun

New Member
May 29, 2016
9
3
try this
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Collections.Concurrent;

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

namespace Emulator.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 = HabboEnvironment.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().SendWhisper(Params[2] + "you just received new badge!");
}
}
else
{
ItemData ItemData = null;

if (!HabboEnvironment.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().SendNotification("You have received a gift! Check your inventory.");
}
}
}

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

return true;
}
}
}
 
Last edited:
Status
Not open for further replies.

Users who are viewing this thread

Top