[Plusemulato]Dice counting whisper not working 100% Need help with coding

Unredable

Member
May 17, 2018
34
0
Hi I'm trying to make so that the user can get users to get notifited when they have used a dice but when I do it shows me not the number directly but the number before and when It's closed and I use the dice and open it up it gives me 0.

Here is the code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Plus.HabboHotel.Rooms;
using Plus.HabboHotel.Items;

namespace Plus.Communication.Packets.Incoming.Rooms.Furni
{
class ThrowDiceEvent : IPacketEvent
{
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
{

Room Room = Session.GetHabbo().CurrentRoom;

if (Room == null)
return;
Session.SendWhisper(Session.GetHabbo().Username + " has rolled number " + Convert.ToString(Item.ExtraData));
Item Item = Room.GetRoomItemHandler().GetItem(Packet.PopInt());

if (Item == null)
return;

Boolean hasRights = false;

if (Room.CheckRights(Session, false, true))
hasRights = true;


int request = Packet.PopInt();




Item.Interactor.OnTrigger(Session, Item, request, hasRights);




}
}
}

Pictures:
You must be registered for see images attach
You must be registered for see images attach


So what is it im trying to get it to?: I'm trying to make it so that it shows me the number they rolled and not the number before. And also that it doesn't show the number 0 when I roll open the dice.
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
In Item.cs around line 1,042 give or take there is a switch statement with the case InteractionType.DICE
This is where the dice physically get rolled.

Your's should look like

Code:
//string[] numbers = new string[] { "1", "2", "3", "4", "5", "6" };
                                //if (ExtraData == "-1")
                                //    ExtraData = RandomizeStrings(numbers)[0];
                                //UpdateState();
Ignore the comment lines, because I did mine differently but that was the original code.

What you are looking for is this:

Code:
string[] numbers = new string[] { "1", "2", "3", "4", "5", "6" };
                                String diceNumber = RandomizeStrings(numbers)[0];
                                if (ExtraData == "-1")
                                {
                                    ExtraData = diceNumber;
                                    GameClient InteractingClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(InteractingUser);
                                    InteractingClient.SendWhisper("You have rolled a " + diceNumber);
                                }
                                UpdateState();
 

Unredable

Member
May 17, 2018
34
0
So I replaced your code with mine and the dice refused to roll it just kept on rolling
In Item.cs around line 1,042 give or take there is a switch statement with the case InteractionType.DICE
This is where the dice physically get rolled.

Your's should look like

Code:
//string[] numbers = new string[] { "1", "2", "3", "4", "5", "6" };
                                //if (ExtraData == "-1")
                                //    ExtraData = RandomizeStrings(numbers)[0];
                                //UpdateState();
Ignore the comment lines, because I did mine differently but that was the original code.

What you are looking for is this:

Code:
string[] numbers = new string[] { "1", "2", "3", "4", "5", "6" };
                                String diceNumber = RandomizeStrings(numbers)[0];
                                if (ExtraData == "-1")
                                {
                                    ExtraData = diceNumber;
                                    GameClient InteractingClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(InteractingUser);
                                    InteractingClient.SendWhisper("You have rolled a " + diceNumber);
                                }
                                UpdateState();
 

Unredable

Member
May 17, 2018
34
0
I've checked every error log and there's no update on any error. The dice keeps on rolling, and when I remove this:
GameClient InteractingClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(InteractingUser);
InteractingClient.SendWhisper("You have rolled a " + diceNumber);
The dice will suddenly work


So this is what my code looks like:

case InteractionType.DICE:
{
string[] numbers = new string[] { "1", "2", "3", "4", "5", "6" };
String diceNumber = RandomizeStrings(numbers)[0];
if (ExtraData == "-1")
{
ExtraData = diceNumber;
GameClient InteractingClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(InteractingUser);
InteractingClient.SendWhisper("You have rolled a " + diceNumber);
}
UpdateState();
}
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
Try this
Code:
GameClient InteractingClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(InteractingUser);
If(InteractingClient != Null)
InteractingClient.SendWhisper("You have rolled a " + diceNumber);
InteractingClient may be null because you don't see the user id when they interact with the dice.
 

Unredable

Member
May 17, 2018
34
0
Try this
Code:
GameClient InteractingClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(InteractingUser);
If(InteractingClient != Null)
InteractingClient.SendWhisper("You have rolled a " + diceNumber);
InteractingClient may be null because you don't see the user id when they interact with the dice.
So I did this, and it keeps rolling
 
And If I move UpdateState(); above the code you sent me, the dice will roll I guess it's the text that's not just showing up now
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
So I did this, and it keeps rolling
 
And If I move UpdateState(); above the code you sent me, the dice will roll I guess it's the text that's not just showing up now
Ok in your InteractorDice.cs class make sure that under the Trigger method it sets Item.InteractingUser equal to the Session habbo ID
 

Unredable

Member
May 17, 2018
34
0
Ok in your InteractorDice.cs class make sure that under the Trigger method it sets Item.InteractingUser equal to the Session habbo ID
I did this
public void OnTrigger(GameClient InteractingUser, Item Item, int Request, bool HasRights)
{
RoomUser User = null;
if (InteractingUser != null)
User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(InteractingUser.GetHabbo().Id);
if (User == null)
return;
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
Dude your just making shit up that's not even what I said I can't bother with people that just blindly paste code . Hire a developer. Goodluck
 

Users who are viewing this thread

Top