public static Invite ( Server.Mobile from, Server.Mobile target ) : void | ||
from | Server.Mobile | |
target | Server.Mobile | |
return | void |
public static void Invite( Mobile from, Mobile target )
{
Party p = Party.Get( from );
if ( p == null )
from.Party = p = new Party( from );
if ( !p.Candidates.Contains( target ) )
p.Candidates.Add( target );
// : You are invited to join the party. Type /accept to join or /decline to decline the offer.
target.Send( new MessageLocalizedAffix( Serial.MinusOne, -1, MessageType.Label, 0x3B2, 3, 1008089, "", AffixType.Prepend | AffixType.System, from.Name, "" ) );
from.SendLocalizedMessage( 1008090 ); // You have invited them to join the party.
target.Send( new PartyInvitation( from ) );
target.Party = from;
DeclineTimer.Start( target, from );
}
protected override void OnTarget(Mobile from, object o) { if (o is Mobile) { Mobile m = (Mobile)o; Party p = Party.Get(from); Party mp = Party.Get(m); if (from == m) { from.SendLocalizedMessage(1005439); // You cannot add yourself to a party. } else if (p != null && p.Leader != from) { from.SendLocalizedMessage(1005453); // You may only add members to the party if you are the leader. } else if (m.Party is Mobile) { return; } else if (p != null && (p.Members.Count + p.Candidates.Count) >= Party.Capacity) { from.SendLocalizedMessage(1008095); // You may only have 10 in your party (this includes candidates). } else if (m.NetState == null) { if (!m.Player && m.Body.IsHuman) { m.SayTo(from, 1005443); // Nay, I would rather stay here and watch a nail rust. } else { from.SendLocalizedMessage(1005444); // The creature ignores your offer. } } else if (mp != null && mp == p) { from.SendLocalizedMessage(1005440); // This person is already in your party! } else if (mp != null) { from.SendLocalizedMessage(1005441); // This person is already in a party! } else { Party.Invite(from, m); } } else { from.SendLocalizedMessage(1005442); // You may only add living things to your party! } }