Hi all. Here is my way to get guilds work on CoEmuv2.
First of all, make copy of your source, before you start doing anything with it. To avoid any bugs read carefully that guide. I have spent some time to get it work, so press Thank if it helps.
So lets start.
1.Create new class file Guild.cs under GS>Entities and paste whole code:
2.Create new class file Guild.cs under GS>Packets and paste whole code:
3. Go to GS>PacketProcessor.cs and search for:
Above add:
4. Open up GS>Entities>Charater.cs and find:
bottom add:
5. Go to GS>Calculations>CanSee.cs and after that
add:
6. Open GS>Calculations>Exp.cs. Find:
and after that add:
7. Go to GS>Nano.cs find:
after it add:
8. Open GS>Entities>Spawn.cs and after:
add:
9. In GS>Handlers>Chat.cs lock for:
and bottom add:
10. Next GS>Database>Database.cs look for:
In GetCharacter void and add after it:
Still here search for:
and replace it with:
11. Open Up GS>Packets>SpawnCharacter.cs and replace
with :
12. Open GS>Nano.cs find StartServer() void and after Struct.LoadTNpcs(); add:
13. Go To GS>Handlers>NPCTalk.cs and look for:
replace it with:
look for:
and add:(if you dont have already)
14. still NPCTalk.cs add that somewhere:
15. In GS>PacketProcessor.cs search for:
then replace:
with:
16. In GS>PacketProcessor.cs find:
and after it add:
17. Last thing what you must do is edit your database. Find Members column under guilds tabble and change type to Text and allow null and Leader to vchar(26)you can execute that sql script in phpmyadmin to do it for you:
Its all(for now). I hope You will like it.
First of all, make copy of your source, before you start doing anything with it. To avoid any bugs read carefully that guide. I have spent some time to get it work, so press Thank if it helps.
So lets start.
1.Create new class file Guild.cs under GS>Entities and paste whole code:
Code:
/*
* Created by Bisiol.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Timers;
using CoEmu_v2_GameServer.Connections;
using CoEmu_v2_GameServer.Structs;
using CoEmu_v2_GameServer.Packets;
using CoEmu_v2_GameServer.Database;
namespace CoEmu_v2_GameServer.Entities
{
/// <summary>
/// A conquer online guild.
/// </summary>
public class Guild
{
public ushort ID;//Guild ID
public string Name;//Guild Name
public member Leader;// Guild Leader
public Dictionary<int, member> Members = new Dictionary<int, member>();//Members(normal and DL)
public int Fund;//Guild Fund
public uint MembersCount;//Number of all members
public string Bulletin; //Bulletin
/// <summary>
/// Remove member from guild and sent message to guild members.
/// </summary>
public void PlayerQuits(Character Quitter)
{
Members.Remove(Quitter.ID);
GuildMessage(Quitter.Name + " has left our guild.");
MembersCount--;
}
public static void refresh(ClientSocket CSocket)
{
if (CSocket.Client.InGuild && Nano.Guilds.ContainsKey(CSocket.Client.gid))
{
Guild gd = Nano.Guilds[CSocket.Client.gid];
CSocket.Send(ConquerPacket.GName(CSocket.Client.gid, CSocket.Client.gna));
CSocket.Send(ConquerPacket.Ginfo(gd, CSocket.Client));
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, gd.Bulletin, Struct.ChatType.GuildBulletin));
}
}
public void GuildMessage(string Message)
{
if (Nano.ClientPool.ContainsKey(Leader.ID))
{
Nano.ClientPool[Leader.ID].Send(ConquerPacket.Chat(0, "Guild", "All", Message, Struct.ChatType.Guild));
}
foreach (KeyValuePair<int, member> mb in Members)
{
if (Nano.ClientPool.ContainsKey(mb.Value.ID))
{
Nano.ClientPool[mb.Value.ID].Send(ConquerPacket.Chat(0, "Guild", "All", Message, Struct.ChatType.Guild));
}
}
}
}
public class member : IComparable<member>
{
public int ID;
public string Name = "";
public bool isDL = false;
public int lvl;
public int Donation = 0;
#region IComparable<member> Members
public int CompareTo(member other)
{
return other.lvl.CompareTo(this.lvl);
}
#endregion
}
}
Code:
/*
* Created by Bisiol.
*/
using System;
using CoEmu_v2_GameServer.Connections;
using CoEmu_v2_GameServer.Entities;
namespace CoEmu_v2_GameServer.Packets
{
/// <summary>
/// Guild packets.
/// </summary>
public partial class ConquerPacket
{
public static byte[] GSend(int GuildID, byte Type)
{
PacketBuilder Packet = new PacketBuilder(0x453, 12);
Packet.Long(Type);
Packet.Long(GuildID);
return Packet.getFinal();
}
public static byte[] Ginfo(Guild gd, Character ch)
{
PacketBuilder Packet = new PacketBuilder(0x452, 21 + gd.Leader.Name.Length);
Packet.Long(gd.ID); //id
Packet.Long(ch.donation); //don
Packet.Long(gd.Fund); //fund
Packet.Long(gd.MembersCount); //mc
Packet.Int(ch.gpo); //pos
Packet.Text(gd.Leader.Name); //gl
return Packet.getFinal();
}
public static byte[] GName(ushort ID, string Name)
{
PacketBuilder Packet = new PacketBuilder(1015, 11 + Name.Length);
Packet.Short(ID);
Packet.Int(0);
Packet.Int(0);
Packet.Int(3);
Packet.Int(1);
Packet.Int(Name.Length);
for (int i = 0; i < Name.Length; i++)
{
Packet.Int(Convert.ToByte(Name[i]));
}
return Packet.getFinal();
}
public static byte[] GList(long CharId, byte Type, string name, byte Count)
{
PacketBuilder Packet = new PacketBuilder(1015, 10 + name.Length);
Packet.Long((uint)CharId);
Packet.Int(Type);
Packet.Int((byte)Count);
Packet.Text(name);
return Packet.getFinal();
}
}
}
Code:
#region CreateCharacter case 1001://Create Character
Code:
#region 3F7(1015),485(1107) guild
case 1015://Send guild members
{
string PackMembers = "";
string OnlineGL = "";
string OfflineGL = "";
string OnlineDL = "";
string OfflineDL = "";
string Online = "";
string Offline = "";
Guild GD = Nano.Guilds[CSocket.Client.gid];
if (Nano.ClientPool.ContainsKey(GD.Leader.ID))
OnlineGL += Convert.ToChar((GD.Leader.Name + " " + GD.Leader.lvl.ToString() + " 1").Length) + GD.Leader.Name + " " + GD.Leader.lvl.ToString() + " 1";
else
OfflineGL += Convert.ToChar((GD.Leader.Name + " " + GD.Leader.lvl.ToString() + " 0").Length) + GD.Leader.Name + " " + GD.Leader.lvl.ToString() + " 0";
List<member> ms = new List<member>();
foreach (KeyValuePair<int, member> mb in GD.Members)
{
ms.Add(mb.Value);
}
ms.Sort();
foreach (member m in ms)
{
if (m.isDL)
{
if (Nano.ClientPool.ContainsKey(m.ID))
OnlineDL += Convert.ToChar((m.Name + " " + m.lvl.ToString() + " 1").Length) + m.Name + " " + m.lvl.ToString() + " 1";
else
OfflineDL += Convert.ToChar((m.Name + " " + m.lvl.ToString() + " 0").Length) + m.Name + " " + m.lvl.ToString() + " 0";
}
else
{
if (Nano.ClientPool.ContainsKey(m.ID))
Online += Convert.ToChar((m.Name + " " + m.lvl.ToString() + " 1").Length) + m.Name + " " + m.lvl.ToString() + " 1";
else
Offline += Convert.ToChar((m.Name + " " + m.lvl.ToString() + " 0").Length) + m.Name + " " + m.lvl.ToString() + " 0";
}
}
PackMembers = OnlineGL + OfflineGL + OnlineDL + OfflineDL + Online + Offline;
CSocket.Send(ConquerPacket.GList(11, 11, PackMembers, (byte)(1 + GD.Members.Count)));
break;
}
case 1107:
{
uint UID = BitConverter.ToUInt32(data, 8);
byte Typee = Data[4];
switch (Typee)
{
case 1://Send Join request
{
ClientSocket target = Nano.ClientPool[(int)UID];
if (!CSocket.Client.InGuild && (target.Client.gpo == 100 || target.Client.gpo == 90))
{
target.Send(ConquerPacket.GSend(CSocket.Client.ID, 1));
}
break;
}
case 2://Accept join request
{
if (Nano.ClientPool.ContainsKey((int)UID))
{
ClientSocket target = Nano.ClientPool[(int)UID];
if (!target.Client.InGuild)
{
Guild gd = Nano.Guilds[CSocket.Client.gid];
target.Client.gid = gd.ID;
target.Client.gna = gd.Name;
target.Client.gpo = 50;
target.Client.InGuild = true;
member m = new member();
m.ID = target.Client.ID;
m.Name = target.Client.Name;
m.lvl = target.Client.Level;
gd.Members.Add(m.ID, m);
gd.MembersCount++;
target.Send(ConquerPacket.GName(target.Client.gid, target.Client.gna));
target.Send(ConquerPacket.Ginfo(gd, target.Client));
target.Send(ConquerPacket.Chat(0, "SYSTEM", target.Client.Name, gd.Bulletin, Struct.ChatType.GuildBulletin));
foreach (KeyValuePair<int, Guild> GD in Nano.Guilds)
{
CSocket.Send(ConquerPacket.GName(GD.Value.ID, GD.Value.Name));
}
Spawn.MeTo(target);
Database.Database.UpdateGuild(gd);
}
}
break;
}
case 3://Leave the guild
{
if (CSocket.Client.InGuild && CSocket.Client.gpo != 100)
{
Guild gd = Nano.Guilds[CSocket.Client.gid];
CSocket.Send(ConquerPacket.GSend(CSocket.Client.gid, 19));
gd.PlayerQuits(CSocket.Client);
CSocket.Client.donation = 0;
CSocket.Client.gid = 0;
CSocket.Client.gna = "";
CSocket.Client.gpo = 50;
CSocket.Client.InGuild = false;
Spawn.MeTo(CSocket);
Database.Database.UpdateGuild(gd);
}
break;
}
case 6://Get Guild Name
{
CSocket.Send(ConquerPacket.GName((ushort)UID, Nano.Guilds[(int)UID].Name));
Guild.refresh(CSocket);
Spawn.MeTo(CSocket);
break;
}
case 11://Donate
{
if (CSocket.Client.InGuild)
{
if (Nano.Guilds.ContainsKey(CSocket.Client.gid))
{
Guild GD = Nano.Guilds[CSocket.Client.gid];
int Amount = BitConverter.ToInt32(Data, 8);
if (CSocket.Client.Money >= Amount)
{
GD.Fund += Amount;
CSocket.Client.Money -= Amount;
CSocket.Client.donation += Amount;
if(CSocket.Client.gpo==100)
GD.Leader.Donation = CSocket.Client.donation;
else
GD.Members[CSocket.Client.ID].Donation = CSocket.Client.donation;
CSocket.Send(ConquerPacket.Ginfo(GD, CSocket.Client));
CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.Money, Struct.StatusTypes.InvMoney));
Database.Database.UpdateGuild(GD);
foreach (KeyValuePair<int, ClientSocket> to in Nano.ClientPool)
{
if (CSocket.Client.Map == to.Value.Client.Map)
if (Calculation.CanSeePlus(CSocket.Client.X, CSocket.Client.Y, to.Value.Client.X, to.Value.Client.Y))
to.Value.Send(ConquerPacket.Chat(0, "SYSTEM", "ALL", CSocket.Client.Name + " has donated " + Amount.ToString() + " silvers to " + CSocket.Client.gna + ".", Struct.ChatType.Top));
}
}
}
}
break;
}
case 12://Guild status
{
Guild.refresh(CSocket);
break;
}
}
break;
}
#endregion
Code:
public Timer UpStam; public Timer FlashTimer;
Code:
// guild
public bool InGuild = false;
public ushort gid = 0;
public int gpo = 0;
public string gna = "";
public int donation = 0;
Code:
public static bool CanSee(int SeeX, int SeeY, int MyX, int MyY)
{
return (Math.Max(Math.Abs(SeeX - MyX), Math.Abs(SeeY - MyY)) <= 15);
}
Code:
public static bool CanSeePlus(int SeeX, int SeeY, int MyX, int MyY)
{
return (Math.Max(Math.Abs(SeeX - MyX), Math.Abs(SeeY - MyY)) <= 25);
}
Code:
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "You have gained three attribute points! Use them wiesely!", Struct.ChatType.Top));
Code:
if (CSocket.Client.InGuild)
if (CSocket.Client.gpo == 100)
Nano.Guilds[CSocket.Client.gid].Leader.lvl = CSocket.Client.Level;
else
Nano.Guilds[CSocket.Client.gid].Members[CSocket.Client.ID].lvl = CSocket.Client.Level;
Code:
public static Dictionary<int, Struct.TerrainNPC> TerrainNpcs = new Dictionary<int, Struct.TerrainNPC>();
Code:
public static Dictionary<int, Guild> Guilds = new Dictionary<int, Guild>();
Code:
public class Spawn
{
Code:
public static void MeTo(ClientSocket CSocket)
{
try
{
Monitor.Enter(Nano.ClientPool);
foreach (KeyValuePair<int, ClientSocket> Locals in Nano.ClientPool)
{
ClientSocket C = Locals.Value;
if ((int)C.Client.Map == (int)CSocket.Client.Map && CSocket.Client.ID != C.Client.ID)
{
if (Calculation.CanSee(CSocket.Client.X, CSocket.Client.Y, C.Client.X, C.Client.Y))
{
C.Send(ConquerPacket.General(CSocket.Client.ID, CSocket.Client.PrevX, CSocket.Client.PrevY, 0, 0, 0, Struct.DataType.EntityRemove));
CSocket.Send(ConquerPacket.General(C.Client.ID, C.Client.PrevX, C.Client.PrevY, 0, 0, 0, Struct.DataType.EntityRemove));
All(C);
All(CSocket);
CSocket.Send(ConquerPacket.SpawnCharacter(C));
C.Send(ConquerPacket.SpawnCharacter(CSocket));
}
}
}
Spawn.All(CSocket);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
finally
{
Monitor.Exit(Nano.ClientPool);
}
}
Code:
case Struct.ChatType.Friend:
{
ConquerPacket.ToServer(ConquerPacket.Chat(0, From, To, Message, Struct.ChatType.Friend), CSocket.Client.ID);
break;
}
Code:
case Struct.ChatType.GuildBulletin:
{
if (CSocket.Client.InGuild)
{
if (Nano.Guilds.ContainsKey(CSocket.Client.gid))
{
Nano.Guilds[CSocket.Client.gid].Bulletin = Message;
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, Nano.Guilds[CSocket.Client.gid].Bulletin, Struct.ChatType.GuildBulletin));
Database.Database.UpdateGuild(Nano.Guilds[CSocket.Client.gid]);
}
}
break;
}
case Struct.ChatType.Guild:
{
if (Nano.ClientPool.ContainsKey(Nano.Guilds[CSocket.Client.gid].Leader.ID))
if (Nano.Guilds[CSocket.Client.gid].Leader.ID != CSocket.Client.ID)
Nano.ClientPool[Nano.Guilds[CSocket.Client.gid].Leader.ID].Send(ConquerPacket.Chat(0, CSocket.Client.Name, To, Message, Type));
foreach (KeyValuePair<int, member> M in Nano.Guilds[CSocket.Client.gid].Members)
{
if(Nano.ClientPool.ContainsKey(M.Value.ID))
if (M.Value.ID != CSocket.Client.ID)
Nano.ClientPool[M.Value.ID].Send(ConquerPacket.Chat(0, CSocket.Client.Name, To, Message, Type));
}
break;
}
Code:
Client.Vitality = Convert.ToInt32(DR["Vit"]);
Code:
//Guild
Client.gid = Convert.ToUInt16(DR["Guild"]);
Client.gpo = Convert.ToInt32(DR["GRank"]);
Client.donation = Convert.ToInt32(DR["GDonation"]);
if (Client.gid != 0 && Nano.Guilds.ContainsKey(Client.gid))
{
if (Nano.Guilds[Client.gid].Leader.ID != Client.ID)
{
if (Nano.Guilds[Client.gid].Members.ContainsKey(Client.ID))
{
Nano.Guilds[Client.gid].Members[Client.ID].Donation = Client.donation;
Client.gna = Nano.Guilds[Client.gid].Name;
Client.InGuild = true;
if (Nano.Guilds[Client.gid].Members[Client.ID].isDL)
{
Client.gpo = 90;
}
else
{
Client.gpo = 50;
}
}
else
{
Client.InGuild = false;
Client.gna = "";
Client.gpo = 50;
Client.gid = 0;
}
}
else
{
Nano.Guilds[Client.gid].Leader.Donation = Client.donation;
Client.InGuild = true;
Client.gna = Nano.Guilds[Client.gid].Name;
}
}
//
Code:
public static void DeleteGuild(int ID)
{
MySqlCommand Cmd = new MySqlCommand("DELETE FROM `guilds` Where `GuildID` = " + ID + "", DatabaseConnection.NewConnection());
Cmd.ExecuteNonQuery();
Cmd.Connection.Close();
Cmd.Connection.Dispose();
Cmd.Dispose();
}
Code:
public static void LoadGuilds()
{
MySqlCommand Cmd = new MySqlCommand("SELECT * FROM `guilds`", DatabaseConnection.NewConnection());
MySqlDataReader DR = Cmd.ExecuteReader(CommandBehavior.CloseConnection);
MySqlCommand Cmd2 = new MySqlCommand("SELECT Level, CharId FROM `characters`", DatabaseConnection.NewConnection());
MySqlDataReader DR2 = Cmd2.ExecuteReader(CommandBehavior.CloseConnection);
Dictionary<int, int> ChLvl = new Dictionary<int, int>();
while (DR2.Read())
{
int id = Convert.ToInt32(DR2["CharID"]);
int lvl = Convert.ToInt32(DR2["Level"]);
ChLvl.Add(id, lvl);
}
while (DR.Read())
{
Guild GD = new Guild();
GD.ID = Convert.ToUInt16(DR["GuildID"]);
GD.Name = Convert.ToString(DR["Name"]);
GD.Bulletin = Convert.ToString(DR["Bulletin"]);
GD.Fund = Convert.ToInt32(DR["Fund"]);
member Gl = new member();
string tmp = Convert.ToString(DR["Leader"]);
string[] ld = tmp.Split(':');
Gl.ID = int.Parse(ld[0]); Gl.Name = ld[1];
Gl.lvl = ChLvl[Gl.ID];
GD.Leader = Gl;
GD.MembersCount = 1;
tmp = Convert.ToString(DR["Members"]);
if (tmp != "")
{
string[] mbs = tmp.Split('~');
foreach (string mbr in mbs)
{
member m = new member();
string[] mb = mbr.Split(':');
m.ID = int.Parse(mb[0]);
m.Name = mb[1];
if (mb[2] == "t")
m.isDL = true;
m.lvl = ChLvl[m.ID];
GD.Members.Add(m.ID, m);
GD.MembersCount++;
}
}
if (!Nano.Guilds.ContainsKey(GD.ID))
{
Nano.Guilds.Add(GD.ID, GD);
}
}
Console.WriteLine("[GameServer] Loaded " + Nano.Guilds.Count + " guilds from the DB.");
DR.Close();
Cmd.Dispose();
DR2.Close();
Cmd2.Dispose();
}
public static void NewGuild(Guild GD,Character Creator)
{
MySqlCommand Cmd = new MySqlCommand("INSERT INTO guilds(GuildID, Name, Bulletin, Fund, Leader) VALUES(" + GD.ID + ",'" + GD.Name + "','" + GD.Bulletin + "', 1000000,'" + GD.Leader.ID+":"+GD.Leader.Name + "')", DatabaseConnection.NewConnection());
Cmd.ExecuteNonQuery();
Cmd.Connection.Close();
Cmd.Connection.Dispose();
Cmd.Dispose();
Cmd = new MySqlCommand("UPDATE `characters` SET `GDonation` = " + Creator.donation + ", `Guild` = " + GD.ID + ", `GRank` = 100 WHERE `CharID` = " + Creator.ID , DatabaseConnection.NewConnection());
Cmd.ExecuteNonQuery();
Cmd.Connection.Close();
Cmd.Connection.Dispose();
Cmd.Dispose();
}
public static void UpdateGuild(Guild GD)
{
MySqlCommand Cmd;
string packmemb = "";
bool first = true;
foreach (KeyValuePair<int, member> m in GD.Members)
{
int rank = 50;
string rank2="f";
if (m.Value.isDL){
rank = 90;
rank2="t";
}
Cmd = new MySqlCommand("UPDATE `characters` SET `GDonation` = " + m.Value.Donation + ", `Guild` = " + GD.ID + ", `GRank` = "+rank+" WHERE `CharID` = " + m.Value.ID, DatabaseConnection.NewConnection());
Cmd.ExecuteNonQuery();
Cmd.Connection.Close();
Cmd.Connection.Dispose();
Cmd.Dispose();
if (first)
{
packmemb = m.Value.ID + ":" + m.Value.Name + ":" + rank2;
first = false;
}
else
packmemb += "~" + m.Value.ID + ":" + m.Value.Name + ":" + rank2;
}
Cmd = new MySqlCommand("UPDATE `characters` SET `GDonation` = " + GD.Leader.Donation + ", `Guild` = " + GD.ID + ", `GRank` = 100 WHERE `CharID` = " + GD.Leader.ID, DatabaseConnection.NewConnection());
Cmd.ExecuteNonQuery();
Cmd.Connection.Close();
Cmd.Connection.Dispose();
Cmd.Dispose();
Cmd = new MySqlCommand("UPDATE `guilds` SET `Bulletin` = '" + GD.Bulletin + "', `Fund` = " + GD.Fund + ", `Members` = '" + packmemb + "', `Leader` = '" + GD.Leader.ID + ":" + GD.Leader.Name + "' WHERE `GuildID` = " + GD.ID, DatabaseConnection.NewConnection());
Cmd.ExecuteNonQuery();
Cmd.Connection.Close();
Cmd.Connection.Dispose();
Cmd.Dispose();
}
public static void DeleteGuild(int ID)
{
MySqlCommand Cmd = new MySqlCommand("DELETE FROM `guilds` Where `GuildID` = " + ID, DatabaseConnection.NewConnection());
Cmd.ExecuteNonQuery();
Cmd.Connection.Close();
Cmd.Connection.Dispose();
Cmd.Dispose();
Cmd = new MySqlCommand("UPDATE `characters` SET `GDonation` = 0, `Guild` = 0, `GRank` = 50 WHERE `CharID` = " + Nano.Guilds[ID].Leader.ID, DatabaseConnection.NewConnection());
Cmd.ExecuteNonQuery();
Cmd.Connection.Close();
Cmd.Connection.Dispose();
Cmd.Dispose();
}
Code:
Packet.Short(0); //TODO: Guilds Packet.Int(0); //Unknown Packet.Int(0); //GuildRank
Code:
Packet.Short(CSocket.Client.gid); //TODO: Guilds Packet.Int(0); //Unknown Packet.Int(CSocket.Client.gpo); //GuildRank
Code:
Database.Database.LoadGuilds();
Code:
public static void NpcTalk(ClientSocket CSocket, int ID, int LinkBack)
Code:
public static void NpcTalk(ClientSocket CSocket, int ID, int LinkBack,byte[] data)
Code:
using CoEmu_v2_GameServer.Calculations;
Code:
using CoEmu_v2_GameServer.Entities;
Code:
case 10003: // Guild Controler
{
if (LinkBack == 0)
{
Text("I am in charge of all the guilds in TwinCity, You may consult me for anything related to the guilds.", CSocket);
Link("Create a Guild.", 1, CSocket);
Link("Deputize.", 2, CSocket);
Link("Remove from Office.", 7, CSocket);
Link("Disband.", 3, CSocket);
Link("No, thanks.", 255, CSocket);
End(CSocket);
}
else if (LinkBack == 1)
{
if (!CSocket.Client.InGuild)
{
Text("It will cost you 1,000,000 silvers, and you need to be level 95 at least.", CSocket);
Input(4, CSocket);
Link("No, thanks.", 255, CSocket);
End(CSocket);
}
else
{
Text("Sorry. You in a Guild.", CSocket);
Link("Ahhh.", 255, CSocket);
End(CSocket);
}
}
else if (LinkBack == 2)
{
if (CSocket.Client.gpo == 100)
{
int dlcount = 0;
foreach (KeyValuePair<int, member> m in Nano.Guilds[CSocket.Client.gid].Members)
if (m.Value.isDL)
dlcount++;
if (dlcount < 6)
{
Text("Enter the name of your guildmate you want to deputize.", CSocket);
Input(5, CSocket);
Link("No, thanks.", 255, CSocket);
End(CSocket);
}
else
{
Text("Sorry. Your guild already have 6 DLs", CSocket);
Link("Ahhh.", 255, CSocket);
End(CSocket);
}
}
else
{
Text("Sorry. Only GuildLeader can promote members.", CSocket);
Link("Ahhh.", 255, CSocket);
End(CSocket);
}
}
else if (LinkBack == 3)
{
if (CSocket.Client.gpo == 100)
{
if (Nano.Guilds[CSocket.Client.gid].Members.Count == 0)
{
Text("Are you sure you want to disband your guild?", CSocket);
Link("Yes.", 6, CSocket);
Link("No, actually.", 255, CSocket);
End(CSocket);
}
else
{
Text("You Cant Disband your guild until you have members in.", CSocket);
Link("OK.", 255, CSocket);
End(CSocket);
}
}
else
{
Text("Only guild leader can disband his/her guild.", CSocket);
Link("Ok.", 255, CSocket);
End(CSocket);
}
}
else if (LinkBack == 4)
{
if (!CSocket.Client.InGuild)
{
if (CSocket.Client.Money >= 1000000)
{
if (CSocket.Client.Level >= 95)
{
string str = "";
for (int i = 14; i < 14 + data[13]; i++)
{
str += Convert.ToChar(data[i]);
}
bool chk = true;
foreach (KeyValuePair<int, Guild> gd in Nano.Guilds)
{
if (gd.Value.Name == str)
chk = false;
}
if (chk)
{
int ngid;
do
{
ngid = Nano.Rand.Next(100, 33333);
} while (Nano.Guilds.ContainsKey(ngid));
Money(-1000000, CSocket);
Guild GD = new Guild();
GD.Bulletin = "Enter Bulletin Here";
GD.Fund = 1000000;
GD.ID = (ushort)ngid;
GD.Leader = new member();
GD.Leader.ID = CSocket.Client.ID;
GD.Leader.lvl = CSocket.Client.Level;
GD.Leader.Name = CSocket.Client.Name;
GD.Name = str;
GD.MembersCount++;
Nano.Guilds.Add(ngid, GD);
CSocket.Client.gid = GD.ID;
CSocket.Client.gna = str;
CSocket.Client.gpo = 100;
CSocket.Client.InGuild = true;
Guild.refresh(CSocket);
foreach (KeyValuePair<int, ClientSocket> C in Nano.ClientPool)
C.Value.Send(ConquerPacket.Chat(0, "SYSTEM", "ALL", "Congratulations " + CSocket.Client.Name + " has set up " + str + " successfully!", Struct.ChatType.Talk));
Database.Database.NewGuild(GD, CSocket.Client);
}
else
Text("Guild name are taken.", CSocket);
Link("OK.", 255, CSocket);
End(CSocket);
break;
}
else
Text("You aren't high level enough.", CSocket);
Link("OK.", 255, CSocket);
End(CSocket);
break;
}
Text("You don't have enough silvers.", CSocket);
Link("OK.", 255, CSocket);
End(CSocket);
break;
}
Text("Congratulations You have set up a guild.", CSocket);
Link("OK.", 255, CSocket);
End(CSocket);
break;
}
else if (LinkBack == 5)
{
string str = "";
for (int i = 14; i < 14 + data[13]; i++)
{
str += Convert.ToChar(data[i]);
}
bool t = false;
foreach (KeyValuePair<int, member> m in Nano.Guilds[CSocket.Client.gid].Members)
if (m.Value.Name == str)
{
t = true;
m.Value.isDL = true;
if (Nano.ClientPool.ContainsKey(m.Key))
{
Nano.ClientPool[m.Value.ID].Client.gpo = 90;
Guild.refresh(Nano.ClientPool[m.Value.ID]);
Spawn.All(CSocket);
break;
}
else
{
Text("The player you want to deputize must be in your guild and online.", CSocket);
Link("OK.", 255, CSocket);
End(CSocket);
break;
}
}
if (!t)
{
Text("You do not have that member.", CSocket);
Link("OK.", 255, CSocket);
End(CSocket);
}
}
else if (LinkBack == 6)
{
foreach (KeyValuePair<int, ClientSocket> C in Nano.ClientPool)
C.Value.Send(ConquerPacket.Chat(0, "SYSTEM", "ALL", CSocket.Client.gna + " has been disbanded.", Struct.ChatType.Talk));
Database.Database.DeleteGuild(CSocket.Client.gid);
CSocket.Send(ConquerPacket.GSend(CSocket.Client.gid, 19));
CSocket.Client.gid = 0;
CSocket.Client.gna = "";
CSocket.Client.gpo = 50;
Nano.Guilds.Remove(CSocket.Client.gid);
}
else if (LinkBack == 7)
{
if (CSocket.Client.gpo == 100)
{
Text("Enter the name of your guildmate with you want remove from office.", CSocket);
Input(8, CSocket);
Link("No, thanks.", 255, CSocket);
End(CSocket);
}
else
{
Text("Sorry. Only GuildLeader can remove DLs.", CSocket);
Link("Ahhh.", 255, CSocket);
End(CSocket);
}
}
else if (LinkBack == 8)
{
string str = "";
for (int i = 14; i < 14 + data[13]; i++)
{
str += Convert.ToChar(data[i]);
}
bool t = false;
foreach (KeyValuePair<int, member> m in Nano.Guilds[CSocket.Client.gid].Members)
if (m.Value.Name == str)
{
t = true;
m.Value.isDL = false;
if (Nano.ClientPool.ContainsKey(m.Key))
{
Nano.ClientPool[m.Value.ID].Client.gpo = 50;
Guild.refresh(Nano.ClientPool[m.Value.ID]);
Spawn.All(CSocket);
break;
}
else
{
Text("The player you want to remove DL must be online.", CSocket);
Link("OK.", 255, CSocket);
End(CSocket);
break;
}
}
if (!t)
{
Text("You do not have that member.", CSocket);
Link("OK.", 255, CSocket);
End(CSocket);
}
}
break;
}
Code:
case 2031: //Initial NPC talk
Code:
case 2031: //Initial NPC talk
{
int ID = ReadLong(Data, 4);
Handler.NpcTalk(CSocket, ID, 0);
break;
}
case 2032: //Reply NPC Talk
{
int ID = CSocket.Client.LastNPC;
int LinkBack = Data[10];
if(LinkBack != 255)
Handler.NpcTalk(CSocket, ID, LinkBack);
break;
}
Code:
case 2031: //Initial NPC talk
{
int ID = ReadLong(Data, 4);
Handler.NpcTalk(CSocket, ID, 0,data);
break;
}
case 2032: //Reply NPC Talk
{
int ID = CSocket.Client.LastNPC;
int LinkBack = Data[10];
if(LinkBack != 255)
Handler.NpcTalk(CSocket, ID, LinkBack,data);
break;
}
Code:
try
{
Monitor.Enter(Nano.ClientPool);
Nano.ClientPool.Add(CSocket.Client.ID, CSocket);
Code:
foreach (KeyValuePair<int, Guild> GD in Nano.Guilds)
CSocket.Send(ConquerPacket.GName(GD.Value.ID, GD.Value.Name));
Guild.refresh(CSocket);
Spawn.MeTo(CSocket);
Code:
ALTER TABLE `guilds` CHANGE `Members` `Members` TEXT CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL ALTER TABLE `guilds` CHANGE `Leader` `Leader` VARCHAR( 26 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL