/// <summary> /// Occurs when kicking a players from the party /// </summary> /// <param name="cpkt"></param> private void CM_PARTYKICK(CMSG_PARTYKICK cpkt) { if (this.character.sessionParty == null) { return; } //Check if party is party leader if (this.character.sessionParty.PartyLeader != this.character) { Trace.TraceInformation("Non party leader attempt to set settings"); return; } //Removes the current character else if (cpkt.Index > this.character.sessionParty._Characters.Count) { Trace.TraceInformation("Party out of range"); return; } uint actorid = this.character.sessionParty[cpkt.Index].id; this.character.sessionParty._Characters.RemoveAt(cpkt.Index); //Forwards to all members that i quite foreach (Character c in this.character.sessionParty.GetCharacters()) { //Pregenerate quite message SMSG_PARTYQUIT spkt = new SMSG_PARTYQUIT(); spkt.ActorId = actorid; spkt.Index = 1; spkt.Reason = 1; spkt.SessionId = c.id; c.client.Send((byte[])spkt); } //Dismiss the party if everybody left if (this.character.sessionParty.Count == 1) { Character lastchar = this.character.sessionParty._Characters[0]; SMSG_PARTYDISMISSED spkt2 = new SMSG_PARTYDISMISSED(); spkt2.SessionId = lastchar.id; lastchar.client.Send((byte[])spkt2); } }
/// <summary> /// Occurs when an players tries to quite for misc reasons. /// They might log off or they might just want to stop the party /// </summary> private void CM_PARTYQUIT(CMSG_PARTYQUIT cpkt) { if (this.character.sessionParty == null) { return; } //Pregenerate quite message SMSG_PARTYQUIT spkt = new SMSG_PARTYQUIT(); spkt.ActorId = this.character.id; spkt.Index = (byte)(this.character.sessionParty.IndexOf(this.character) + 1); spkt.Reason = 1; //Forwards to all members that i quite foreach (Character c in this.character.sessionParty.GetCharacters()) { if (c.client.isloaded == false) { continue; } spkt.SessionId = c.id; c.client.Send((byte[])spkt); } //Removes the current character this.character.sessionParty.Remove ( this.character ); //Dismiss the party if everybody left if (this.character.sessionParty.Count == 1) { Character lastchar = this.character.sessionParty._Characters[0]; SMSG_PARTYDISMISSED spkt2 = new SMSG_PARTYDISMISSED(); spkt2.SessionId = lastchar.id; lastchar.client.Send((byte[])spkt2); lastchar.sessionParty = null; } //Clears the party object this.character.sessionParty = null; }