01/19/2018, 14:15
|
#18
|
elite*gold: 0
Join Date: Mar 2005
Posts: 1,425
Received Thanks: 1,565
|
Quote:
Originally Posted by ~OwnageBoy
This is the code i'm currently using. You can send out invites to several chars and press ''Marry'' on all chars and it will have marriage to all the chars. Where can i put another check to make it stop being able to marry more than 1 char?
PHP Code:
public class Marriage { public static void Handle(Main.GameClient GC, byte[] Data) { uint AttackType = BitConverter.ToUInt32(Data, 20);
if (AttackType == 8) { uint TargetUID = BitConverter.ToUInt32(Data, 12); Game.Character TargetMarry = null;
if (Game.World.H_Chars.ContainsKey(TargetUID)) TargetMarry = Game.World.H_Chars[TargetUID]; if (TargetMarry == null) return;
if (GC.MyChar.Spouse != "None" && GC.MyChar.Spouse != " " && GC.MyChar.Spouse != "") { GC.LocalMessage(2005, "You are married."); return; } if (TargetMarry.Spouse != "None" && TargetMarry.Spouse != " " && TargetMarry.Spouse != "") { GC.LocalMessage(2005, "The target is married."); return; } if ((TargetMarry.Body == 1003 || TargetMarry.Body == 1004) && (GC.MyChar.Body == 1003 || GC.MyChar.Body == 1004)) { GC.LocalMessage(2005, "No male and male marriage is permited!"); return; } if ((TargetMarry.Body == 2001 || TargetMarry.Body == 2002) && (GC.MyChar.Body == 2001 || GC.MyChar.Body == 2002)) { GC.LocalMessage(2005, "No female and female marriage is permited!"); return; }
TargetMarry.MyClient.AddSend(Packets.AttackPacket(GC.MyChar.EntityID, TargetMarry.EntityID, TargetMarry.Loc.X, TargetMarry.Loc.Y, 0, 8)); } else if (AttackType == 9) { uint TargetUID = BitConverter.ToUInt32(Data, 12); Game.Character TargetMarry = null; if (Game.World.H_Chars.ContainsKey(TargetUID)) TargetMarry = Game.World.H_Chars[TargetUID]; TargetMarry.Spouse = GC.MyChar.Name; GC.MyChar.Spouse = TargetMarry.Name; TargetMarry.MyClient.AddSend(Packets.String(TargetMarry.EntityID, 6, TargetMarry.Spouse)); GC.AddSend(Packets.String(GC.MyChar.EntityID, 6, GC.MyChar.Spouse)); Database.SaveCharacter(TargetMarry, TargetMarry.MyClient.AuthInfo.Account); Database.SaveCharacter(GC.MyChar, GC.AuthInfo.Account); if (GC.MyChar.Body == 1003 || GC.MyChar.Body == 1004) Game.World.SendMsgToAll("SYSTEM", GC.MyChar.Name + " and " + TargetMarry.Name + " are married now.", 2005, 0); else Game.World.SendMsgToAll("SYSTEM", TargetMarry.Name + " and " + GC.MyChar.Name + " are married now.", 2005, 0); } } } }
|
ALL OF THIS could be replaced with
Code:
if ((target.Body / 1000) == (Gc.MyChar.Body / 1000))
{
GC.LocalMessage(2005, "You cannot marry the same gender!"); return;
}
PS. please use enums for your MsgTalkTypes not 2005 etc xD
also, having GC.MyChar seems very counter productive.. Why not just have GC inherit mychar class? or merge them?
|
|
|