本文整理汇总了C#中PacketReader.Close方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.Close方法的具体用法?C# PacketReader.Close怎么用?C# PacketReader.Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketReader
的用法示例。
在下文中一共展示了PacketReader.Close方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPacketToSend
KeyValuePair<TransferBuffer, Packet> GetPacketToSend()
{
if (m_outgoing_packets.Count == 0)
{
throw (new Exception("[SecurityAPI::GetPacketToSend] No packets are avaliable to send."));
}
Packet packet = m_outgoing_packets[0];
m_outgoing_packets.RemoveAt(0);
if (packet.Massive)
{
PacketWriter final = null;
PacketWriter final_data = null;
byte[] raw_bytes = null;
PacketReader input_reader = null;
PacketWriter final_header = null;
try
{
ushort parts = 0;
final = new PacketWriter();
final_data = new PacketWriter();
byte[] input_data = packet.GetBytes();
input_reader = new PacketReader(input_data);
TransferBuffer workspace = new TransferBuffer(4089, 0, (int)input_data.Length);
while (workspace.Size > 0)
{
PacketWriter part_data = null;
try
{
part_data = new PacketWriter();
int cur_size = workspace.Size > 4089 ? 4089 : workspace.Size; // Max buffer size is 4kb for the client
part_data.Write((byte)0); // Data flag
part_data.Write(input_data, workspace.Offset, cur_size);
workspace.Offset += cur_size;
workspace.Size -= cur_size; // Update the size
final_data.Write(FormatPacket(0x600D, part_data.GetBytes(), false));
++parts; // Track how many parts there are
}
finally
{
if (part_data != null)
{
part_data.Close();
}
}
}
// Write the final header packet to the front of the packet
final_header = new PacketWriter();
final_header.Write((byte)1); // Header flag
final_header.Write((short)parts);
final_header.Write(packet.Opcode);
final.Write(FormatPacket(0x600D, final_header.GetBytes(), false));
// Finish the large packet of all the data
final.Write(final_data.GetBytes());
// Return the collated data
raw_bytes = final.GetBytes();
}
finally
{
if (final != null)
{
final.Close();
}
if (final_data != null)
{
final_data.Close();
}
if (input_reader != null)
{
input_reader.Close();
}
if (final_header != null)
{
final_header.Close();
}
}
packet.Lock();
return new KeyValuePair<TransferBuffer, Packet>(new TransferBuffer(raw_bytes, 0, raw_bytes.Length, true), packet);
}
else
{
//.........这里部分代码省略.........
示例2: client_Received
void client_Received(object sender, xDataReceivedEventArgs e)
{
ChatClient client = sender as ChatClient;
PacketReader r = new PacketReader(e.Data, false);
switch (e.Header)
{
case ChatClient.Header.USERNAME:
online++;
Invoke((MethodInvoker)delegate
{
lstUsers.Columns[0].Text = "Online (" + online.ToString() + ")";
string _username = r.ReadString();
lstUsers.Items.Add(_username);
if (blocked.Contains(_username))
lstUsers.Items[lstUsers.Items.Count - 1].ForeColor = Color.Red;
lstUsers.Sort();
WriteToChat(_username + ": Connected", Color.Green);
if (connectToolStripMenuItem.Checked)
{
GlobalProperties.SoundPlayer.Stream = Properties.Resources.beep_1;
GlobalProperties.SoundPlayer.Play();
}
});
break;
case ChatClient.Header.USERS:
List<string> usernames = new List<string>();
int len = r.ReadInt32();
for (int i = 0; i < len; i++)
{
usernames.Add(r.ReadString());
}
usernames.Sort();
Invoke((MethodInvoker)delegate
{
lstUsers.Items.Clear();
});
foreach (string name in usernames)
{
Invoke((MethodInvoker)delegate
{
lstUsers.Items.Add(name);
if (blocked.Contains(name))
lstUsers.Items[lstUsers.Items.Count - 1].ForeColor = Color.Red;
});
}
online = usernames.Count;
Invoke((MethodInvoker)delegate
{
lstUsers.Columns[0].Text = "Online (" + online.ToString() + ")";
});
break;
case ChatClient.Header.MESSAGE:
string username = r.ReadString();
string message = r.ReadString();
int bLen = r.ReadInt32();
for (int i = 0; i < bLen; i++)
{
if (GlobalProperties.Client.Username == r.ReadString())
{
r.Close();
return;
}
}
if (blocked.Contains(username))
break;
if (soundOnSentReceivedToolStripMenuItem.Checked)
{
GlobalProperties.SoundPlayer.Stream = Properties.Resources.IM08;
GlobalProperties.SoundPlayer.Play();
}
StringBuilder sb = new StringBuilder();
sb.Append(username + ": " + message);
Invoke((MethodInvoker)delegate
{
WriteToChat(sb.ToString(), Color.Black);
});
break;
case ChatClient.Header.LEFT:
string leftName = r.ReadString();
online--;
for (int i = 0; i < lstUsers.Items.Count; i++)
{
Invoke((MethodInvoker)delegate
{
if (lstUsers.Items[i].Text == leftName)
{
lstUsers.Items.RemoveAt(i);
lstUsers.Columns[0].Text = "Online (" + online.ToString() + ")";
r.Close();
WriteToChat(leftName + ": Disconnected", Color.Red);
if (disconnectToolStripMenuItem.Checked)
{
GlobalProperties.SoundPlayer.Stream = Properties.Resources.boing_2;
GlobalProperties.SoundPlayer.Play();
//.........这里部分代码省略.........
示例3: Recv
//.........这里部分代码省略.........
}
if (packet_encrypted || (m_security_flags.security_bytes == 1 && m_security_flags.blowfish == 0))
{
if (packet_encrypted || m_enc_opcodes.Contains(packet_opcode))
{
packet_size |= 0x8000;
Buffer.BlockCopy(BitConverter.GetBytes((ushort)packet_size), 0, buffer.Buffer, 0, 2);
}
}
buffer.Buffer[5] = 0;
byte expected_crc = GenerateCheckByte(buffer.Buffer);
if (packet_security_crc != expected_crc)
{
throw (new Exception("[SecurityAPI::Recv] CRC byte mismatch."));
}
buffer.Buffer[4] = 0;
if (packet_encrypted || (m_security_flags.security_bytes == 1 && m_security_flags.blowfish == 0))
{
if (packet_encrypted || m_enc_opcodes.Contains(packet_opcode))
{
packet_size &= 0x7FFF;
Buffer.BlockCopy(BitConverter.GetBytes((ushort)packet_size), 0, buffer.Buffer, 0, 2);
}
}
}
}
if (packet_opcode == 0x5000 || packet_opcode == 0x9000) // New logic processing!
{
Handshake(packet_opcode, packet_data, packet_encrypted);
// Pass the handshake packets to the user so they can at least see them.
// They do not need to actually do anything with them. This was added to
// help debugging and make output logs complete.
//CA2000 dont care
Packet packet = new Packet(packet_opcode, packet_encrypted, false, buffer.Buffer, 6, packet_size);
packet.Lock();
m_incoming_packets.Add(packet);
}
else
{
if (m_client_security)
{
// Make sure the client accepted the security system first
if (!m_accepted_handshake)
{
throw (new Exception("[SecurityAPI::Recv] The client has not accepted the handshake."));
}
}
if (packet_opcode == 0x600D) // Auto process massive messages for the user
{
byte mode = packet_data.ReadByte();
if (mode == 1)
{
m_massive_count = packet_data.ReadUInt16();
ushort contained_packet_opcode = packet_data.ReadUInt16();
m_massive_packet = new Packet(contained_packet_opcode, packet_encrypted, true);
}
else
{
if (m_massive_packet == null)
{
throw (new Exception("[SecurityAPI::Recv] A malformed 0x600D packet was received."));
}
m_massive_packet.WriteUInt8Array(packet_data.ReadBytes(packet_size - 1));
m_massive_count--;
if (m_massive_count == 0)
{
m_massive_packet.Lock();
m_incoming_packets.Add(m_massive_packet);
m_massive_packet = null;
}
}
}
else
{
//CA2000 dont care
Packet packet = new Packet(packet_opcode, packet_encrypted, false, buffer.Buffer, 6, packet_size);
packet.Lock();
m_incoming_packets.Add(packet);
}
}
}
finally
{
if (packet_data != null)
{
packet_data.Close();
}
}
}
}
}
}
示例4: GuildTitle
void GuildTitle()
{
//Wrap our function inside a catcher
try
{
//Extra hack check
if (Character.Network.Guild.Level < 4) return;
//Open our packet reader
PacketReader Reader = new PacketReader(PacketInformation.buffer);
int Selecteduser = Reader.Int32();
short TitleL = Reader.Int16();
string Title = Reader.String(TitleL);
Reader.Close();
//Get character information
Systems playerinfo = GetPlayerMainid(Selecteduser);
//Make sure the user is still there
if (playerinfo.Character != null)
{
//Update database set new title
DB.query("UPDATE guild_members SET guild_grant='" + Title + "' WHERE guild_member_id='" + playerinfo.Character.Information.CharacterID + "'");
//Send title update to send list
Send(Packet.GuildSetTitle(Character.Guild.GuildID, playerinfo.Character.Information.Name, Title));
//Send Final packet to client
client.Send(Packet.GuildSetTitle2(Character.Guild.GuildID, Selecteduser, Title));
}
foreach (int member in Character.Network.Guild.Members)
{
if (member != 0)
{
Systems getplayer = GetPlayerMainid(member);
if (getplayer != null)
{
getplayer.LoadPlayerGuildInfo(false);
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("Guild Title Error: {0}", ex);
Log.Exception(ex);
}
}
示例5: GuildTransferLeaderShip
void GuildTransferLeaderShip()
{
try
{
//Read packet data
PacketReader Reader = new PacketReader(PacketInformation.buffer);
int Guildid = Reader.Int32();
int Memberid = Reader.Int32();
Reader.Close();
//Grab the information of the player
Systems sys = GetPlayerid(Memberid);
//Update database
DB.query("UPDATE guild_members SET guild_rank='10',guild_perm_join='0',guild_perm_withdraw='0',guild_perm_union='0',guild_perm_storage='0',guild_perm_notice='0' WHERE guild_member_id='" + Character.Information.CharacterID + "'");
DB.query("UPDATE guild_members SET guild_rank='0',guild_perm_join='1',guild_perm_withdraw='1',guild_perm_union='1',guild_perm_storage='1',guild_perm_notice='1' WHERE guild_member_id='" + Memberid + "'");
//Send required packets to network
foreach (int member in Character.Network.Guild.Members)
{
//Make sure member s not null
if (member != 0)
{
//Get information for the guildmember
Systems guildmember = GetPlayerMainid(member);
//Make sure the guildmember isnt null
if (guildmember != null)
{
//Bool check single send packet
if (!guildmember.Character.Network.Guild.SingleSend)
{
//Send update packet
guildmember.client.Send(Packet.GuildUpdate(Character, 3, Memberid, 0 , 0));
guildmember.LoadPlayerGuildInfo(false);
}
}
}
}
//Disable bool
foreach (int member in Character.Network.Guild.Members)
{
if (member != 0)
{
Systems guildmember = GetPlayerMainid(member);
if (guildmember != null)
{
guildmember.Character.Network.Guild.SingleSend = false;
}
}
}
//Send message to old owner
client.Send(Packet.GuildTransferMessage());
}
catch (Exception ex)
{
Console.WriteLine("Guild Transfer Error: {0}", ex);
Log.Exception(ex);
}
}
示例6: GuildPromote
void GuildPromote()
{
try
{
//Read client information int32 id
PacketReader reader = new PacketReader(PacketInformation.buffer);
int guildid = reader.Int32();
reader.Close();
//Incase of hacking attempt :)
if (Character.Network.Guild.Level == 5) return;
//Define int's to use
int goldneeded;
int guildpoints;
bool promoting = false;
if (!promoting)
{
LoadPlayerGuildInfo(false);
promoting = true;
switch (Character.Network.Guild.Level)
{
case 1:
goldneeded = 3000000;
guildpoints = 5400;
break;
case 2:
goldneeded = 9000000;
guildpoints = 50400;
break;
case 3:
goldneeded = 15000000;
guildpoints = 135000;
break;
case 4:
goldneeded = 21000000;
guildpoints = 378000;
break;
default:
return;
}
int changelevel = Character.Network.Guild.Level + 1;
int storageslots = Character.Network.Guild.StorageSlots + 30;
if (Character.Information.Gold < goldneeded)
{
client.Send(Packet.ErrorMsg(SERVER_GUILD_PROMOTE_MSG, ErrorMsg.UIIT_MSG_ERROR_GUILD_LEVEL_UP_GOLD_DEFICIT));
return;
}
//Not enough guildpoints
if (Character.Network.Guild.PointsTotal < guildpoints)
{
client.Send(Packet.ErrorMsg(SERVER_GUILD_PROMOTE_MSG, ErrorMsg.UIIT_MSG_ERROR_GUILD_LEVEL_UP_GP_DEFICIT));
}
//Max level
if (Character.Network.Guild.Level == 5)
{
client.Send(Packet.ErrorMsg(SERVER_GUILD_PROMOTE_MSG, ErrorMsg.UIIT_MSG_ERROR_GUILD_LEVEL_UP_FULL));
return;
}
else
//Upgrade guild initiate
{
//If max level return just incase.
if (Character.Network.Guild.Level == 5) return;
//Reduct guildpoints
Character.Network.Guild.PointsTotal -= guildpoints;
//If the upgrade is final upgrade set points to 0
if (Character.Network.Guild.Level == 4) Character.Network.Guild.PointsTotal = 0;
//Reduct gold
Character.Information.Gold -= goldneeded;
client.Send(Packet.InfoUpdate(1, Character.Network.Guild.PointsTotal, 0));
client.Send(Packet.GuildPromoteMsgS());
//Update guild in database
DB.query("UPDATE guild SET guild_level='" + changelevel + "',guild_points='" + Character.Network.Guild.PointsTotal + "',guild_storage_slots='" + storageslots + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");
//Send Guild Packets
foreach (int member in Character.Network.Guild.Members)
{
if (member != 0)
{
Systems memberinfo = GetPlayerMainid(member);
if (memberinfo != null)
{
memberinfo.LoadPlayerGuildInfo(false);
memberinfo.client.Send(Packet.GuildUpdate(Character, 5, 0, 0, 0));
}
}
}
// save
SaveGold();
client.Send(Packet.UpdateGold(Character.Information.Gold));
}
}
promoting = false;
}
catch (Exception ex)
{
Console.WriteLine("Guild Promote Error: {0}", ex);
//.........这里部分代码省略.........
示例7: GuildRemove
void GuildRemove()
{
//Wrap our function inside a catcher
try
{
//Open our packet reader
PacketReader Reader = new PacketReader(PacketInformation.buffer);
short UserL = Reader.Int16();
string User = Reader.String(UserL);
Reader.Close();
//Define new count for database check
//Get player information
Systems sys = GetPlayerName(User);
//Send required packets to network
foreach (int member in Character.Network.Guild.Members)
{
//Make sure member s not null
if (member != 0)
{
//Get information for the guildmember
Systems guildmember = GetPlayerMainid(member);
//Make sure the guildmember isnt null
if (guildmember != null)
{
//Make sure the kicked member does not receive the packet
if (guildmember.Character.Information.CharacterID != sys.Character.Information.CharacterID)
{
//Bool check single send packet
if (!guildmember.Character.Network.Guild.SingleSend)
{
//Send update packet
guildmember.client.Send(Packet.GuildUpdate(sys.Character, 7, 0, 0, 0));
guildmember.Character.Network.Guild.SingleSend = true;
}
}
}
}
}
//Send update packet to the kicked player
sys.client.Send(Packet.GuildUpdate(sys.Character, 7, 0, 0, 0));
sys.client.Send(Packet.GuildKickMsg());
sys.Send(Packet.GuildKick(sys.Character.Information.UniqueID));
//Minus 1 count for new database info
int getmembercount = Convert.ToInt32(DB.GetData("SELECT guild_members_t FROM guild WHERE guild_name='" + Character.Network.Guild.Name + "'", "guild_members_t"));
int newmembercount = getmembercount - 1;
//Update database
DB.query("UPDATE guild SET guild_members_t='" + newmembercount + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");
//Remove the player from database
DB.query("DELETE from guild_members where guild_member_id='" + sys.Character.Information.CharacterID + "'");
//Disable bool
foreach (int member in Character.Network.Guild.Members)
{
if (member != 0)
{
Systems guildmember = GetPlayerMainid(member);
if (guildmember != null)
{
guildmember.LoadPlayerGuildInfo(false);
guildmember.Character.Network.Guild.SingleSend = false;
}
}
}
//Final updates
if (Character.Network.Guild.UniqueUnion != 0)
{
Character.Network.Guild.UnionActive = false;
Character.Network.Guild.UnionMembers.Remove(Character.Information.CharacterID);
}
Character.Network.Guild.Members.Remove(sys.Character.Information.UniqueID);
Character.Network.Guild.MembersClient.Remove(sys.client);
sys.Character.Network.Guild.Guildid = 0;
}
catch (Exception ex)
{
Console.WriteLine("Guild Kick Error: {0}", ex);
Log.Exception(ex);
}
}
示例8: GuildMessage
void GuildMessage()
{
//Wrap our function inside a catcher
try
{
//Start reading packet data
PacketReader Reader = new PacketReader(PacketInformation.buffer);
short TitleL = Reader.Int16();
string Title = Reader.String(TitleL);
short MessageL = Reader.Int16();
string Message = Reader.String(MessageL);
Reader.Close();
//Update database guild message title
DB.query("UPDATE guild SET guild_news_t='" + Title + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");
//Update database guild message
DB.query("UPDATE guild SET guild_news_m='" + Message + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");
//Set new message info to current member for sending packet update.
Character.Network.Guild.NewsTitle = Title;
Character.Network.Guild.NewsMessage = Message;
//Send news update to all members currently online
Character.Network.Guild.Send(Packet.GuildUpdate(Character, 11, 0, 0, 0));
}
catch (Exception ex)
{
Console.WriteLine("Guild Message Error: {0}", ex);
Log.Exception(ex);
}
}
示例9: GuildPermissions
/////////////////////////////////////////////////////////////////////////
//Guild Permissions
/////////////////////////////////////////////////////////////////////////
void GuildPermissions()
{
try
{
PacketReader Reader = new PacketReader(PacketInformation.buffer);
Reader.Byte();
int memberid = Reader.Int32();
byte permissions = (byte)Reader.Int32();
char[] bits = new char[8];
for (int i = 0; i < 8; ++i) bits[i] = (char)0;
bits = Convert.ToString(permissions, 2).ToCharArray();
Reader.Close();
// set the amount to the target player :)
int targetindex = Character.Network.Guild.MembersInfo.FindIndex(i => i.MemberID == memberid);
if (Character.Network.Guild.MembersInfo[targetindex].Online)
{
Systems member = GetPlayerMainid(memberid);
// so here we can set chars right
member.Character.Network.Guild.joinRight = bits[4] == '1' ? true : false;
member.Character.Network.Guild.withdrawRight = bits[3] == '1' ? true : false;
member.Character.Network.Guild.unionRight = bits[2] == '1' ? true : false;
member.Character.Network.Guild.guildstorageRight = bits[0] == '1' ? true : false;
member.Character.Network.Guild.noticeeditRight = bits[1] == '1' ? true : false;
}
// set new amount to every guild members guild class
foreach (int m in Character.Network.Guild.Members)
{
int index = Character.Network.Guild.MembersInfo.FindIndex(i => i.MemberID == m);
if (Character.Network.Guild.MembersInfo[index].Online)
{
Systems sys = Helpers.GetInformation.GetPlayerMainid(m);
// here comes the messy way
Global.guild_player mygp = new Global.guild_player();
int myindex = 0;
foreach (Global.guild_player gp in sys.Character.Network.Guild.MembersInfo)
{
if (gp.MemberID == memberid)
{
mygp = gp; //
mygp.joinRight = bits[4] == '1' ? true : false;
mygp.withdrawRight = bits[3] == '1' ? true : false;
mygp.unionRight = bits[2] == '1' ? true : false;
mygp.guildstorageRight = bits[0] == '1' ? true : false;
mygp.noticeeditRight = bits[1] == '1' ? true : false;
break;
}
myindex++;
}
sys.Character.Network.Guild.MembersInfo[myindex] = mygp;
}
}
DB.query("UPDATE guild_members SET guild_perm_join='" + bits[4] + "',guild_perm_withdraw='" + bits[3] + "',guild_perm_union='" + bits[2] + "',guild_perm_storage='" + bits[0] + "',guild_perm_notice='" + bits[1] + "' WHERE guild_member_id='" + memberid + "'");
Character.Network.Guild.Send(Packet.GuildUpdate(Character, 4, 0, permissions, 0));
}
catch (Exception ex)
{
Console.WriteLine("Guild permission error: {0}", ex);
Log.Exception(ex);
}
}
示例10: GuildInvite
void GuildInvite()
{
//Wrap our code into a catcher
try
{
//Open our packet reader
PacketReader Reader = new PacketReader(PacketInformation.buffer);
Int16 dLen = Reader.Int16();
string invitename = Reader.String(dLen);
Reader.Close();
//Get information for target
Systems sys = GetPlayerName(invitename);
//Set targetid information
Character.Network.TargetID = sys.Character.Information.UniqueID;
//If player allready has a guild
if (sys.Character.Network.Guild.Guildid != 0)
{
//Add message here
return;
}
//Set targetid to the invited player
sys.Character.Network.TargetID = Character.Information.UniqueID;
//Send guild request packet
sys.client.Send(Packet.P_Request(5, Character.Information.UniqueID, 0));
//Set bools active
Character.State.GuildInvite = true;
sys.Character.State.GuildInvite = true;
}
catch (Exception ex)
{
Console.WriteLine("Guild invite error {0}", ex);
Log.Exception(ex);
}
}
示例11: GuildCreate
void GuildCreate()
{
try
{
//Extra check if user is allready in guild.
if (Character.Network.Guild.Guildid != 0) return;
//Read client packet ObjData.Manager.
PacketReader Reader = new PacketReader(PacketInformation.buffer);
int infoid = Reader.Int32();
short guildname = Reader.Int16();
string guildnameinfo = Reader.String(guildname);
string charactername = Character.Information.Name;
Reader.Close();
//Will write global class for special chars later.
if (guildnameinfo.Contains("[")) return;
if (guildnameinfo.Contains("]")) return;
if (guildnameinfo.Contains("(")) return;
if (guildnameinfo.Contains(")")) return;
if (guildnameinfo.Contains("@")) return;
if (guildnameinfo.Contains("#")) return;
if (guildnameinfo.Contains("$")) return;
if (guildnameinfo.Contains("^")) return;
if (guildnameinfo.Contains("&")) return;
if (guildnameinfo.Contains("*")) return;
if (guildnameinfo.Contains("+")) return;
if (guildnameinfo.Contains("=")) return;
if (guildnameinfo.Contains("~")) return;
if (guildnameinfo.Contains("`")) return;
//Check length lower are 4 return
if (guildnameinfo.Length < 4) return;
//Check if guild name is taken or not.
int guildcheckname = DB.GetRowsCount("SELECT * FROM guild WHERE guild_name='" + guildnameinfo + "'");
//If name excists
if (guildcheckname == 1)
{
//Need to sniff packet
return;
}
//Set the gold requirements 500.000 retail info
int goldrequired = 500000;
//If character level is to low
if (Character.Information.Level < 20)
{
client.Send(Packet.GuildCreateLow());
return;
}
//If gold is lower then price of creating a guild
else if (Character.Information.Gold < goldrequired)
{
client.Send(Packet.ErrorMsg(SERVER_GUILD, ErrorMsg.UIIT_MSG_GUILDERR_NOT_ENOUGH_GOLD));
return;
}
//All checks ok, continue creating new guild.
else
{
//Reduct the gold required from player gold
Character.Information.Gold -= goldrequired;
//Save player information
SavePlayerInfo();
//Insert guild into database
DB.query("INSERT INTO guild (guild_name, guild_level, guild_points, guild_news_t, guild_news_m, guild_members_t, guild_master_id) VALUES ('" + guildnameinfo + "','1','0','" + "" + "','" + "" + "','1','" + Character.Information.CharacterID + "')");
//Get guild id
string guildid = DB.GetData("SELECT id FROM guild WHERE guild_name='" + guildnameinfo + "'", "id");
int docount = Convert.ToInt32(guildid);
//Insert member into database
DB.query("INSERT INTO guild_members (guild_id, guild_member_id, guild_rank, guild_points, guild_fortress, guild_grant, guild_perm_join, guild_perm_withdraw, guild_perm_union, guild_perm_storage, guild_perm_notice) VALUES ('" + docount + "','" + Character.Information.CharacterID + "','0','0','1','','1','1','1','1','1')");
//Load our new guild
LoadPlayerGuildInfo(false);
//Private packet
client.Send(Packet.Guild_Create(Character.Network.Guild));
//Public spawn packet
Send(Packet.SendGuildInfo2(Character));
}
}
catch (Exception ex)
{
Log.Exception(ex);
}
}
示例12: DonateGP
void DonateGP()
{
//First we write our function inside a catcher
try
{
//Max level of guild wont allow new gp donations.
if (Character.Network.Guild.Level == 5)
{
client.Send(Packet.ErrorMsg(SERVER_GUILD_PROMOTE_MSG, ErrorMsg.UIIT_MSG_GUILD_LACK_GP));
return;
}
//Open our packet reader
PacketReader reader = new PacketReader(PacketInformation.buffer);
int donatedgp = reader.Int32();
reader.Close();
//Anti hack checking (If donated gp higher is then the player skillpoints.
if (donatedgp > Character.Information.SkillPoint) return;
//Calculate total
int totalgp = Character.Network.Guild.PointsTotal + donatedgp;
//First we write our base information to use
Character.Network.Guild.PointsTotal += donatedgp;
Character.Information.SkillPoint -= donatedgp;
//Save our information (Skill points).
SavePlayerInfo();
//Update database information
DB.query("UPDATE guild SET guild_points='" + totalgp + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");
//Update packets for each member in the guild
//Send packets to donator.
client.Send(Packet.InfoUpdate(1, totalgp, 0));
client.Send(Packet.GuildDonateGP(donatedgp));
foreach (int member in Character.Network.Guild.Members)
{
//Make sure that the member isnt null
if (member != 0)
{
//Now we get the detailed information for each member
Systems guildmember = GetPlayerMainid(member);
//Make sure the guildmember is still there
if (guildmember != null)
{
//Send packet only once
if (!guildmember.Character.Network.Guild.SingleSend)
{
//Set bool true so it only sends once
guildmember.Character.Network.Guild.SingleSend = true;
//Send packet data to the player
guildmember.client.Send(Packet.GuildUpdate(Character, 13, 0, 0, totalgp));
guildmember.client.Send(Packet.GuildUpdate(Character, 9, 0, 0, totalgp));
guildmember.LoadPlayerGuildInfo(false);
}
}
}
}
//Disable the bool again
foreach (int member in Character.Network.Guild.Members)
{
//Make sure member isnt null
if (member != 0)
{
//Get guildmember details
Systems guildmember = GetPlayerMainid(member);
//Make sure guildmember isnt null
if (guildmember != null)
{
//Disable bool to allow resend new packets.
guildmember.Character.Network.Guild.SingleSend = false;
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("Donate GP Error {0}", ex);
Log.Exception(ex);
}
}
示例13: HandleRegisterIcon
void HandleRegisterIcon()
{
try
{
PacketReader reader = new PacketReader(PacketInformation.buffer);
byte type = reader.Byte();
int iconlenght = reader.Int32();
string icon = reader.Text();
reader.Close();
string convertedicon = ConvertToHex(icon);
//Save output to .dat file in hex formatting.
}
catch (Exception ex)
{
Console.WriteLine("Guild icon register error {0}", ex);
}
}
示例14: GuildWarGold
/////////////////////////////////////////////////////////////////////////
//Guild War
/////////////////////////////////////////////////////////////////////////
void GuildWarGold()
{
try
{
PacketReader Reader = new PacketReader(PacketInformation.buffer);
int guildid = Reader.Int32();
Reader.Close();
if (Character.Guild.GuildWarGold == 0)
{
//Send Packet Message No War Gold Received
client.Send(Packet.GuildWarMsg(2));
}
else
{
//Sniff packet for war gold
}
}
catch (Exception ex)
{
Log.Exception(ex);
}
}