Advertisement
Guest User

Untitled

a guest
Feb 14th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.77 KB | None | 0 0
  1. using Butterfly.Communication.Packets.Outgoing;
  2. using Butterfly.HabboHotel.GameClients;
  3. using Butterfly.HabboHotel.Rooms.Games;
  4. using System;
  5.  
  6. namespace Butterfly.HabboHotel.Rooms.Chat.Commands.Cmd
  7. {
  8.     class Mordre : IChatCommand
  9.     {
  10.         public void Execute(GameClient Session, Room Room, RoomUser UserRoom, string[] Params)
  11.         {
  12.             if (Params.Length >= 1 && ButterflyEnvironment.ZombieInfectionMode)
  13.             {
  14.                 string Username = Params[1];
  15.                 bool CanInfect = false;
  16.  
  17.                 GameClient Player = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(Username);
  18.  
  19.                 if (Player == null || Player.GetHabbo() == null || Player.GetHabbo().CurrentRoomId != Session.GetHabbo().CurrentRoomId || Player.GetHabbo().IsZombie)
  20.                     return;
  21.  
  22.                 if (!Session.GetHabbo().IsZombie)
  23.                 {
  24.                     return;
  25.                 }
  26.  
  27.                 Room RoomCurrent = Session.GetHabbo().CurrentRoom;
  28.                 RoomUser Me = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Username);
  29.                 RoomUser Them = Room.GetRoomUserManager().GetRoomUserByHabbo(Player.GetHabbo().Username);
  30.  
  31.                 if (Room == null || Me == null || Them == null)
  32.                     return;
  33.  
  34.                 //if ((Them.X == Me.X - 1) || (Them.X == Me.X + 1) || (Them.Y == Me.Y - 1) || (Them.Y == Me.Y + 1))
  35.  
  36.                 if (Them.Y == Me.Y && Them.X == Me.X - 1)
  37.                 {
  38.                     CanInfect = true;
  39.                 }
  40.                 else if (Them.X == Me.X && Them.Y == Me.Y - 1)
  41.                 {
  42.                     CanInfect = true;
  43.                 }
  44.                 else if (Them.X == Me.X && Them.Y == Me.Y + 1)
  45.                 {
  46.                     CanInfect = true;
  47.                 }
  48.                 else if (Them.Y == Me.Y && Them.X == Me.X + 1)
  49.                 {
  50.                     CanInfect = true;
  51.                 }
  52.  
  53.                 if (CanInfect)
  54.                 {
  55.                     string[] SplitLook = Player.GetHabbo().Look.Split('.');
  56.                     string FullFaceCode = String.Empty;
  57.                     string FaceType = String.Empty;
  58.                     string FaceColor = String.Empty;
  59.                     int CurrentLoop = 1;
  60.  
  61.                     foreach (string LookCode in SplitLook)
  62.                     {
  63.                         if (LookCode.StartsWith("hd"))
  64.                         {
  65.                             FullFaceCode = LookCode;
  66.  
  67.                             string[] SplitFace = new string[3];
  68.                             SplitFace = LookCode.Split('-');
  69.  
  70.                             foreach (string FaceCode in SplitFace)
  71.                             {
  72.                                 if (CurrentLoop == 1)
  73.                                 {
  74.                                     CurrentLoop += 1;
  75.                                     continue;
  76.                                 }
  77.                                 else if (CurrentLoop == 2)
  78.                                 {
  79.                                     FaceType = FaceCode;
  80.                                     CurrentLoop += 1;
  81.                                     continue;
  82.                                 }
  83.                                 else if (CurrentLoop == 3)
  84.                                 {
  85.                                     FaceColor = FaceCode;
  86.                                     break;
  87.                                 }
  88.                             }
  89.                         }
  90.                     }
  91.  
  92.                     Player.GetHabbo().LookBeforeWorking = Player.GetHabbo().Look;
  93.                     Player.GetHabbo().Look = Player.GetHabbo().Look.Replace(FullFaceCode, "hd-" + FaceType + "-97545");
  94.  
  95.                     Me.SendWhisperChat(" "+ Session + "* vient d'infecter " + Player.GetHabbo().Username + " ! *");
  96.                     Them.SendWhisperChat(" "+Player + " * est maintenant un Zombie*");
  97.  
  98.                     ServerPacket RoomUpdate = new ServerPacket(ServerPacketHeader.UserChangeMessageComposer);
  99.                     RoomUpdate.WriteInteger(Them.VirtualId);
  100.                     RoomUpdate.WriteString(Player.GetHabbo().Look);
  101.                     RoomUpdate.WriteString(Player.GetHabbo().Gender.ToLower());
  102.                     RoomUpdate.WriteString(Player.GetHabbo().Motto);
  103.                     RoomUpdate.WriteInteger(Player.GetHabbo().AchievementPoints);
  104.                     Room.SendPacket(RoomUpdate);
  105.  
  106.                     Player.GetHabbo().IsZombie = true;
  107.                     Player.GetHabbo().HitPoints = 300;
  108.  
  109.                     Player.SendNotification("You are now a Zombie. To infect other players, type :infect [username]");
  110.                 }
  111.             }
  112.         }
  113.     }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement