A couple of questions about marriage.

10/13/2008 03:18 BlooD-BoY#1
so i was playing around with marriage, and decided to build a divorce NPC, so i built this
Code:
if (CurrentNPC == 104820)

{

if (Control == 1)

{

if ( MyChar.Spouse == "" || MyChar.Spouse == "None")

{

SendPacket(General.MyPackets.NPCSay("You are not even married, what do you want from me?!"));

SendPacket(General.MyPackets.NPCLink("Ahh, whoops sorry", 255));

SendPacket(General.MyPackets.NPCSetFace(30));

SendPacket(General.MyPackets.NPCFinish());

}

else

{

MyChar.Spouse = "";

SendPacket(General.MyPackets.NPCSay("You are divorced, enjoy your single life"));

SendPacket(General.MyPackets.NPCLink("Thank you", 255));

SendPacket(General.MyPackets.NPCSetFace(30));

SendPacket(General.MyPackets.NPCFinish());

}

}

}


it works and all, but i got one problem, it may divorce me from my spouse, but it doesn't divorce my spouse from me O.O i mean i tried every single thing, nothing worked for some reason any ideas? thx.



my second question, if i get married it doesn't show my spouse name in "My stats" where it shows my level, name, guildname and other stuff, any ideas? thx =)
10/13/2008 03:39 kinshi88#2
The only reason this only divorces you is because you are only "divorcing" yourself with that code. You have to "divorce" your spouse aswell.
10/13/2008 03:42 BlooD-BoY#3
Quote:
Originally Posted by kinshi88 View Post
The only reason this only divorces you is because you are only "divorcing" yourself with that code. You have to "divorce" your spouse aswell.
well true i know that, the problem is i found the char.spouse thingy, added it but it can't find "Char.Spouse" for some reason...but i can see it in the source O.O
10/13/2008 05:37 nTL3fTy#4
Best method that I can come up with in 10 minutes (not compiled, not tested):
Code:
uint SpouseUID = 0;
foreach (DictionaryEntry DE in World.AllChars)
{
    Character c = (Character)DE.Value;
    if (c.Name == MyChar.Spouse)
    {
        SpouseUID = c.UID;
        break;
    }
}
if (SpouseUID == 0)
{
    SendPacket(General.MyPackets.NPCSay("Your spouse is offline. Please try again when your spouse is online."));
    SendPacket(General.MyPackets.NPCLink("Ok.", 255));
    SendPacket(General.MyPackets.NPCSetFace(30));
    SendPacket(General.MyPackets.NPCFinish());
}
else
{
    MyChar.Spouse = "None";
    ((Character)World.AllChars[SpouseUID]).Spouse = "None";
    SendPacket(General.MyPackets.NPCSay("Your spouse has been divorced."));
    SendPacket(General.MyPackets.NPCLink("Thank you for your service.", 255));
    SendPacket(General.MyPackets.NPCSetFace(30));
    SendPacket(General.MyPackets.NPCFinish());
}
10/13/2008 22:35 InfamousNoone#5
Only works if the spouse is online :P
10/13/2008 23:58 BlooD-BoY#6
Quote:
Originally Posted by InfamousNoone View Post
Only works if the spouse is online :P
kk i already got it working not perfectly like 95%, ty for any help guys =)
btw both chars need to log off for MySQL to update i kinda did the "Drop();" thingy for the char. that is divorcing, but how can i do it for the spouse? any idea? thx ;P
10/14/2008 01:55 nTL3fTy#7
Quote:
Originally Posted by BlooD-BoY View Post
kk i already got it working not perfectly like 95%, ty for any help guys =)
btw both chars need to log off for MySQL to update i kinda did the "Drop();" thingy for the char. that is divorcing, but how can i do it for the spouse? any idea? thx ;P
Loop through World.AllChars until you come to the character with the same name as your spouse and then use the MyClient variable of the character to drop it.

Code:
foreach (DictionaryEntry DE in World.AllChars)
{
    Character c = (Character)DE.Value;
    if (c.Name == MyChar.Spouse)
        c.MyClient.Drop();
}
If you already have the UID of the spouse:
Code:
((Character)World.AllChars[SpouseUID]).MyClient.Drop();
10/14/2008 02:14 BlooD-BoY#8
Quote:
Originally Posted by nTL3fTy View Post
Loop through World.AllChars until you come to the character with the same name as your spouse and then use the MyClient variable of the character to drop it.

Code:
foreach (DictionaryEntry DE in World.AllChars)
{
    Character c = (Character)DE.Value;
    if (c.Name == MyChar.Spouse)
        c.MyClient.Drop();
}
If you already have the UID of the spouse:
Code:
((Character)World.AllChars[SpouseUID]).MyClient.Drop();
lolz thx, didn't know which code to use to dc the spouse, so i just took the "((Character)World.AllChars[SpouseUID]).MyClient.Drop();" and it worked, so thx ;P
btw have any idea on how to make my spouses name show in my status? O.O
10/14/2008 12:48 pauldexter#9
@BlooD-BoY
to show your spouse name in your status you need to change CharacterInfo.
and it goes like this.
Code:
        public byte[] CharacterInfo(Character Charr)
        {
            byte[] Packet = new byte[70 + Charr.Name.Length + Charr.Spouse.Length];
            long Model = Convert.ToInt64(Convert.ToString(Charr.Avatar) + Convert.ToString(Charr.Model));

            fixed (byte* p = Packet)
            {
                *((ushort*)p) = (ushort)Packet.Length;
                *((ushort*)(p + 2)) = 1006;
                *((uint*)(p + 4)) = (uint)Charr.UID;
                *((uint*)(p + 8)) = (uint)Model;
                *((ushort*)(p + 12)) = (ushort)Charr.Hair;
                *((uint*)(p + 14)) = (uint)Charr.Silvers;
                *((uint*)(p + 18)) = (uint)Charr.CPs;
                *((uint*)(p + 22)) = (uint)Charr.Exp;
                *((ushort*)(p + 42)) = (ushort)5130;
                *((ushort*)(p + 46)) = (ushort)Charr.Str;
                *((ushort*)(p + 48)) = (ushort)Charr.Agi;
                *((ushort*)(p + 50)) = (ushort)Charr.Vit;
                *((ushort*)(p + 52)) = (ushort)Charr.Spi;
                *((ushort*)(p + 54)) = (ushort)Charr.StatP;
                *((ushort*)(p + 56)) = (ushort)Charr.CurHP;
                *((ushort*)(p + 58)) = (ushort)Charr.MaxMana();
                *((ushort*)(p + 60)) = (ushort)Charr.PKPoints;
                *(p + 62) = Charr.Level;
                *(p + 63) = Charr.Job;
                *(p + 66) = 1;
                *(p + 67) = 2;
                *(p + 68) = (byte)Charr.Name.Length;

                Packet[69 + Charr.Name.Length] = (byte)Charr.Spouse.Length;

                for (sbyte i = 0; i < Charr.Name.Length; i++)
                {
                    *(p + 69 + i) = (byte)Charr.Name[i];
                }
                for (sbyte i = 0; i < Charr.Spouse.Length; i++)
                {
                    *(p + 70 + Charr.Name.Length + i) = (byte)Charr.Spouse[i];
                }

            }
            return Packet;
        }
10/14/2008 13:33 BlooD-BoY#10
Quote:
Originally Posted by pauldexter View Post
@BlooD-BoY
to show your spouse name in your status you need to change CharacterInfo.
and it goes like this.
Code:
        public byte[] CharacterInfo(Character Charr)
        {
            byte[] Packet = new byte[70 + Charr.Name.Length + Charr.Spouse.Length];
            long Model = Convert.ToInt64(Convert.ToString(Charr.Avatar) + Convert.ToString(Charr.Model));

            fixed (byte* p = Packet)
            {
                *((ushort*)p) = (ushort)Packet.Length;
                *((ushort*)(p + 2)) = 1006;
                *((uint*)(p + 4)) = (uint)Charr.UID;
                *((uint*)(p + 8)) = (uint)Model;
                *((ushort*)(p + 12)) = (ushort)Charr.Hair;
                *((uint*)(p + 14)) = (uint)Charr.Silvers;
                *((uint*)(p + 18)) = (uint)Charr.CPs;
                *((uint*)(p + 22)) = (uint)Charr.Exp;
                *((ushort*)(p + 42)) = (ushort)5130;
                *((ushort*)(p + 46)) = (ushort)Charr.Str;
                *((ushort*)(p + 48)) = (ushort)Charr.Agi;
                *((ushort*)(p + 50)) = (ushort)Charr.Vit;
                *((ushort*)(p + 52)) = (ushort)Charr.Spi;
                *((ushort*)(p + 54)) = (ushort)Charr.StatP;
                *((ushort*)(p + 56)) = (ushort)Charr.CurHP;
                *((ushort*)(p + 58)) = (ushort)Charr.MaxMana();
                *((ushort*)(p + 60)) = (ushort)Charr.PKPoints;
                *(p + 62) = Charr.Level;
                *(p + 63) = Charr.Job;
                *(p + 66) = 1;
                *(p + 67) = 2;
                *(p + 68) = (byte)Charr.Name.Length;

                Packet[69 + Charr.Name.Length] = (byte)Charr.Spouse.Length;

                for (sbyte i = 0; i < Charr.Name.Length; i++)
                {
                    *(p + 69 + i) = (byte)Charr.Name[i];
                }
                for (sbyte i = 0; i < Charr.Spouse.Length; i++)
                {
                    *(p + 70 + Charr.Name.Length + i) = (byte)Charr.Spouse[i];
                }

            }
            return Packet;
        }
lolz thx man, i've been looking for that shit for so long, thx :handsdown:
10/14/2008 21:48 InfamousNoone#11
No, you should only send the character info packet ONCE; and thats when they log in. >_>;
10/14/2008 22:11 tanelipe#12
And for the rest you use the 0x3F9 update packet. (or string packet for spouse?)
10/14/2008 22:18 InfamousNoone#13
string packet