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; }
private void ChangeMaster(GroupMember pFrom, GroupMember pTo) { if(pFrom.Role != GroupRole.Master) return; pFrom.Role = GroupRole.Member; pTo.Role = GroupRole.Master; OnChangedMaster(pFrom, pTo); }
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); } }
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(); }
protected virtual void OnChangedMaster(GroupMember pOld, GroupMember pNew) { if(ChangedMaster != null) ChangedMaster(this, new ChangedMasterEventArgs(pOld, pNew)); }
internal void AddMember(GroupMember pMember) { this.Members.Add(pMember); pMember.Group = this; UpdateInDatabase(); SendAddMemberInterPacket(pMember); }
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(); }
public ChangedMasterEventArgs(GroupMember pOld, GroupMember pNew) { this.OldMaster = pOld; this.NewMaster = pNew; }
public void ChangeMaster(GroupMember pNewMaster) { ChangeMaster(this.Master, pNewMaster); AnnounceChangeMaster(); }
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; }