|
You last visited: Today at 13:21
Advertisement
Save Guild Enemies/Allies
Discussion on Save Guild Enemies/Allies within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.
08/28/2010, 06:06
|
#1
|
elite*gold: 0
Join Date: Oct 2009
Posts: 8,783
Received Thanks: 5,304
|
Save Guild Enemies/Allies
First and foremost this is for 5165 Tanel source. NewestCOServer.
Well first define this in features/guilds.cs under public class Guild
Code:
public Dictionary<uint, string> Allies = new Dictionary<uint, string>();
public Dictionary<uint, string> Enemies = new Dictionary<uint, string>();
Code:
public static void CreateNewGuild(string GName, ushort GID, Character Creator)
And at the bottom of this void, put this
Code:
G.Allies.Add(0, "");
G.Enemies.Add(0, "");
Scroll down you should see this
Code:
public void SaveThis(BinaryWriter BW)
At the bottom, under BW.Write(Wins);
insert this,
Code:
BW.Write((int)Allies.Count);
foreach (KeyValuePair<uint, string> kvp in Allies)
{
BW.Write(Convert.ToUInt32(kvp.Key));
BW.Write(Convert.ToString(kvp.Value));
}
BW.Write((int)Enemies.Count);
foreach (KeyValuePair<uint, string> kvp in Enemies)
{
BW.Write(Convert.ToUInt32(kvp.Key));
BW.Write(Convert.ToString(kvp.Value));
}
Next scroll down to public Guild(BinaryReader BR) and under
Wins = BR.ReadUInt32();
insert this
Code:
int a = BR.ReadInt32();
{
for (int i = 0; i < a; i++)
Allies.Add(BR.ReadUInt32(), BR.ReadString());
}
int e = BR.ReadInt32();
{
for (int i = 0; i < e; i++)
Enemies.Add(BR.ReadUInt32(), BR.ReadString());
}
And bam, loading and saving.
To add to the dictionary it is GuildID then GuildName.
|
|
|
08/28/2010, 06:49
|
#2
|
elite*gold: 0
Join Date: Sep 2007
Posts: 188
Received Thanks: 8
|
thanks but i get this error
and how to add it in npc to make Enemies
|
|
|
08/28/2010, 07:01
|
#3
|
elite*gold: 0
Join Date: Oct 2009
Posts: 8,783
Received Thanks: 5,304
|
Make sure your server is off, delete guilds.dat. and then start the server, create a guild, and see if it works.
And as of adding the enemies via npc, just make the npc add the enemy ID and Name.
|
|
|
08/28/2010, 10:49
|
#4
|
elite*gold: 0
Join Date: Sep 2008
Posts: 39
Received Thanks: 0
|
Ye it works 
You'll just have to delete your Guilds.dat
Well, i'll try ( bet i wont get it omg ^^ ) to write the code for the npc - i'll let you know if it works.
BIG THANKS! (Y)
|
|
|
08/28/2010, 11:52
|
#5
|
elite*gold: 0
Join Date: May 2009
Posts: 480
Received Thanks: 112
|
booooo @ arco rofl jks great work bro
|
|
|
08/28/2010, 13:10
|
#6
|
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
|
Quote:
Originally Posted by .Arco
At the bottom, under BW.Write(Wins);
insert this,
Code:
BW.Write((int)Allies.Count);
foreach (KeyValuePair<uint, string> kvp in Allies)
{
BW.Write(Convert.ToUInt32(kvp.Key));
BW.Write(Convert.ToString(kvp.Value));
}
BW.Write((int)Enemies.Count);
foreach (KeyValuePair<uint, string> kvp in Enemies)
{
BW.Write(Convert.ToUInt32(kvp.Key));
BW.Write(Convert.ToString(kvp.Value));
}
|
Why convert uint to uint and string to string? I don't get it.
Code:
BW.Write((int)Allies.Count);
foreach (KeyValuePair<uint, string> kvp in Allies)
{
BW.Write(kvp.Key);
BW.Write(kvp.Value);
}
BW.Write((int)Enemies.Count);
foreach (KeyValuePair<uint, string> kvp in Enemies)
{
BW.Write(kvp.Key);
BW.Write(kvp.Value);
}
|
|
|
08/28/2010, 15:44
|
#7
|
elite*gold: 0
Join Date: Oct 2009
Posts: 8,783
Received Thanks: 5,304
|
Quote:
Originally Posted by nTL3fTy
Why convert uint to uint and string to string? I don't get it.
Code:
BW.Write((int)Allies.Count);
foreach (KeyValuePair<uint, string> kvp in Allies)
{
BW.Write(kvp.Key);
BW.Write(kvp.Value);
}
BW.Write((int)Enemies.Count);
foreach (KeyValuePair<uint, string> kvp in Enemies)
{
BW.Write(kvp.Key);
BW.Write(kvp.Value);
}
|
I don't know either man :/
But it didn't work till I did that.
I would keep getting "Cannot read to end of stream." error.
But once I did that, it worked.
|
|
|
08/28/2010, 16:08
|
#8
|
elite*gold: 0
Join Date: May 2009
Posts: 884
Received Thanks: 211
|
so....what would be a good example of how it might look like in an npc  ?
|
|
|
08/28/2010, 16:17
|
#9
|
elite*gold: 0
Join Date: Aug 2010
Posts: 452
Received Thanks: 75
|
I think u just won :P
|
|
|
08/28/2010, 16:23
|
#10
|
elite*gold: 0
Join Date: May 2006
Posts: 1,190
Received Thanks: 516
|
The NPC you already have should be fine for the allys/enemys just add this code into the NPC under Disband. Not sure if this will work for you but it works for me and has done for a while now. All you should need to do is change a few things.
NOTE! : This is JUST Allys you should be able to work out enemys for yourself.
Code:
#region Ally
if (option == 20)
{
Say("Who would you like to ally?", GC);
Link2("Ally", 21, GC);
Done(30, GC);
}
if (option == 21)
if (GC.MyChar.MyGuild != null && GC.MyChar.GuildRank == MayaCo.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.AddAlly(Ally);
GC.AddSend(Packets.String(g.GuildID, 21, Ally));
Say(g.GuildName + " is now your ally!", GC);
Link("Thanks.", 255, GC);
}
else
{
Say(g.GuildName + " is already your ally.", GC);
Link("Damn.", 255, GC);
}
}
else
{
Say("Make sure the guild leader of the Features guild is in your team.", GC);
Link("Okay", 255, GC);
}
}
}
}
break;
}
#endregion
If this doesn't work for you I will recode it using Tanels source.
|
|
|
08/28/2010, 16:26
|
#11
|
elite*gold: 0
Join Date: Oct 2009
Posts: 8,783
Received Thanks: 5,304
|
@Matty
Haha straight out of my source I gave you >.<
|
|
|
08/28/2010, 16:31
|
#12
|
elite*gold: 0
Join Date: May 2009
Posts: 884
Received Thanks: 211
|
Quote:
Originally Posted by .Arco
@Matty
Haha straight out of my source I gave you >.<
|
dont worry >.< hes a very good friend and trust me he doesnt leech LOL...
|
|
|
08/28/2010, 16:36
|
#13
|
elite*gold: 0
Join Date: May 2006
Posts: 1,190
Received Thanks: 516
|
Quote:
Originally Posted by .Arco
@Matty
Haha straight out of my source I gave you >.<
|
Whoops posted the wrong one lmao. Got one in my other source that I use lol.
|
|
|
08/28/2010, 17:00
|
#14
|
elite*gold: 0
Join Date: Feb 2009
Posts: 700
Received Thanks: 79
|
I get an error on these 2 lines:
Code:
G.Allies.Add(0, "");
G.Enemies.Add(0, "");
The error is "Cannot use local variable 'G' before it is declared".
|
|
|
08/28/2010, 17:01
|
#15
|
elite*gold: 0
Join Date: Oct 2009
Posts: 8,783
Received Thanks: 5,304
|
Quote:
Originally Posted by copz1337
I get an error on these 2 lines:
Code:
G.Allies.Add(0, "");
G.Enemies.Add(0, "");
The error is "Cannot use local variable 'G' before it is declared".
|
o.o Where are you putting it?
Are you putting in inside of the void?
|
|
|
 |
|
Similar Threads
|
[Problem]Guild Allies and Enemies
08/16/2010 - CO2 Private Server - 2 Replies
Well after two days of having a go at this, and one day of asking people for help, I finally decided it was time to ask the community for help.
Well I am trying to load allies from the Guilds.dat file.
They are defined as public Dictionary<uint, string> Allies = new Dictionary<uint, string>();
When something is added to the dictionary its like this.
Allies.Add(GuildID, GuildName);
Now when saving to the guild.dat file, its saved like this.
BW.Write((int)Allies.Count);
...
|
allies and enemies
03/31/2010 - CO2 Private Server - 1 Replies
Anybody know if Guild Allie and Enemy code is released for LOTF?
The status are added, but not codes for npc.
And im to lazy to make it, so if is not released ill just leave it untill i got time to make it ^^
Thanks
|
[Help]Guild Allies
02/14/2010 - CO2 Private Server - 9 Replies
could someone help me with allies this is what i have so far
if (MyChar.GuildPosition == 100)
{
if (MyChar.MyGuild.Allies.Count <= 6)
{
string Allies = "";
for (int i = 14; i < 14 + Data; i++)
{
Allies +=...
|
[Question]Guild Allies
02/02/2010 - CO2 Private Server - 0 Replies
could someone help me with adding allies
its for 5017
|
guild and allies
12/29/2007 - CO2 Weapon, Armor, Effects & Interface edits - 0 Replies
hi all
i was thinking
does anyone know if its possible to make allie colors yellow and guild green
cause i like the green more
grtz
|
All times are GMT +1. The time now is 13:23.
|
|