طبعا فاعل خير من غير كلام
Eslam Abdella
ومقدرتك كبيره قوى عند ناس كتير قبل اما تنزل السورس
WayOfHeroes كامله بعون الله وكله بفضل ربنا وبعدين اسلام عبدالله
هتعمل كلاس جديد وتسميه
WayofHeroes
وهتضيف ده جواه
- الكود:
using System;
using System.IO;
using System.Linq;
using Conquer_Online_Server.Client;
using Conquer_Online_Server.Database;
using System.Collections.Generic;
namespace Conquer_Online_Server.Network.GamePackets
{
public unsafe class WayofHeroes : Writer, Interfaces.IPacket
{
byte[] buffer;
int offset = 11;
public WayofHeroes(uint page)
{
buffer = new byte[11 + 8];
Writer.Ushort((ushort)(buffer.Length - 8), 0, buffer);
Writer.Ushort(2831, 2, buffer);
Page = page;
}
private uint Page
{
get { return BitConverter.ReadUint(buffer, 4); }
set { WriteUint(value, 4, buffer); }
}
private bool AllDone
{
get { return buffer[8] == 1; }
set { buffer[8] = value == true ? (byte)1 : (byte)0; }
}
private ushort Count
{
get { return BitConverter.ReadUshort(buffer, 9); }
set { Ushort(value, 9, buffer); }
}
public struct Stage
{
public uint UID;
public uint Progress;
public uint[] Prize;
}
public class StageInfo
{
public uint UID;
public bool Done;
public SafeDictionary<uint, SubStageInfo> SubStages = new SafeDictionary<uint, SubStageInfo>();
public void WriteItem(BinaryWriter writer)
{
writer.Write(UID); //= reader.ReadUInt32();
writer.Write(Done);
writer.Write((byte)SubStages.Count);
foreach (var prize in SubStages.Values)
prize.WriteItem(writer);
}
public StageInfo ReadItem(BinaryReader reader)
{
UID = reader.ReadUInt32();//4
Done = reader.ReadBoolean();//8
int count = reader.ReadByte();
for (uint x = 0; x < count; x++)
{
SubStageInfo item = new SubStageInfo();
item = item.ReadItem(reader);
SubStages.Add(item.UID, item);
}
return this;
}
}
public class SubStageInfo
{
public uint UID;
public bool Done;
public uint points;
public void WriteItem(BinaryWriter writer)
{
writer.Write(UID);
writer.Write(Done);
writer.Write(points);
}
public SubStageInfo ReadItem(BinaryReader reader)
{
UID = reader.ReadUInt32();
Done = reader.ReadBoolean();
points = reader.ReadUInt32();
return this;
}
}
public static void Load()
{
System.Console.Write("Loading StageGoal information... ");
Stages = new Dictionary<uint, Stage>();
string[] text = File.ReadAllLines("database\\stagegoal.txt");
Stage Stage = new Stage();
for (int x = 0; x < text.Length; x++)
{
System.Console.Write("\b{0}", Loading.NextChar());
string line = text[x];
string[] split = line.Split('=');
if (line.StartsWith("[") && line.EndsWith("]") && !line.Contains("StageGoal"))
{
string[] numbers = line.Replace("[", "").Replace("]", "").Split('-');
uint id = uint.Parse(numbers[0]) * 100;
if (numbers.Length > 1)
id += uint.Parse(numbers[1]);
if (Stages.ContainsKey(id))
Stage = Stages[uint.Parse(split[1])];
else
{
Stage = new Stage();
Stage.UID = id;
Stage.Prize = new uint[3];
Stages.Add(id, Stage);
}
}
else
{
if (split[0] == "Progress")
Stage.Progress = uint.Parse(split[1]);
else if (split[0] == "Prize1")
{
string[] PrizeLine = split[1].Split(new string[] { "@@" }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < PrizeLine.Length; i++)
{
Stage.Prize[i] = uint.Parse(PrizeLine[i]);
}
}
}
}
Console.WriteLine("Ok!");
}
public void check(StageInfo stages)
{
if (stages.SubStages.Count > 0)
{
byte[] bytes = new byte[11 + 8 + stages.SubStages.Count * 9];
buffer.CopyTo(bytes, 0);
WriteUInt16((ushort)(bytes.Length - 8), 0, bytes);
buffer = bytes;
Count = (ushort)stages.SubStages.Count;
AllDone = stages.Done;
var items = stages.SubStages.Values.ToArray();
for (uint i = 0; i < items.Length; i++)
{
Uint(items[i].UID, offset, buffer); offset += 8;
buffer[offset++] = items[i].Done == true ? (byte)1 : (byte)0;
}
}
}
public static void Load(GameClient client)
{
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT))
{
cmd.Select("wayofheroes").Where("UID", client.Entity.UID);
using (MySqlReader rdr = new MySqlReader(cmd))
{
if (rdr.Read())
{
byte[] data = rdr.ReadBlob("wayofheroes");
if (data.Length > 0)
{
using (var stream = new MemoryStream(data))
using (var reader = new BinaryReader(stream))
{
int count = reader.ReadByte();
for (uint x = 0; x < count; x++)
{
StageInfo item = new StageInfo();
item = item.ReadItem(reader);
client.Way2Heroes.Add(item.UID, item);
}
}
}
}
else
{
using (var command = new MySqlCommand(MySqlCommandType.INSERT))
{
command.Insert("WayofHeroes").Insert("UID", client.Entity.UID).Insert("Name", client.Entity.Name);
command.Execute();
}
}
}
}
}
public static void Save(GameClient client)
{
MemoryStream stream = new MemoryStream();
BinaryWriter writer = new BinaryWriter(stream);
writer.Write((byte)client.Way2Heroes.Count);
foreach (var prize in client.Way2Heroes.Values)
prize.WriteItem(writer);
string SQL = "UPDATE `wayofheroes` SET wayofheroes=@wayofheroes where UID = " + client.Entity.UID + " ;";
byte[] rawData = stream.ToArray();
using (var conn = DataHolder.MySqlConnection)
{
conn.Open();
using (var cmd = new MySql.Data.MySqlClient.MySqlCommand())
{
cmd.Connection = conn;
cmd.CommandText = SQL;
cmd.Parameters.AddWithValue("@wayofheroes", rawData);
cmd.ExecuteNonQuery();
}
}
}
public static Dictionary<uint, Stage> Stages;
public static void SendDone(GameClient client)
{
byte[] Buffer = new byte[106 + 8];
WriteUInt16((ushort)(Buffer.Length - 8), 0, Buffer);
WriteUInt16(2832, 2, Buffer);
Ushort(10, 4, Buffer);//count
int offset = 6;
for (uint i = 0; i < 10; i++)
{
Uint(i + 1, offset, Buffer); offset += 5;//id
Buffer[offset++] = 0;//has something to claim
Uint(4, offset, Buffer); offset += 4;//items done
}
client.Send(Buffer);
}
public byte[] ToArray()
{
return buffer;
}
public void Send(GameClient client)
{
client.Send(this.ToArray());
}
public void Deserialize(byte[] Data)
{
buffer = Data;
}
public static void Process(byte[] packet, GameClient client)
{
byte type = packet[4];
switch (type)
{
case 0://show
{
uint stage = BitConverter.ReadUint(packet, 5);
WayofHeroes Way2Heroes = new WayofHeroes(stage);
if (client.Way2Heroes.ContainsKey(stage))
Way2Heroes.check(client.Way2Heroes[stage]);
else client.Way2Heroes.Add(stage, new WayofHeroes.StageInfo() { UID = stage });
client.Send(Way2Heroes);
break;
}
case 1://claim sub prize
{
uint uid = BitConverter.ReadUint(packet, 5);
if (WayofHeroes.Stages.ContainsKey(uid))
{
uint stage = uid / 100;
if (!client.Way2Heroes[stage].SubStages.ContainsKey(uid))
{
client.Way2Heroes[stage].SubStages.Add(uid, new WayofHeroes.SubStageInfo() { UID = uid, Done = true });
var substage = WayofHeroes.Stages[uid];
client.Inventory.AddBoundItem(substage.Prize[0], 0, (byte)substage.Prize[1]);
client.Send(packet);
WayofHeroes.Save(client);
}
}
break;
}
case 2://claim main prize
{
uint uid = BitConverter.ReadUint(packet, 5) * 100;
if (WayofHeroes.Stages.ContainsKey(uid))
{
uint stage = uid / 100;
client.Way2Heroes[stage].Done = true;
var substage = WayofHeroes.Stages[uid];
client.Inventory.AddBoundItem(substage.Prize[0], (byte)substage.Prize[2], (byte)substage.Prize[1]);
client.Send(packet);
WayofHeroes.Save(client);
}
break;
}
//default: GeneralData.PrintPacket(packet); break;
}
}
}
}
تمام كده هتروح على
GameClient
او
GameState
على حسب اللى عندك
وهتضيف ده
- الكود:
public SafeDictionary<uint, WayofHeroes.StageInfo> Way2Heroes = new SafeDictionary<uint, WayofHeroes.StageInfo>(1000);
وبعدين ابحث عن
- الكود:
internal void LoadData(bool loadFake = false)
وبعدين انزل لحد
- الكود:
Database.ChiTable.Load
وضيف ده فوقيها
- الكود:
WayofHeroes.Load(this);
وهتروح على
program.cs
هتبحث عن
- الكود:
Database.SpellTable.Load();
وهتضيف ده تحتها
- الكود:
WayofHeroes.Load();
وهتحط الملف ده
[ندعوك للتسجيل في المنتدى أو التعريف بنفسك لمعاينة هذا الرابط]
فى المسار ده
bin/Debug/database
كده خلاص خلص كل حاجه
صورة للتاكيد
[ندعوك للتسجيل في المنتدى أو التعريف بنفسك لمعاينة هذه الصورة]
الأحد 01 مايو 2016, 7:45 pm من طرف Mr.MOSTAFA
» صفحة تسجيل فاجرة ومحمية مميزة وسهلة
الثلاثاء 09 يونيو 2015, 8:48 am من طرف VampiersCo
» Epic Taoist Screen.cs Code By ElMistro
الجمعة 22 مايو 2015, 8:41 pm من طرف Mr.MOSTAFA
» ابجريد 6075 الرقم بتاع ضربه الاسكله
السبت 09 مايو 2015, 2:05 am من طرف Mr.MOSTAFA
» الاصدار التانى من سورس هشام يورى بعد حل جميع المشاكل لعيون الناس كلها بمناسبه افتتاح المنتدى
السبت 28 مارس 2015, 12:49 am من طرف hsinstar
» WayOfHeroes Like TQ
الثلاثاء 17 مارس 2015, 7:37 am من طرف Mr.MOSTAFA
» حصريا : شرح عمل اوتو باتش كامل بالصور من منتدى تيم تى كى يو
الثلاثاء 03 مارس 2015, 4:26 pm من طرف VampiersCo
» حل مشكله البرود كاست BroadCast
الخميس 19 فبراير 2015, 1:54 am من طرف Mr.MOSTAFA
» أتحكم فى الدونيشن برحتك
الخميس 08 يناير 2015, 11:38 pm من طرف Mr.MOSTAFA