Beispiel #1
0
        public static void FriendInvite(WorldClient pClient, Packet pPacket)
        {
            string sender, receiver;
            if (!pPacket.TryReadString(out sender, 16) ||
                !pPacket.TryReadString(out receiver, 16))
            {
                Log.WriteLine(LogLevel.Warn, "Error reading friend invite.");
                return;
            }

            WorldCharacter inviter = pClient.Character;
            WorldClient invitee = ClientManager.Instance.GetClientByCharname(receiver);
            if (invitee == null)
            {
                //character not found
                using (var pack = new Packet(SH21Type.FriendInviteResponse))
                {
                    pack.WriteString(sender, 16);
                    pack.WriteString(receiver, 16);
                    pack.WriteUShort(0x0946);	// Cannot find ${Target}

                    pClient.SendPacket(pack);
                }
            }
            else if (receiver == sender)
            {
                using (var pack = new Packet(SH21Type.FriendInviteResponse))
                {
                    pack.WriteString(sender, 16);
                    pack.WriteString(receiver, 16);
                    pack.WriteUShort(0x0942);	// You cannot add yourself to your Buddy List.

                    pClient.SendPacket(pack);
                }
            }
            else if (inviter.Friends.Find(f => f.Name == receiver) != null)
            {
                using (var pack = new Packet(SH21Type.FriendInviteResponse))
                {
                    pack.WriteString(sender, 16);
                    pack.WriteString(receiver, 16);
                    pack.WriteUShort(0x0945);	// {Target} is already registered in the friends list.
                    pClient.SendPacket(pack);
                }
            }
            else
            {
                using (var pack = new Packet(SH21Type.FriendInviteRequest))
                {
                    pack.WriteString(receiver, 16);
                    pack.WriteString(sender, 16);

                    invitee.SendPacket(pack);
                }
            }
        }
Beispiel #2
0
        public static void ChangeFromGuildAcademyToResponse(WorldClient client, Packet packet)
        {
            string GuildName;
              string RequestName;
              bool answer;
              if (!packet.TryReadString(out GuildName, 16) || !packet.TryReadString(out RequestName, 16)|| (!packet.TryReadBool(out answer) || !client.Character.IsInGuildAcademy))
                  return;
             if (answer)
            {
                GuildAcademyMember pMember = client.Character.GuildAcademy.Members.Find(m => m.Character.Character.Name == RequestName);
                if (pMember == null)
                    return;
                pMember.Character.IsInGuildAcademy = false;
                pMember.Academy.RemoveMember(pMember);
               pMember.Character.GuildAcademy.Guild.AddMember(pMember.Character, GuildRank.Member, Program.DatabaseManager.GetClient().GetConnection(), true, true);

                pMember.Character.Guild = pMember.Character.GuildAcademy.Guild;
                pMember.Character.IsInGuild = true;
             using (var pack = new Packet(SH38Type.SendJoinGuildFromAcademy))
             {
                 //this packet remove character from academy List and added to GuildList
                 pack.WriteString(RequestName, 16);
                 pack.WriteString(client.Character.Character.Name, 16);
                 pack.WriteByte(6);//rank
                 pack.WriteInt(0);//unk
                 pack.WriteUShort(0);//korp
                 pack.Fill(64, 0x00);//unk
                 pack.WriteByte(true ? (byte)0x95 : (byte)0x00);// (this.isOnline ? (byte)0x95 : (byte)0x00);
                 pack.Fill(3, 0x00);//unk
                 pack.WriteByte(pMember.Character.Character.Job);
                 pack.WriteByte(pMember.Character.Character.CharLevel);
                 pack.Fill(13, 0x00);//unk
                 client.Character.GuildAcademy.Guild.Broadcast(pack);
                 client.Character.GuildAcademy.Broadcast(pack);
                 }
             }
             using (var p2 = new Packet(SH4Type.CharacterGuildinfo))
             {
                 client.Character.Guild.WriteGuildInfo(packet);
                 client.SendPacket(p2);
             }
             using (var pack = new Packet(SH29Type.GuildMemberJoined))
             {
                 pack.WriteString(client.Character.Character.Name, 16);
                 client.Character.GuildAcademy.Guild.Broadcast(pack);
                 client.Character.GuildAcademy.Broadcast(pack);

             }
             using (var pack = new Packet(SH29Type.ChangeResponse))
             {
                 pack.WriteUShort(3137);//unk
                 pack.WriteByte(3);
                 pack.Fill(2, 0x00);//unk
                 client.SendPacket(pack);
             }
        }
Beispiel #3
0
 public static void Wisper(WorldClient client, Packet packet)
 {
     string toname;
     byte messagelenght;
     if (packet.TryReadString(out toname, 16) && packet.TryReadByte(out messagelenght))
     {
         string message;
         if (!packet.TryReadString(out message, messagelenght))
         {
             return;
         }
         WorldClient toChar = ClientManager.Instance.GetClientByCharname(toname);
         if (toChar != null)
         {
             using (var frompacket = new Packet(SH8Type.WisperFrom))
             {
                 frompacket.WriteString(client.Character.Character.Name, 16);
                 if (!toChar.Character.BlocketUser.Contains(client.Character.Character.Name))
                 {
                     frompacket.WriteByte(0);
                 }
                 else
                 {
                     frompacket.WriteByte(12);//blocket notdisplay message
                 }
                 frompacket.WriteByte(messagelenght);
                 frompacket.WriteString(message, messagelenght);
                 toChar.SendPacket(frompacket);
             }
             using (var pack = new Packet(SH8Type.WisperTo))
             {
                 pack.WriteString(toname, 16);
                 pack.WriteByte(messagelenght);
                 pack.WriteString(message, messagelenght);
                 client.SendPacket(pack);
             }
         }
         else
         {
             //target not found
             using (var pp = new Packet(SH8Type.WisperTargetNotfound))
             {
                 pp.WriteUShort(3945);//unk
                 pp.WriteString(toname, 16);
                 client.SendPacket(pp);
             }
         }
     }
 }
Beispiel #4
0
        public void BroadcastGuildName()
        {
            var packet = new Packet(SH29Type.GuildNameResult);
            packet.WriteInt(Academy.Guild.ID);
            packet.WriteString(Academy.Guild.Name, 16);

            Character.BroucastPacket(packet);
        }
Beispiel #5
0
        public void BroadcastGuildName()
        {
            var packet = new Packet(SH29Type.GuildNameResult);
            packet.WriteInt(Guild.ID);
            packet.WriteString(Guild.Name, 16);

            BroadcastManager.Instance.BroadcastInRange(Character, packet, false);
        }
Beispiel #6
0
 public static void SendQuestion(ZoneCharacter character, Question question, ushort range)
 {
     using (var packet = new Packet(SH15Type.Question))
     {
         packet.WriteString(question.Text, 129);
         packet.WriteUShort(character.MapObjectID);     // Obj id
         packet.WriteInt(character.Position.X);
         packet.WriteInt(character.Position.Y);
         packet.WriteUShort(range);        // Distance how far your allowed to run when the question window is closed by Client
         packet.WriteByte((byte)question.Answers.Count);
         for (byte i = 0; i < question.Answers.Count; ++i)
         {
             packet.WriteByte(i);
             packet.WriteString(question.Answers[i], 32);
         }
         character.Client.SendPacket(packet);
     }
 }
Beispiel #7
0
 public static void SendAcademyResponse(WorldClient pClient,string GuildName, GuildAcademyResponse Response)
 {
     using (var packet = new Packet(SH38Type.AcademyResponse))
     {
         packet.WriteString(GuildName, 16);
         packet.WriteUShort((ushort)Response);
         pClient.SendPacket(packet);
     }
 }
Beispiel #8
0
 public static void SendZoneServerIP(WorldClient client, ZoneConnection info)
 {
     using (var packet = new Packet(SH4Type.ServerIP))
     {
         packet.WriteString(info.IP, 16);
         packet.WriteUShort(info.Port);
         client.SendPacket(packet);
     }
 }
Beispiel #9
0
 public static void SendChangeZone(ZoneCharacter character, ushort mapid, int x, int y, string ip, ushort port, ushort randomid)
 {
     using (var packet = new Packet(SH6Type.ChangeZone))
     {
         packet.WriteUShort(mapid);
         packet.WriteInt(x);
         packet.WriteInt(y);
         packet.WriteString(Settings.Instance.IP, 16);
         packet.WriteUShort(port);
         packet.WriteUShort(randomid);
         character.Client.SendPacket(packet);
     }
 }
Beispiel #10
0
 public void SendRemoveFromGuildStore(GuildStoreAddFlags Flags, string Charname, long Value, long NewGuildMoney = 0, ushort ItemID = 0xFFFF)
 {
     using (var packet = new Packet(SH38Type.RemoveFromGuildStore))
     {
         packet.WriteByte(0);//unk
         packet.WriteByte((byte)Flags);
         packet.WriteString(Charname, 16);
         packet.WriteUShort(ItemID);
         packet.WriteByte(0);
         packet.WriteLong(Value);
         packet.WriteLong(NewGuildMoney);//new GuildMoney
         Guild.Broadcast(packet);
     }
 }
Beispiel #11
0
 public static void ChangeCharNameHandler(WorldClient client, Packet packet)
 {
     byte Character_slot;
     string charname;
     if (!packet.TryReadByte(out Character_slot) || !packet.TryReadString(out charname, 16))
         return;
     using (var pack = new Packet(SH5Type.SendCharacterChangeNewName))
     {
         pack.WriteByte(Character_slot);
         pack.WriteString(charname,16);
         pack.WriteUShort(208);//Responsecode?
     }
     //Todo ChangeinDatabase
 }
Beispiel #12
0
        public static void MasterList(WorldClient client, Packet packet)
        {
            Dictionary<string, string> list = new Dictionary<string, string>
            {
                {"Char1", "hier ist Char1"},
                {"Char2", "hier ist Char2"}
            };
            using (var ppacket = new Packet(SH14Type.GroupList))
            {
                ppacket.WriteHexAsBytes("00 00 14 01 01 00 01 00 00 00");
                ppacket.WriteInt(list.Count);
                foreach (KeyValuePair<string, string> stat in list)
                {
                    // Note - teh f**k?
                    ppacket.WriteHexAsBytes("");
                    ppacket.WriteString("haha", 16);
                    ppacket.WriteString("1234567890123456789012345678901234567890123456", 46);
                    ppacket.WriteHexAsBytes("00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 8C 8E CD 00 88 49 DF 4E B3 08 4C 00 78 26 43 00 01 00 00 00 5A 68 42 00 18 FE 64 02 40 55 DF 4E 08 27 4D 00 94 FF 64 02 24 00 00 00 BD 68 42 00 87 BE");
                }

                list.Clear();
                client.SendPacket(ppacket);
            }
        }
Beispiel #13
0
 public static void AddBlock(WorldClient client, Packet packet)
 {
     string AddBlockname;
     if (packet.TryReadString(out AddBlockname, 16))
     {
         client.Character.BlocketUser.Add(AddBlockname);
         using (var pp = new Packet(SH42Type.AddToBlockList))
         {
             pp.WriteUShort(7168);//unk
             pp.WriteString(AddBlockname, 16);
             pp.WriteUShort(0);//unk
             client.SendPacket(pp);
         }
         Program.DatabaseManager.GetClient().ExecuteQuery("INSERT INTO BlockUser (CharID,BlockCharname) VALUES ('" + client.Character.ID + "','" + AddBlockname + "')");
     }
 }
Beispiel #14
0
        public void WritePacket(Packet pPacket)
        {
            pPacket.WriteUShort(ItemID);
            if (this.Type != HouseType.Resting)
            {
                pPacket.Fill(10, 0xFF); // Unknown

                pPacket.WriteString(this.Name, 30);
            }
            else
            {
                pPacket.WriteHexAsBytes("BE 02 FA 01 F8 01");
                pPacket.Fill(34, 0xFF); // No idea!?
            }
            pPacket.WriteByte(0xFF);
            pPacket.WriteByte(0);//unk
        }
Beispiel #15
0
 public static void RemoveFromBlockList(WorldClient client, Packet packet)
 {
     string removename;
     if (packet.TryReadString(out removename, 16))
     {
         if (client.Character.BlocketUser.Contains(removename))
         {
             using (var pack = new Packet(SH42Type.RemoveFromBlockList))
             {
                 pack.WriteUShort(7184);//unk
                 pack.WriteString(removename, 16);
                 client.SendPacket(pack);
             }
             Program.DatabaseManager.GetClient().ExecuteQuery("DELETE FROM BlockUser WHERE CharID = '" + client.Character.ID + "' AND BlockCharname= '" + removename + "'");
             client.Character.BlocketUser.Remove(removename);
         }
     }
 }
Beispiel #16
0
        public void Write(Packet packet)
        {
            packet.WriteUShort(this.MapObjectID);
            packet.WriteByte(2); //always 2 (type i bet shown / transparent?) -> test it
            packet.WriteUShort(this.ID);
            packet.WriteInt(this.Position.X);
            packet.WriteInt(this.Position.Y);
            packet.WriteByte(this.Rotation);
            if (Gate != null)
            {
                packet.WriteByte(1);
                packet.WriteString(Gate.MapClient, 12);
                packet.Fill(43, 0);

            }
            else
            {
                packet.Fill(56, 0); //find out later
            }
        }
Beispiel #17
0
        private static void SendGuildInviteError(Client Client, string TargetName, GuildInviteError Error)
        {
            using (var packet = new Packet(SH29Type.GuildInviteError))
            {
                packet.WriteString(TargetName, 16);
                packet.WriteUShort((ushort)Error);

                Client.SendPacket(packet);
            }
        }
Beispiel #18
0
        private static void SendGuildCreateResponse(WorldClient Client, string Name, string Password, bool AllowGuildWar, GuildCreateResponse Response)
        {
            using (var packet = new Packet(SH29Type.CreateGuildResponse))
            {

                packet.WriteUShort((ushort)Response);
                packet.WriteInt((Response == GuildCreateResponse.Success ? 32 : 0));

                packet.WriteString(Name, 16);
                packet.WriteString(Password, 8);
                packet.WriteBool(AllowGuildWar);
                Client.SendPacket(packet);
            }
        }
Beispiel #19
0
        private static void On_CharacterManager_CharacterLogout(WorldCharacter Character)
        {
            GuildMember member;
            if (Character.Guild != null
                && Character.Guild.GetMember(Character.Character.Name, out member))
            {
                //send guild member logged out to other guild members
                using (var packet = new Packet(SH29Type.GuildMemberLoggedOut))
                {
                    packet.WriteString(Character.Character.Name, 16);

                    Character.Guild.Broadcast(packet, member);
                }

                //send packet to zone that guild member logged out
                using (var packet = new InterPacket(InterHeader.ZONE_GuildMemberLogout))
                {
                    packet.WriteInt(Character.Guild.ID);
                    packet.WriteInt(Character.ID);

                    ZoneManager.Instance.Broadcast(packet);
                }
            }
        }
Beispiel #20
0
        private static void On_CharacterManager_CharacterLogin(WorldCharacter Character)
        {
            if (Character.IsInGuild)
            {
                var guild = Character.Guild;

                //send guild info to client
                using (var packet = new Packet(SH4Type.CharacterGuildinfo))
                {
                    guild.WriteGuildInfo(packet);

                    Character.Client.SendPacket(packet);
                }

                //send member list to client
                guild.SendMemberList(Character.Client);

                GuildMember member;
                if (guild.GetMember(Character.Character.Name, out member))
                {
                    //send guild member logged in to other guild members
                    using (var packet = new Packet(SH29Type.GuildMemberLoggedIn))
                    {
                        packet.WriteString(Character.Character.Name, 16);

                        Character.Guild.Broadcast(packet, member);
                    }
                }

                //send packet to zone that guild member logged in
                using (var packet = new InterPacket(InterHeader.ZONE_GuildMemberLogin))
                {
                    packet.WriteInt(guild.ID);
                    packet.WriteInt(Character.ID);

                    ZoneManager.Instance.Broadcast(packet);
                }
            }
            else
            {
                using (var packet = new Packet(SH4Type.CharacterGuildinfo))
                {
                    packet.WriteInt(0);

                    Character.Client.SendPacket(packet);
                }
            }

            //academy
            var academy = Character.GuildAcademy;
            if (academy != null)
            {
                if (Character.IsInGuildAcademy)
                {
                    using (var packet = new Packet(SH4Type.CharacterGuildacademyinfo))
                    {
                        academy.WriteInfo(packet);

                        Character.Client.SendPacket(packet);
                    }

                    academy.SendMemberList(Character.Client);
                }
                else
                {
                    using (var packet = new Packet(SH4Type.CharacterGuildacademyinfo))
                    {
                        packet.Fill(5, 0);

                        Character.Client.SendPacket(packet);
                    }
                }
            }
            else
            {
                using (var packet = new Packet(SH4Type.CharacterGuildacademyinfo))
                {
                    packet.Fill(5, 0);

                    Character.Client.SendPacket(packet);
                }
            }
        }
Beispiel #21
0
        public static void On_GameClient_UpdateGuildMessage(WorldClient Client, Packet Packet)
        {
            ushort length;
            string message;
            if (Client.Character.Guild == null
                || !Packet.TryReadUShort(out length)
                || !Packet.TryReadString(out message, length))
            {
                return;
            }

            //response packets
            using (var packet = new Packet(SH29Type.UnkMessageChange))
            {
                packet.WriteHexAsBytes("68 1B 00 92 AD F8 4F 2E 00 00 00 2B 00 00 00 17 00 00 00 07 00 00 00 06 00 00 00 70 00 00 00 06 00 00 00 BC 00 00 00 01 00 00 00 00 00");

                Client.SendPacket(packet);
            }
            using (var packet = new Packet(SH29Type.ClearGuildDetailsMessage))
            {
                packet.WriteUShort(3137);
                packet.WriteLong(0);

                Client.SendPacket(packet);
            }
            using (var packet = new Packet(SH29Type.UpdateGuildMessageResponse))
            {
                packet.WriteUShort(3137);
                Client.SendPacket(packet);
            }

            //update guild
            lock (Client.Character.Guild.ThreadLocker)
            {
                Client.Character.Guild.Message = message;
                Client.Character.Guild.MessageCreater = Client.Character;
                Client.Character.Guild.MessageCreateTime = Program.CurrentTime;

                Client.Character.Guild.Save();

                //broadcast packet to all guild members
                using (var packet = new Packet(SH29Type.SendUpdateGuildDetails))
                {
                    packet.Fill(4, 0x00);
                    packet.WriteInt(Client.Character.Guild.MessageCreateTime.Second);
                    packet.WriteInt(Client.Character.Guild.MessageCreateTime.Minute);
                    packet.WriteInt(Client.Character.Guild.MessageCreateTime.Hour);
                    packet.WriteInt(Client.Character.Guild.MessageCreateTime.Day);
                    packet.WriteInt(Client.Character.Guild.MessageCreateTime.Month - 1);
                    packet.WriteInt(Client.Character.Guild.MessageCreateTime.Year - 1900);
                    packet.WriteInt(0);
                    packet.WriteLong(0);
                    packet.WriteString(Client.Character.Character.Name, 16);
                    packet.WriteUShort(length);
                    packet.WriteString(message, length);

                    Client.Character.Guild.Broadcast(packet);
                }

                //send packet to zone that guild message changed
                using (var packet = new InterPacket(InterHeader.ZONE_GuildMessageUpdate))
                {
                    packet.WriteInt(Client.Character.Guild.ID);
                    packet.WriteInt(Client.Character.ID);
                    packet.WriteDateTime(Client.Character.Guild.MessageCreateTime);

                    packet.WriteUShort(length);
                    packet.WriteString(message, length);
                    ZoneManager.Instance.Broadcast(packet);
                }
            }
        }
Beispiel #22
0
        public static void On_GameClient_UpdateGuildMemberRank(WorldClient Client, Packet Packet)
        {
            string targetName;
            byte newRankByte;
            if (!Packet.TryReadString(out targetName, 16)
                || !Packet.TryReadByte(out newRankByte))
            {
                return;
            }

            var newRank = (GuildRank)newRankByte;
            GuildMember member;
            GuildMember target;
            if (Client.Character.Guild != null
                && Client.Character.Guild.GetMember(Client.Character.Character.Name, out member)
                && Client.Character.Guild.GetMember(targetName, out target))
            {
                switch (member.Rank)
                {
                    case GuildRank.Master:

                        if (newRank == GuildRank.Master)
                        {
                            Client.Character.Guild.UpdateMemberRank(member, GuildRank.Member);
                        }

                        Client.Character.Guild.UpdateMemberRank(target, newRank);

                        using (var packet = new Packet(SH29Type.UpdateGuildMemberRankResponse))
                        {
                            packet.WriteString(targetName, 16);
                            packet.WriteByte(newRankByte);
                            packet.WriteUShort(3137); // ok response

                            Client.SendPacket(packet);
                        }

                        break;

                    case GuildRank.Admin:
                    case GuildRank.Advice:
                    case GuildRank.Commander:
                    case GuildRank.Default:
                    case GuildRank.Guard:
                    case GuildRank.Member:
                        return;
                }
            }
        }
Beispiel #23
0
        public static void On_GameClient_GuildNameRequest(WorldClient Client, Packet Packet)
        {
            int guildID;
            if (!Packet.TryReadInt(out guildID))
            {
                return;
            }

            Guild guild;
            if (GetGuildByID(guildID, out guild))
            {
                using (var packet = new Packet(SH29Type.GuildNameResult))
                {
                    packet.WriteInt(guildID);
                    packet.WriteString(guild.Name, 16);

                    Client.SendPacket(packet);
                }
            }
        }
Beispiel #24
0
        public static void On_GameClient_GuildInviteRequest(WorldClient Client, Packet Packet)
        {
            string targetName;
            if (Client.Character == null
                || Client.Character.Guild == null // cheating ?
                || !Packet.TryReadString(out targetName, 16))
            {
                return;
            }

            //get target
            WorldCharacter target;
            if (!CharacterManager.GetLoggedInCharacter(targetName, out target)
                || !target.IsOnline)
            {
                return;
            }

            //todo: check for academy, too
            if (target.Guild != null)
            {
                SendGuildInviteError(Client, targetName, GuildInviteError.TargetHasAlreadyGuild);
                return;
            }

            //send invite to target
            using (var packet = new Packet(SH29Type.GuildInviteRequest))
            {
                packet.WriteString(Client.Character.Guild.Name, 16);
                packet.WriteString(Client.Character.Character.Name, 16);

                target.Client.SendPacket(packet);
            }
        }
Beispiel #25
0
        public static void On_GameClient_GuildChat(WorldClient Client, Packet pPacket)
        {
            byte len;
            string msg;
            if (Client.Character == null
                || !pPacket.TryReadByte(out len)
                || !pPacket.TryReadString(out msg, len))
            {
                return;
            }

            len = (byte)(len + 2);

            if (Client.Character.Guild != null)
            {
                using (var packet = new Packet(SH29Type.GuildChat))
                {
                    packet.WriteInt(Client.Character.Guild.ID);
                    packet.WriteString(Client.Character.Character.Name, 16);

                    packet.WriteByte(len);
                    packet.WriteString(msg, len);

                    Client.Character.Guild.Broadcast(packet);
                }
            }
        }
Beispiel #26
0
        public static void On_GameClient_CreateGuild(WorldClient Client, Packet Packet)
        {
            string name, password;
            bool allowGuildWar;
            if (!Packet.TryReadString(out name, 16)
                || !Packet.TryReadString(out password, 8)
                || !Packet.ReadSkip(4) // unk ?
                || !Packet.TryReadBool(out allowGuildWar))
            {
                return;
            }

            GuildCreateResponse response;

            if (Client.Character.Character.CharLevel < 20)
            {
                response = GuildCreateResponse.LevelTooLow;
            }
            else if (Client.Character.Character.Money < Guild.Price)
            {
                response = GuildCreateResponse.MoneyTooLow;
            }
            else
            {
                //encrypt guild pw
               var pwData = Encoding.UTF8.GetBytes(password);
            //                InterCrypto.Encrypt(ref pwData, 0, pwData.Length);

                Guild guild;

                //try to create guild
                lock (ThreadLocker)
                {
                    int result;
                    int guildID;
                    var createTime = Program.CurrentTime;

                    using (var con = Program.DatabaseManager.GetClient().GetConnection())
                    {
                        //insert guild in db
                        using (var cmd = con.CreateCommand())
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.CommandText = "Guild_Create";

                            cmd.Parameters.Add(new MySqlParameter("@pName", name));
                            cmd.Parameters.Add(new MySqlParameter("@pPassword", pwData));
                            cmd.Parameters.Add(new MySqlParameter("@pAllowGuildWar", allowGuildWar));
                            cmd.Parameters.Add(new MySqlParameter("@pCreaterID", Client.Character.ID));
                            cmd.Parameters.Add(new MySqlParameter("@pCreateTime", createTime));

                            var idParam = cmd.Parameters.Add(new MySqlParameter("@pID", SqlDbType.Int)
                                {
                                    Direction = ParameterDirection.Output
                                });
                            result = Convert.ToInt32(cmd.ExecuteScalar());
                            guildID = (int)idParam.Value;
                        }

                        switch (result)
                        {
                            case -1:
                                //guild name already exists (ToDo: get response code)

                                SendGuildCreateResponse(Client, name, password, allowGuildWar, GuildCreateResponse.AlredyExist);
                                return;

                            case -2: //database error @ insert guild (ToDo: get response code)
                                SendGuildCreateResponse(Client, name, password, allowGuildWar, GuildCreateResponse.Failed);
                                return;
                            case -3: //database error @ insert guild academy (ToDo: get response code)
                                SendGuildCreateResponse(Client, name, password, allowGuildWar, GuildCreateResponse.Failed);
                                return;

                            case 0:

                                //create guild
                                guild = new Guild(con, guildID, name, pwData, allowGuildWar, Client.Character, createTime);
                            //insert guild master (character will get updated)
                                guild.AddMember(Client.Character, GuildRank.Master, con, false, false);
                                //add to loaded guilds
                                LoadedGuilds.Add(guild);

                                break;

                            default:
                                return;
                        }
                    }
                }

                Client.Character.
                //revoke money
               Client.Character.ChangeMoney(Client.Character.Character.Money - Guild.Price);

                //let character broadcast guild name packet
                using (var packet = new Packet(SH29Type.GuildNameResult))
                {
                    packet.WriteInt(guild.ID);
                    packet.WriteString(guild.Name, 16);

                    BroadcastManager.Instance.BroadcastInRange(Client.Character, packet, true);
                }

                //let zone know that a guild has been loaded
                using (var packet = new InterPacket(InterHeader.ZONE_GuildCreated))
                {
                    packet.WriteInt(guild.ID);
                    packet.WriteInt(Client.Character.ID);

                    ZoneManager.Instance.Broadcast(packet);
                }

                //set response to success
                response = GuildCreateResponse.Success;
            }

            SendGuildCreateResponse(Client, name, password, allowGuildWar, response);
        }
Beispiel #27
0
 public void WriteDetailedInfo(Packet pPacket)
 {
     pPacket.WriteInt(ID);
     pPacket.WriteString(this.Name, 16);
     pPacket.WriteByte(this.Slot);
     pPacket.WriteByte(this.Level);
     pPacket.WriteLong(this.Exp);
     pPacket.WriteInt(12345678);                // UNK
     pPacket.WriteShort(this.StonesHP);
     pPacket.WriteShort(this.StonesSP);
     pPacket.WriteUInt(this.HP);
     pPacket.WriteUInt(this.SP);
     pPacket.WriteInt(this.Fame);
     pPacket.WriteLong(this.Inventory.Money);
     pPacket.WriteString(this.Map.MapInfo.ShortName, 12);
     pPacket.WriteInt(this.Position.X);
     pPacket.WriteInt(this.Position.Y);
     pPacket.WriteByte(this.Rotation);
     pPacket.WriteByte(this.Str);//  -.
     pPacket.WriteByte(this.End);//   |
     pPacket.WriteByte(this.Dex);//   |  Boni
     pPacket.WriteByte(this.Int);//   |
     pPacket.WriteByte(this.Spr);//  -'
     pPacket.WriteShort(0);               // UNK
     pPacket.WriteUInt(0);               // Killpoints (TODO)
     pPacket.Fill(7, 0);                 // UNK
 }
Beispiel #28
0
        public void WriteCharacterDisplay(Packet packet)
        {
            packet.WriteUShort(MapObjectID);
            packet.WriteString(Name, 16);
            packet.WriteInt(Position.X);
            packet.WriteInt(Position.Y);
            packet.WriteByte(Rotation);                // Rotation
            packet.WriteByte((byte)State);          // Player State (1,2 - Player, 3 - Dead, 4 - Resting, 5 - Vendor, 6 - On Mount)
            packet.WriteByte((byte)Job);
            if (State != PlayerState.Resting && State != PlayerState.Vendor && this.House == null)
            {
                WriteLook(packet);
                WriteEquipment(packet);
            }
            else
            {
                this.House.WritePacket(packet);
            }
            WriteRefinement(packet);
            //(IsMale ? 1 : 0)
            int mount = (this.Mount != null) ? (int) this.Mount.Handle : (int)0xffff;
            packet.WriteUShort((ushort)mount);  // Mount Handle
            packet.WriteUShort(0xffff);
            packet.WriteByte(0xff);          // Emote (0xff = nothing)
            packet.WriteUShort(0xffff);
            packet.WriteShort(0);
            packet.WriteUShort(0);             // Mob ID (title = 10)

            packet.Fill(55, 0);                // Buff Bits? Something like that
            if (this.Character.GuildID > 1)
            {
                packet.WriteInt(this.Guild.ID);
            }
            else if (this.Character.AcademyID > 0)
            {
                packet.WriteInt(this.Character.AcademyID);
            }
            else
            {
                packet.WriteInt(0);
            }
            packet.WriteByte(0x02);            // UNK (0x02)

            packet.WriteBool(this.IsInaAcademy);            // In Guild Academy (0 - No, 1 - Yes)
            packet.WriteBool(true);            // Pet AutoPickup   (0 - Off, 1 - On)
            packet.WriteByte(this.Level);
        }
Beispiel #29
0
        public void Move(int oldx, int oldy, int newx, int newy, bool walk, bool stop)
        {
            Teleport(newx, newy);

            if (stop)
            {
                using (var packet = Handler8.StopObject(this))
                {
                    Broadcast(packet);
                }
            }
            else
            {
                ushort speed = 0;
                if (walk) speed = 60;
                else if(Mount != null) speed = this.Mount.speed;
                else speed = 115;
                foreach (var member in this.Party)
                {
                    if (member.Value.Character.Name != this.Character.Name)
                    {
                        using (var ppacket = new Packet(14, 73))
                        {
                            ppacket.WriteByte(1);//unk
                            ppacket.WriteString(member.Key, 16);
                            ppacket.WriteInt(member.Value.Character.Character.PositionInfo.XPos);
                            ppacket.WriteInt(member.Value.Character.Character.PositionInfo.XPos);
                            member.Value.SendPacket(ppacket);
                        }
                    }
                }
                using (var packet = Handler8.MoveObject(this, oldx, oldy, walk, speed))
                {
                    Broadcast(packet);
                }

                if (this.Group != null)
                {
                    this.Group.CharacterMoved(this.GroupMember, oldx, oldy, newx, newy);
                }
            }
        }
Beispiel #30
0
        private void UpdateMemberPosition(GroupMember member)
        {
            if (!member.IsOnline)
                return;
            using (var packet = new Packet(SH14Type.UpdatePartyMemberLoc))
            {
                packet.WriteString(member.Name, 0x10);
                packet.WriteInt(member.Character.Position.X);
                packet.WriteInt(member.Character.Position.Y);

                AnnouncePacketToUpdatable(packet);
            }
        }