Exemplo n.º 1
0
        public static GroupMember LoadFromDatabase(ushort pCharId)
        {
            const string query = "SELECT * FROM `characters` WHERE CharId = @cid";
            GroupMember member = new GroupMember();

            using (var con = Program.DatabaseManager.GetClient())
            using (var cmd = new MySqlCommand(query, con.GetConnection()))
            {
                cmd.Parameters.AddWithValue("@cid", pCharId);
                using (var rdr = cmd.ExecuteReader())
                {
                    while (rdr.Read())
                    {
                        member.Name = rdr.GetString("Name");
                        member.IsOnline = ClientManager.Instance.IsOnline(member.Name);
                        member.Role = rdr.GetBoolean("IsGroupMaster")
                                            ? GroupRole.Master
                                            : GroupRole.Member;
                        if (member.IsOnline)
                        {
                            member.Client = ClientManager.Instance.GetClientByCharname(member.Name);
                            member.Character = member.Client.Character;
                        }

                        return member;
                    }
                }
            }
            return member;
        }
Exemplo n.º 2
0
 private void ChangeMaster(GroupMember pFrom, GroupMember pTo)
 {
     if(pFrom.Role != GroupRole.Master)
         return;
     pFrom.Role = GroupRole.Member;
     pTo.Role = GroupRole.Master;
     OnChangedMaster(pFrom, pTo);
 }
Exemplo n.º 3
0
 private void SendAddMemberInterPacket(GroupMember pMember)
 {
     ZoneConnection con = Program.GetZoneByMap(pMember.Character.Character.PositionInfo.Map);
     using (var pack = new InterPacket(InterHeader.AddPartyMember))
     {
         pack.WriteLong(this.Id);
         pack.WriteString(pMember.Name, 16);
         con.SendPacket(pack);
     }
 }
Exemplo n.º 4
0
 internal void RemoveMember(GroupMember pMember)
 {
     this.Members.Remove(pMember);
     pMember.Character.Group = null;
     pMember.Character.GroupMember = null;
     RemoveGroupDataInDatabase(pMember.CharId);
     // TEMP
     KickMember(pMember.Name);
     // NOTE: Send packet to other Members to update GroupList!
     AnnouncePartyList();
 }
Exemplo n.º 5
0
 protected virtual void OnChangedMaster(GroupMember pOld, GroupMember pNew)
 {
     if(ChangedMaster != null)
         ChangedMaster(this, new ChangedMasterEventArgs(pOld, pNew));
 }
Exemplo n.º 6
0
 internal void AddMember(GroupMember pMember)
 {
     this.Members.Add(pMember);
     pMember.Group = this;
     UpdateInDatabase();
     SendAddMemberInterPacket(pMember);
 }
Exemplo n.º 7
0
        public void MemberJoin(string pMember)
        {
            WorldClient client = ClientManager.Instance.GetClientByCharname(pMember);
            GroupMember gMember = new GroupMember(client, GroupRole.Member);
            client.Character.GroupMember = gMember;
            client.Character.Group = this;
            AddMember(gMember);

            AnnouncePartyList();
            UpdateInDatabase();
        }
Exemplo n.º 8
0
 public ChangedMasterEventArgs(GroupMember pOld, GroupMember pNew)
 {
     this.OldMaster = pOld;
     this.NewMaster = pNew;
 }
Exemplo n.º 9
0
 public void ChangeMaster(GroupMember pNewMaster)
 {
     ChangeMaster(this.Master, pNewMaster);
     AnnounceChangeMaster();
 }
Exemplo n.º 10
0
        public Group CreateNewGroup(WorldClient pMaster)
        {
            Group grp = new Group(GetNextId());
            GroupMember mstr = new GroupMember(pMaster, GroupRole.Master);
            pMaster.Character.GroupMember = mstr;
            pMaster.Character.Group = grp;
            grp.AddMember(mstr);

            AddGroup(grp);
            grp.CreateInDatabase();

            SendNewPartyInterPacket(grp.Id);
            return grp;
        }