Help with coding (Making only a room owner see message, me and staff members)

Unredable

Member
May 17, 2018
34
0
Hi I've done a trading notification but need help with making only staff members, room owners, and myself who made the trade start and the person i'm trading with get this message.

Here is the code:
RoomUser TargetUser = Room.GetRoomUserManager().GetRoomUserByVirtualId(Packet.PopInt());
Room.SendMessage(new ShoutComposer(User.VirtualId, "Startar ett byte av möbler med: " + TargetUser.GetUsername() + " ", 0, User.LastBubble));

if (TargetUser == null || TargetUser.GetClient() == null || TargetUser.GetClient().GetHabbo() == null)
return;
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
So first of all, You shouldn't be using the variable TargetUser until you have checked to see if Targetuser is null or not (If it ever is null, it will throw an exception)

Also there is a list of things it checks, before the user starts the trade, you want to let those run their course before showing the alert as well. For example, the next line tests if the user is ALREADY trading and returns if they are. So it would show an alert saying they started trading, even if they haven't..

Give me 5 minutes I'll give you the code you are looking for.
 
Update:

In your database you have a table called "permissions"
Add a new entry, with the next available ID.
Permission should be user_trade_alerts and the description can read Whisper to the user when new trades have started

Under permissions_rights table you can use the next available ID along with the group_id being the rank and the permission_id being the next available ID that you used in the permissions table to assign that rank the ability to see the whispers for when users start a trade.

At the bottom of that file InitTradeEvent.cs you can add this block of code
Underneath
Code:
Room.TryStartTrade(User, TargetUser);

Add:

Code:
User.GetClient().SendWhisper("You have started a trade with " + TargetUser.GetClient().GetHabbo().Username);

            foreach (RoomUser roomuser in Room.GetRoomUserManager().GetRoomUsers().ToList())
            {
               if (roomuser == User)  continue;
                if(Room.OwnerId == roomuser.HabboId || roomuser.GetClient().GetHabbo().GetPermissions().HasRight("user_trade_alerts"))
                    roomuser.GetClient().SendWhisper(User.GetClient().GetHabbo().Username + " has started a trade with " + TargetUser.GetClient().GetHabbo().Username);
            }
 

Unredable

Member
May 17, 2018
34
0
So first of all, You shouldn't be using the variable TargetUser until you have checked to see if Targetuser is null or not (If it ever is null, it will throw an exception)

Also there is a list of things it checks, before the user starts the trade, you want to let those run their course before showing the alert as well. For example, the next line tests if the user is ALREADY trading and returns if they are. So it would show an alert saying they started trading, even if they haven't..

Give me 5 minutes I'll give you the code you are looking for.
 
Update:

In your database you have a table called "permissions"
Add a new entry, with the next available ID.
Permission should be user_trade_alerts and the description can read Whisper to the user when new trades have started

Under permissions_rights table you can use the next available ID along with the group_id being the rank and the permission_id being the next available ID that you used in the permissions table to assign that rank the ability to see the whispers for when users start a trade.

At the bottom of that file InitTradeEvent.cs you can add this block of code
Underneath
Code:
Room.TryStartTrade(User, TargetUser);

Add:

Code:
User.GetClient().SendWhisper("You have started a trade with " + TargetUser.GetClient().GetHabbo().Username);

            foreach (RoomUser roomuser in Room.GetRoomUserManager().GetRoomUsers().ToList())
            {
               if (roomuser == User)  continue;
                if(Room.OwnerId == roomuser.HabboId || roomuser.GetClient().GetHabbo().GetPermissions().HasRight("user_trade_alerts"))
                    roomuser.GetClient().SendWhisper(User.GetClient().GetHabbo().Username + " has started a trade with " + TargetUser.GetClient().GetHabbo().Username);
            }


Thank you! Much love
 

Users who are viewing this thread

Top