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:
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;
}
}
}
}