Save Guild Enemies/Allies

10/11/2010 03:32 FadMucker#106
tried it but still doesn't work maybe we cud TV and i show you the problem im having?
10/11/2010 03:39 Arcо#107
Alright man, we've helped you enough, its time for you to take the pieces and put them together and try and give it a go on your own. We're not gonna spoonfeed you mate.
10/11/2010 18:11 CØĐ£Ř||Mã©hÍñє#108
thanks its working keep going
11/23/2010 18:52 ZeRo-ToLeRaNcE#109
hello all, all is working good i think only the red marked parts are going wrong i guess.

what is going to read as ally? my guildname or the name of the partner?
and what is the EntityID? from my self or the partner?

please can somebody help me?

Code:
if (GC.MyChar.MyGuild != null && GC.MyChar.GuildRank == NewestCOServer.Features.GuildRank.GuildLeader)
                                        {
                                            [COLOR="Red"]string Ally = ReadString(Data);[/COLOR]              foreach (Features.Guild g in Features.Guilds.AllTheGuilds.Values)
                                            {
                                                if ([COLOR="red"]g.GuildName == Ally[/COLOR])
                                                {
                                                    if (g.Creator.Info != null)
                                                    {
                                                        if (g.Creator.Info.MyTeam.Members.Contains([COLOR="red"]GC.MyChar.EntityID[/COLOR]))
                                                        {
                                                            if (!GC.MyChar.MyGuild.Allies.ContainsValue(Ally))
                                                            {
                                                                GC.MyChar.MyGuild.Allies.Add(0, Ally);
                                                                GC.AddSend(Packets.String(g.GuildID, 21, Ally));
                                                                GC.AddSend(Packets.NPCSay(g.GuildName + " is now your ally!"));
                                                                GC.AddSend(Packets.NPCLink("Thanks.", 255));
                                                                GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                                                GC.AddSend(Packets.NPCFinish());
11/23/2010 20:32 Syst3m_W1z4rd#110
foreach (Features.Guild g in Features.Guilds.AllTheGuilds.Values)
{
if (g.GuildName == Ally)
{

is making a foreach loop and checking all the guilds.
then it checks for a guild with the name that u putted as ally.

string Ally = ReadString(Data); will read from Link2 and make it to the string ally.

So basicly g.GuildName == Ally is just checking what u wrote.

And this will only add them as allie to ur self, he have to do it also.
Just like normal. (Don't know why u aint running a team check instead).
To check if only 2 guildleaders in team and then if u both click.
Much easier and better :)
11/23/2010 21:26 ZeRo-ToLeRaNcE#111
He hello,

i have debug it and indeed he is doing that good, but if he is coming by the:

Code:
if (g.Creator.Info.MyTeam.Members.Contains(GC.MyChar.EntityID))
then i check the members in debug and i have the 2 leaders in the team, and the EntityID's are correct, but he is see it as IF NOT state and skip the part to make it ally.

really strange, what i do nothing is working, you have any idea?

Quote:
Originally Posted by 1337 H4X0R View Post
foreach (Features.Guild g in Features.Guilds.AllTheGuilds.Values)
{
if (g.GuildName == Ally)
{

is making a foreach loop and checking all the guilds.
then it checks for a guild with the name that u putted as ally.

string Ally = ReadString(Data); will read from Link2 and make it to the string ally.

So basicly g.GuildName == Ally is just checking what u wrote.

And this will only add them as allie to ur self, he have to do it also.
Just like normal. (Don't know why u aint running a team check instead).
To check if only 2 guildleaders in team and then if u both click.
Much easier and better :)
11/24/2010 10:01 Syst3m_W1z4rd#112
Just do GC.MyChar I think :)
11/24/2010 16:30 †he Knight#113
Quote:
Originally Posted by 1337 H4X0R View Post
Just do GC.MyChar I think :)
GC.MyChar .. the tittle tells you...
foreach is missing guyz,,

Code:
foreach (Game.Character Target in World.H_Chars.Values)
{
if (GC.MyChar != Target)
{
[spoiler]The code for team and etc.. put almost everything inside this foreach (you should know what you need to)[/spoiler]
}
}

I hope I helped enough.. Press Thanks please.
11/24/2010 20:55 .Beatz#114
Can you guys get back on topic please and stop provoking people...

Please read the rules... No flaming

No one on this forum is an idiot, they simply lack the knowledge needed or just are too lazy to learn.
11/25/2010 14:25 †he Knight#115
Quote:
Originally Posted by .Beatz View Post
Can you guys get back on topic please and stop provoking people...

Please read the rules... No flaming

No one on this forum is an idiot, they simply lack the knowledge needed or just are too lazy to learn.
My Post was very helpful.. And I Didn't flame for no reason.. he started
11/25/2010 16:19 |NeoX#116
Quote:
Originally Posted by †he Knight View Post
My Post was very helpful.. And I Didn't flame for no reason.. he started
Your ego needs to be cut.
11/26/2010 19:51 †he Knight#117
Quote:
Originally Posted by |NeoX View Post
Your ego needs to be cut.
Also your head.
12/05/2010 02:05 denominator#118
>.> I knew I should have just waited instead of attempting it myself in the first place lmao. This is what happens when you try to add it from another source then try and add it the correct way lol. I think Arcos code will work fine BUT I get this error.
12/05/2010 02:08 Syst3m_W1z4rd#119
your making a foreach loop for a string, when allies is a collection.
12/05/2010 05:35 denominator#120
Yup and the thing is it shouldn`t even be there lol. I can`t remember what I did and didn`t add from back then >.< Problem is if I take that part out then it comes up with errors.

Ok got past that hurdle but now I come across this part lol

Nevermind I got it working :D

Next problem is with deleting Guilds.dat >.< It is giving me errors all over the place :( So I have a folder in OldCODB "Guilds" and I have a Guilds.dat in there BUT I also have a Guilds.dat in the OldCODB as well?
NewestCOServer crashes also and when my char logs on there are no NPCs and my char is naked BUT he still has the topguildleader thing and professor and king >.<

Had another attempt and so far everything seems fine.



Ok WTF?!?!?!?! I try to add it to the guild NPC but it does nothing when I click add allies/enemies, however if I create a seperate NPC the friggin thing works o.0?

I will give code for my NPC and for guild NPC so why does it work for one but not the other o.0????

Code:
#region Guild NPC allied&enemied
                            case 19999:
                                {
                                    if (Control == 0)
                                    {
                                        GC.AddSend(Packets.NPCSay("I am what my name says. I create and manage guilds. So what do you want to do?"));
                                        GC.AddSend(Packets.NPCLink("Create Allies", 1));
                                        GC.AddSend(Packets.NPCLink("Create Enemies", 3));
                                        GC.AddSend(Packets.NPCLink("Just passing by.", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }
                                    #region Ally
                                    if (Control == 1)
                                    {
                                        GC.AddSend(Packets.NPCSay("Who would you like to Ally?"));
                                        GC.AddSend(Packets.NPCLink2("Ally", 21));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }
                                    if (Control == 21)
                                    {
                                        if (GC.MyChar.MyGuild != null && GC.MyChar.GuildRank == NewestCOServer.Features.GuildRank.GuildLeader)
                                        {
                                            string Ally = ReadString(Data);
                                            foreach (Features.Guild g in Features.Guilds.AllTheGuilds.Values)
                                            {
                                                if (g.GuildName == Ally)
                                                {
                                                    if (g.Creator.Info != null)
                                                    {
                                                        if (g.Creator.Info.MyTeam.Members.Contains(GC.MyChar.EntityID))
                                                        {
                                                            if (!GC.MyChar.MyGuild.Allies.ContainsValue(Ally))
                                                            {
                                                                GC.MyChar.MyGuild.Allies.Add(0, Ally);
                                                                GC.AddSend(Packets.String(g.GuildID, 21, Ally));
                                                                GC.AddSend(Packets.NPCSay(g.GuildName + " is now your ally!"));
                                                                GC.AddSend(Packets.NPCLink("Thanks.", 255));
                                                                GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                                                GC.AddSend(Packets.NPCFinish());
                                                            }
                                                            else
                                                            {
                                                                GC.AddSend(Packets.NPCSay(g.GuildName + " is already allied."));
                                                                GC.AddSend(Packets.NPCLink("Oh alright.", 255));
                                                                GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                                                GC.AddSend(Packets.NPCFinish());
                                                            }
                                                        }
                                                        else
                                                        {
                                                            GC.AddSend(Packets.NPCSay("Make sure the guild leader of the Features guild is in your team."));
                                                            GC.AddSend(Packets.NPCLink("Okay", 255));
                                                        }
                                                    }
                                                }
                                            }
                                            break;
                                        }
                                    }
                                    #endregion
                                    #region Enemy
                                    if (Control == 3)
                                    {
                                        GC.AddSend(Packets.NPCSay("Who would you like to Enemy?"));
                                        GC.AddSend(Packets.NPCLink2("Enemy", 23));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }
                                    if (Control == 23)
                                    {
                                        if (GC.MyChar.MyGuild != null && GC.MyChar.GuildRank == NewestCOServer.Features.GuildRank.GuildLeader)
                                        {
                                            string Enemy = ReadString(Data);
                                            foreach (Features.Guild g in Features.Guilds.AllTheGuilds.Values)
                                            {
                                                if (g.GuildName == Enemy)
                                                {
                                                    if (g.Creator.Info != null)
                                                    {
                                                        if (!GC.MyChar.MyGuild.Enemies.ContainsValue(Enemy))
                                                        {
                                                            GC.MyChar.MyGuild.Enemies.Add(0, Enemy);
                                                            GC.AddSend(Packets.String(g.GuildID, 21, Enemy));
                                                            GC.AddSend(Packets.NPCSay(g.GuildName + " is now your enemy!"));
                                                            GC.AddSend(Packets.NPCLink("Thanks.", 255));
                                                            GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                                            GC.AddSend(Packets.NPCFinish());
                                                        }
                                                        else
                                                        {
                                                            GC.AddSend(Packets.NPCSay(g.GuildName + " is already enemied."));
                                                            GC.AddSend(Packets.NPCLink("Oh alright.", 255));
                                                            GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                                            GC.AddSend(Packets.NPCFinish());
                                                        }
                                                    }
                                                    else
                                                    {
                                                        GC.AddSend(Packets.NPCSay("Make sure the guild leader of the Features guild is in your team."));
                                                        GC.AddSend(Packets.NPCLink("Okay", 255));
                                                    }
                                                }
                                            }
                                        }
                                        break;
                                    }
                                    #endregion

                                    break;
                                }
                            #endregion
Code:
#region Guild NPC
                            case 10003:
                                {
                                    if (Control == 0)
                                    {
                                        GC.AddSend(Packets.NPCSay("I am what my name says. I create and manage guilds. So what do you want to do?"));
                                        GC.AddSend(Packets.NPCLink("Create Guild", 1)); 
                                        GC.AddSend(Packets.NPCLink("Deputize", 3));
                                        GC.AddSend(Packets.NPCLink("Disband my guild", 5));
                                        GC.AddSend(Packets.NPCLink("Allies", 7));
                                        GC.AddSend(Packets.NPCLink("Enemies", 9));
                                        GC.AddSend(Packets.NPCLink("Just passing by.", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }
                                    #region Create
                                    else if (Control == 1)
                                    {
                                        if (GC.MyChar.MyGuild == null)
                                        {
                                            GC.AddSend(Packets.NPCSay("I don't know why, but you have to be level 95 or higher and need 1 million silvers to create one."));
                                            GC.AddSend(Packets.NPCLink2("Create", 2));
                                            GC.AddSend(Packets.NPCLink("No, i changed my mind.", 255));
                                            GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                            GC.AddSend(Packets.NPCFinish());
                                        }
                                        else
                                        {
                                            GC.AddSend(Packets.NPCSay("You are already in a guild. You cannot create a guild."));
                                            GC.AddSend(Packets.NPCLink("Oh, i forgot...", 255));
                                            GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                            GC.AddSend(Packets.NPCFinish());
                                        }
                                    }
                                    else if (Control == 2)
                                    {
                                        if (GC.MyChar.Level >= 95 && GC.MyChar.MyGuild == null)
                                        {
                                            if (GC.MyChar.Silvers >= 1000000)
                                            {
                                                string GuildName = ReadString(Data);
                                                if (Features.Guilds.ValidName(GuildName))
                                                {
                                                    GC.MyChar.Silvers -= 1000000;
                                                    ushort NewGuildID = (ushort)Rnd.Next(ushort.MaxValue);
                                                    while (Features.Guilds.AllTheGuilds.Contains(NewGuildID))
                                                        NewGuildID = (ushort)Rnd.Next(ushort.MaxValue);
                                                    Features.Guilds.CreateNewGuild(GuildName, NewGuildID, GC.MyChar);
                                                    Game.World.Spawn(GC.MyChar, false);

                                                    GC.AddSend(Packets.GuildInfo(GC.MyChar.MyGuild, GC.MyChar));
                                                    GC.AddSend(Packets.String(GC.MyChar.MyGuild.GuildID, (byte)Game.StringType.GuildName, GC.MyChar.MyGuild.GuildName));

                                                    GC.AddSend(Packets.NPCSay("Congratulations! You now have your own guild."));
                                                    GC.AddSend(Packets.NPCLink("Thanks.", 255));
                                                    GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                                    GC.AddSend(Packets.NPCFinish());
                                                }
                                                else
                                                {
                                                    GC.AddSend(Packets.NPCSay("Choose another name, this name is taken or has invalid length."));
                                                    GC.AddSend(Packets.NPCLink2("Create", 2));
                                                    GC.AddSend(Packets.NPCLink("I changed my mind.", 255));
                                                    GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                                    GC.AddSend(Packets.NPCFinish());
                                                }
                                            }
                                            else
                                            {
                                                GC.AddSend(Packets.NPCSay("I said you need 1 million silvers and you don't have enough."));
                                                GC.AddSend(Packets.NPCLink("Ok ok, i'll go bring the money.", 255));
                                                GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                                GC.AddSend(Packets.NPCFinish());
                                            }
                                        }
                                        else
                                        {
                                            GC.AddSend(Packets.NPCSay("Forget it! You're too weak."));
                                            GC.AddSend(Packets.NPCLink("Alright, i will get stronger.", 255));
                                            GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                            GC.AddSend(Packets.NPCFinish());
                                        }
                                    }
                                    #endregion
                                    #region Deputize
                                    else if (Control == 3)
                                    {
                                        if (GC.MyChar.MyGuild != null && GC.MyChar.GuildRank == NewestCOServer.Features.GuildRank.GuildLeader)
                                        {
                                            GC.AddSend(Packets.NPCSay("Insert the name of the player in your guild you want to make a deputy leader."));
                                            GC.AddSend(Packets.NPCLink2("Here", 4));
                                            GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                            GC.AddSend(Packets.NPCFinish());
                                        }
                                        else
                                        {
                                            GC.AddSend(Packets.NPCSay("You are not a guild leader."));
                                            GC.AddSend(Packets.NPCLink("Silly me.", 255));
                                            GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                            GC.AddSend(Packets.NPCFinish());
                                        }
                                    }
                                    else if (Control == 4)
                                    {
                                        string PlayerName = ReadString(Data);
                                        Features.MemberInfo M = GC.MyChar.MyGuild.MembOfName(PlayerName);
                                        if (M != null && M.MembName == PlayerName && ((Hashtable)GC.MyChar.MyGuild.Members[(byte)90]).Count < 5)
                                        {
                                            M.Rank = NewestCOServer.Features.GuildRank.DeputyManager;
                                            ((Hashtable)GC.MyChar.MyGuild.Members[(byte)50]).Remove(M.MembID);
                                            ((Hashtable)GC.MyChar.MyGuild.Members[(byte)90]).Add(M.MembID, M);
                                            Game.Character C = M.Info;
                                            if (C != null)
                                            {
                                                C.GuildRank = NewestCOServer.Features.GuildRank.DeputyManager;
                                                Game.World.Spawn(C, false);
                                                C.MyClient.AddSend(Packets.GuildInfo(GC.MyChar.MyGuild, GC.MyChar));
                                            }
                                        }
                                        else
                                        {
                                            GC.AddSend(Packets.NPCSay("The player is not in your guild or is not a normal member. By the way, the max number deputy leaders there can be is 5."));
                                            GC.AddSend(Packets.NPCLink("Oh, sorry.", 255));
                                            GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                            GC.AddSend(Packets.NPCFinish());
                                        }
                                    }
                                    #endregion
                                    #region Disband
                                    else if (Control == 5)
                                    {
                                        if (GC.MyChar.MyGuild != null && GC.MyChar.GuildRank == NewestCOServer.Features.GuildRank.GuildLeader)
                                        {
                                            GC.AddSend(Packets.NPCSay("Are you sure you want to disband your guild?"));
                                            GC.AddSend(Packets.NPCLink("Yes, i want to disband my guild.", 6));
                                            GC.AddSend(Packets.NPCLink("I've changed my mind.", 255));
                                            GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                            GC.AddSend(Packets.NPCFinish());
                                        }
                                        else
                                        {
                                            GC.AddSend(Packets.NPCSay("You are not a guild leader, therefore you cannot disband a guild."));
                                            GC.AddSend(Packets.NPCLink("I see.", 255));
                                            GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                            GC.AddSend(Packets.NPCFinish());
                                        }
                                    }
                                    else if (Control == 6)
                                    {
                                        if (GC.MyChar.MyGuild != null && GC.MyChar.GuildRank == NewestCOServer.Features.GuildRank.GuildLeader)
                                        {
                                            GC.MyChar.MyGuild.Disband();
                                        }
                                    #endregion                                    
                                    #region Ally
                                        if (Control == 7)
                                        {
                                            GC.AddSend(Packets.NPCSay("Who would you like to Ally?"));
                                            GC.AddSend(Packets.NPCLink2("Ally", 21));
                                            GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                            GC.AddSend(Packets.NPCFinish());
                                        }
                                        else if (Control == 21)
                                        {
                                            if (GC.MyChar.MyGuild != null && GC.MyChar.GuildRank == NewestCOServer.Features.GuildRank.GuildLeader)
                                            {
                                                string Ally = ReadString(Data);
                                                foreach (Features.Guild g in Features.Guilds.AllTheGuilds.Values)
                                                {
                                                    if (g.GuildName == Ally)
                                                    {
                                                        if (g.Creator.Info != null)
                                                        {
                                                            if (g.Creator.Info.MyTeam.Members.Contains(GC.MyChar.EntityID))
                                                            {
                                                                if (!GC.MyChar.MyGuild.Allies.ContainsValue(Ally))
                                                                {
                                                                    GC.MyChar.MyGuild.Allies.Add(0, Ally);
                                                                    GC.AddSend(Packets.String(g.GuildID, 21, Ally));
                                                                    GC.AddSend(Packets.NPCSay(g.GuildName + " is now your ally!"));
                                                                    GC.AddSend(Packets.NPCLink("Thanks.", 255));
                                                                    GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                                                    GC.AddSend(Packets.NPCFinish());
                                                                }
                                                                else
                                                                {
                                                                    GC.AddSend(Packets.NPCSay(g.GuildName + " is already allied."));
                                                                    GC.AddSend(Packets.NPCLink("Oh alright.", 255));
                                                                    GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                                                    GC.AddSend(Packets.NPCFinish());
                                                                }
                                                            }
                                                            else
                                                            {
                                                                GC.AddSend(Packets.NPCSay("Make sure the guild leader of the Features guild is in your team."));
                                                                GC.AddSend(Packets.NPCLink("Okay", 255));
                                                            }
                                                        }
                                                    }
                                                }
                                                break;
                                            }
                                        }
                                        #endregion
                                    #region Enemy
                                        if (Control == 9)
                                        {
                                            GC.AddSend(Packets.NPCSay("Who would you like to Enemy?"));
                                            GC.AddSend(Packets.NPCLink2("Enemy", 23));
                                            GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                            GC.AddSend(Packets.NPCFinish());
                                        }
                                        else if (Control == 23)
                                        {
                                            if (GC.MyChar.MyGuild != null && GC.MyChar.GuildRank == NewestCOServer.Features.GuildRank.GuildLeader)
                                            {
                                                string Enemy = ReadString(Data);
                                                foreach (Features.Guild g in Features.Guilds.AllTheGuilds.Values)
                                                {
                                                    if (g.GuildName == Enemy)
                                                    {
                                                        if (g.Creator.Info != null)
                                                        {
                                                            if (!GC.MyChar.MyGuild.Enemies.ContainsValue(Enemy))
                                                            {
                                                                GC.MyChar.MyGuild.Enemies.Add(0, Enemy);
                                                                GC.AddSend(Packets.String(g.GuildID, 23, Enemy));
                                                                GC.AddSend(Packets.NPCSay(g.GuildName + " is now your enemy!"));
                                                                GC.AddSend(Packets.NPCLink("Thanks.", 255));
                                                                GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                                                GC.AddSend(Packets.NPCFinish());
                                                            }
                                                            else
                                                            {
                                                                GC.AddSend(Packets.NPCSay(g.GuildName + " is already enemied."));
                                                                GC.AddSend(Packets.NPCLink("Oh alright.", 255));
                                                                GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                                                GC.AddSend(Packets.NPCFinish());
                                                            }
                                                        }
                                                        else
                                                        {
                                                            GC.AddSend(Packets.NPCSay("Make sure the guild leader of the Features guild is in your team."));
                                                            GC.AddSend(Packets.NPCLink("Okay", 255));
                                                        }
                                                    }
                                                }
                                            }
                                            break;
                                        }
                                        #endregion
                                    }
                                    break;
                                }
                                #endregion