Thanks for the Information, But It's kinda I am noob in C# :) I only know basic. hehe
Code:
const int TargetLimit = 30;
public byte[] ToArray()
{
if (Targets.Count <= TargetLimit)
{
byte[] buffer = new byte[61 + Targets.Count * 32];
Writer.WriteUInt16((ushort)(buffer.Length - 8), 0, buffer);
Writer.WriteUInt16(1105, 2, buffer);
Writer.WriteUInt32(Attacker, 4, buffer);
Writer.WriteUInt16(X, 8, buffer);
Writer.WriteUInt16(Y, 10, buffer);
Writer.WriteUInt16(SpellID, 12, buffer);
Writer.WriteUInt16(SpellLevel, 14, buffer);
Writer.WriteUInt32((uint)Targets.Count, 17, buffer);
ushort offset = 20;
foreach (KeyValuePair<uint, DamageClass> target in Targets.Base)
{
Writer.WriteUInt32(target.Key, offset, buffer); offset += 4;
Writer.WriteUInt32(target.Value.Damage, offset, buffer); offset += 4;
Writer.WriteBoolean(target.Value.Hit, offset, buffer); offset += 4;
offset += 6;
Writer.WriteUInt32(target.Value.newX, offset, buffer); offset += 4;
Writer.WriteUInt32(target.Value.newY, offset, buffer); offset += 8;
}
return buffer;
}
else
{
using (MemoryStream stream = new MemoryStream())
using (BinaryWriter writer = new BinaryWriter(stream))
{
var array = [COLOR="Red"]Targets.ToArray();[/COLOR]
for (int i = 0; i < array.Length; i += TargetLimit)
{
int targets = array.Length - i;
if (targets > TargetLimit) targets = TargetLimit;
byte[] buffer = new byte[61 + targets * 32];
Writer.WriteUInt16((ushort)(buffer.Length - 8), 0, buffer);
Writer.WriteUInt16(1105, 2, buffer);
Writer.WriteUInt32(Attacker, 4, buffer);
Writer.WriteUInt16(X, 8, buffer);
Writer.WriteUInt16(Y, 10, buffer);
Writer.WriteUInt16(SpellID, 12, buffer);
Writer.WriteUInt16(SpellLevel, 14, buffer);
if (Kernel.GamePool.ContainsKey(Attacker))
if (Kernel.GamePool[Attacker].Spells != null)
if (Kernel.GamePool[Attacker].Spells[SpellID] != null)
Writer.WriteUInt32((uint)(targets/* << 8*/), 17, buffer);
ushort offset = 20;
for (int j = 0; j < targets; j++)
{
KeyValuePair<uint, DamageClass> target = [COLOR="Red"]array[i + j][/COLOR];
Writer.WriteUInt32(target.Key, offset, buffer); offset += 4;
Writer.WriteUInt32(target.Value.Damage, offset, buffer); offset += 4;
Writer.WriteBoolean(target.Value.Hit, offset, buffer); offset += 4;
offset += 6;
offset += 6;
Writer.WriteUInt32(target.Value.newX, offset, buffer); offset += 4;
Writer.WriteUInt32(target.Value.newY, offset, buffer); offset += 8;
}
Writer.WriteString("TQServer", buffer.Length - 8, buffer);
writer.Write(buffer, 0, buffer.Length);
}
return stream.ToArray();
}
}
}
I am workin now, and I've got this error . Please help me please :) Im stuck with this part
Error in this part:
1. =
var array = Targets.ToArray();
2. =
KeyValuePair<uint, DamageClass> target = array[i + j];
Here is the ScreenShot error
[Only registered and activated users can see links. Click Here To Register...]