PlusEmu - Command ONLY for Friends ???

uttmmmm5

Member
May 18, 2016
110
5
Hey there,
I have a question!
I start coding a few very very simple Commands.
Now I am coding a "shoot"-Command ... I know, nothing special and not even hard but this is my third command :)
My question now is: How I can do that this command can only be run if the target user is my friend?

Here the Code till now:
Code:
using System;
using Plus.HabboHotel.Rooms;
using Plus.HabboHotel.GameClients;
using Plus.Communication.Packets.Outgoing.Rooms.Chat;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun
{
    class Shoot : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_shoot"; }
        }
        public string Parameters
        {
            get { return "%username%"; }
        }
        public string Description
        {
            get { return "Erschieße einen anderen Hubba!"; }
        }
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Gib den Usernamen des Hubba's an den du töten möchtest!");
                return;
            }

            GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);
            if (TargetClient == null)
            {
                Session.SendWhisper("Dieser Hubba konnte nicht gefunden werden. Vielleicht ist er nicht online.");
                return;
            }

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Id);
            if (User == null)
            {
                Session.SendWhisper("Dieser Hubba konnte nicht gefunden werden. Vielleicht ist er nicht online oder nicht im Raum.");
                return;
            }

            RoomUser TargetUser = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Id);
            if (TargetUser.ProtectEnabled)
            {
                Session.SendWhisper("Oops, du kannst keinen Hubba erschießen solange er den Protect-Befehl aktiviert hat.");
                return;
            }

            RoomUser ThisUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (ThisUser == null)
                return;

            if (!((Math.Abs(User.X - ThisUser.X) >= 2 && (Math.Abs(User.Y - ThisUser.Y) >= 2))))
            {

                Room.SendPacket(new ChatComposer(ThisUser.VirtualId, "*schießt " + TargetClient.GetHabbo().Username + " den Kopf weg*", 0, User.LastBubble));
                User.ApplyEffect(93);
            }
            else
            {
                Session.SendWhisper("Dieser Hubba ist zu weit entfernt. Geh näher ran.");
                return;
            }
        }
    }
}
 

uttmmmm5

Member
May 18, 2016
110
5
Code:
if (Session.GetHabbo().GetMessenger().FriendshipExists(TargetClient.GetHabbo().Id))
Perfect!!!! Thank you!! Works's perfect!

Here is a protect code that protect a user from :shoot but the if you switch the room the command is disabled again.
Can you tell me what i must do that the command is still activated if i switch to another room?
Here is the code:
Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Plus.HabboHotel.Rooms;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator.Fun
{
    class ProtectCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_protect"; }
        }

        public string Parameters
        {
            get { return ""; }
        }

        public string Description
        {
            get { return "Schützt dich vor :shoot und :massaker"; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (User == null)

                return;

            User.ProtectEnabled = !User.ProtectEnabled;
            Room.GetGameMap().GenerateMaps();


        }
    }
}
 

SOUL

┼ ┼ ┼
Nov 10, 2015
224
45
Perfect!!!! Thank you!! Works's perfect!

Here is a protect code that protect a user from :shoot but the if you switch the room the command is disabled again.
Can you tell me what i must do that the command is still activated if i switch to another room?
Here is the code:
Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Plus.HabboHotel.Rooms;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator.Fun
{
    class ProtectCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_protect"; }
        }

        public string Parameters
        {
            get { return ""; }
        }

        public string Description
        {
            get { return "Schützt dich vor :shoot und :massaker"; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (User == null)

                return;

            User.ProtectEnabled = !User.ProtectEnabled;
            Room.GetGameMap().GenerateMaps();


        }
    }
}

What do you mean the command is disabled? I'm confused
 

uttmmmm5

Member
May 18, 2016
110
5
What do you mean the command is disabled? I'm confused
I mean:
You are in Room 1 and run the command ;Protect.
Now protect is on and nobody can :shoot you.
The you go in Room 2 and then protect is off because you changed the room.
How I can do, that if you run ;Protect the ;Protect is on till you close the client or till you run :shoot to another user?
 
Last edited:

Users who are viewing this thread

Top