بسم الله الرحمن الرحيم
السلام عليكم ورحمه الله وبركاته
اليوم جايب لكم سستم الورد الذي طال انتضاره
طبعا هو منقول بس الترجمه بتاعتي
باعمل هيكل جديد للورد flowers
واكتب فيه
كود PHP:
using System;
using System.Collections.Generic;
using System.Text;
namespace NewestCOServer
{
public partial class Struct
{
public class Flowers
{
public int RedRoses;
public int RedRoses2day;
public int Lilies;
public int Lilies2day;
public int Orchads;
public int Orchads2day;
public int Tulips;
public int Tulips2day;
public int Ammount;
}
}
}
ثم ضيف الكود ده في
character.cs
كود PHP:
public Struct.Flowers Flowers = new Struct.Flowers;
ثم ضيف الكود هذا الى Packets.cs
كود PHP:
public static COPacket FlowerPacket(string flowers)
{
byte[] packet = new byte[21 flowers.Length 8];
COPacket p = new COPacket(packet);
p.WriteInt16((ushort)(21 flowers.Length));
p.WriteInt16(1150);
p.WriteInt32(1);
p.Move(
;
p.WriteByte(1);
p.WriteString(flowers);
return p;
}
ثم اذهب الى PacketHandler.cs واضيف هذا الكود كمان
كود PHP:
#region Flowers
case 1150:
{
#region Target
string ID = "";
for (byte x = 18; x < 25; x )
{
ID = Convert.ToChar(Data[x]).ToString();
}
uint TargetID = uint.Parse(ID);
Character SaveChar = (Character)World.H_Chars[TargetID];
#endregion
#region Type
string Typing = "";
for (byte x = 25; x < 32; x )
{
Typing = Convert.ToChar(Data[x]).ToString();
}
string[] SplitValue = Typing.Split(' ');
int Flowers = int.Parse(SplitValue[1]);
int Type = int.Parse(SplitValue[2]);
[ندعوك للتسجيل في المنتدى أو التعريف بنفسك لمعاينة هذا الرابط] "Flowers : " Flowers);
[ندعوك للتسجيل في المنتدى أو التعريف بنفسك لمعاينة هذا الرابط] "Type : " Type);
#endregion
if (GC.MyChar.Body == 2001 || GC.MyChar.Body == 2002)
{ GC.LocalMessage(2005, "You can't sent flowers!"); return; }
if (World.H_Chars.Contains(TargetID))
{
if (World.AllFlowers.ContainsKey(SaveChar.EntityID))
{
Struct.Flowers F = World.AllFlowers[SaveChar.EntityID];
switch (Type)
{
#region Red Roses
case 0:
{
#region Item
string It = "751";
if (Flowers == 1)
It = "001";
else if (Flowers == 3)
It = "003";
else if (Flowers == 9)
It = "009";
else if (Flowers == 99)
It = "099";
else if (Flowers == 999)
It = "999";
#endregion
[ندعوك للتسجيل في المنتدى أو التعريف بنفسك لمعاينة هذا الرابط] "Item id : " It);
GC.MyChar.RemoveItem(GC.MyChar.NextItem(uint.Parse(It)));
F.RedRoses = Flowers;
F.RedRoses2day = Flowers;
SaveChar.Flowers = World.AllFlowers[SaveChar.EntityID];
SaveChar.FlowerName = "Red Roses";
break;
}
#endregion
#region Lilies
case 1:
{
#region Item
string It = "752";
if (Flowers == 1)
It = "001";
else if (Flowers == 3)
It = "003";
else if (Flowers == 9)
It = "009";
else if (Flowers == 99)
It = "099";
else if (Flowers == 999)
It = "999";
#endregion
[ندعوك للتسجيل في المنتدى أو التعريف بنفسك لمعاينة هذا الرابط] "Item id : " It);
GC.MyChar.RemoveItem(GC.MyChar.NextItem(uint.Parse(It)));
F.Lilies = Flowers;
F.Lilies2day = Flowers;
SaveChar.Flowers = World.AllFlowers[SaveChar.EntityID];
SaveChar.FlowerName = "Lilies";
break;
}
#endregion
#region Orchids
case 2:
{
#region Item
string It = "753";
if (Flowers == 1)
It = "001";
else if (Flowers == 3)
It = "003";
else if (Flowers == 9)
It = "009";
else if (Flowers == 99)
It = "099";
else if (Flowers == 999)
It = "999";
#endregion
[ندعوك للتسجيل في المنتدى أو التعريف بنفسك لمعاينة هذا الرابط] "Item id : " It);
GC.MyChar.RemoveItem(GC.MyChar.NextItem(uint.Parse(It)));
F.Orchads = Flowers;
F.Orchads2day = Flowers;
SaveChar.Flowers = World.AllFlowers[SaveChar.EntityID];
SaveChar.FlowerName = "Orchids";
break;
}
#endregion
#region Tulips
case 3:
{
#region Item
string It = "754";
if (Flowers == 1)
It = "001";
else if (Flowers == 3)
It = "003";
else if (Flowers == 9)
It = "009";
else if (Flowers == 99)
It = "099";
else if (Flowers == 999)
It = "999";
#endregion
[ندعوك للتسجيل في المنتدى أو التعريف بنفسك لمعاينة هذا الرابط] "Item id : " It);
GC.MyChar.RemoveItem(GC.MyChar.NextItem(uint.Parse(It)));
F.Tulips = Flowers;
F.Tulips2day = Flowers;
SaveChar.Flowers = World.AllFlowers[SaveChar.EntityID];
SaveChar.FlowerName = "Tulips";
break;
}
#endregion
}
GC.Message(2011, "What a love! " GC.MyChar.Name " has sent " Flowers.ToString() " " SaveChar.FlowerName " to your loved " SaveChar.Name "...");
}
else
{
Struct.Flowers F = new Struct.Flowers();
switch (Type)
{
#region Red Roses
case 0:
{
#region Item
string It = "751";
if (Flowers == 1)
It = "001";
else if (Flowers == 3)
It = "003";
else if (Flowers == 9)
It = "009";
else if (Flowers == 99)
It = "099";
else if (Flowers == 999)
It = "999";
#endregion
[ندعوك للتسجيل في المنتدى أو التعريف بنفسك لمعاينة هذا الرابط] "Item id : " It);
GC.MyChar.RemoveItem(GC.MyChar.NextItem(uint.Parse(It)));
F.RedRoses = Flowers;
F.RedRoses2day = Flowers;
SaveChar.FlowerName = "Red Roses";
break;
}
#endregion
#region Lilies
case 1:
{
#region Item
string It = "752";
if (Flowers == 1)
It = "001";
else if (Flowers == 3)
It = "003";
else if (Flowers == 9)
It = "009";
else if (Flowers == 99)
It = "099";
else if (Flowers == 999)
It = "999";
#endregion
[ندعوك للتسجيل في المنتدى أو التعريف بنفسك لمعاينة هذا الرابط] "Item id : " It);
GC.MyChar.RemoveItem(GC.MyChar.NextItem(uint.Parse(It)));
F.Lilies = Flowers;
F.Lilies2day = Flowers;
SaveChar.FlowerName = "Lilies";
break;
}
#endregion
#region Orchids
case 2:
{
#region Item
string It = "753";
if (Flowers == 1)
It = "001";
else if (Flowers == 3)
It = "003";
else if (Flowers == 9)
It = "009";
else if (Flowers == 99)
It = "099";
else if (Flowers == 999)
It = "999";
#endregion
[ندعوك للتسجيل في المنتدى أو التعريف بنفسك لمعاينة هذا الرابط] "Item id : " It);
GC.MyChar.RemoveItem(GC.MyChar.NextItem(uint.Parse(It)));
F.Orchads = Flowers;
F.Orchads2day = Flowers;
SaveChar.FlowerName = "Orchids";
break;
}
#endregion
#region Tulips
case 3:
{
#region Item
string It = "754";
if (Flowers == 1)
It = "001";
else if (Flowers == 3)
It = "003";
else if (Flowers == 9)
It = "009";
else if (Flowers == 99)
It = "099";
else if (Flowers == 999)
It = "999";
#endregion
[ندعوك للتسجيل في المنتدى أو التعريف بنفسك لمعاينة هذا الرابط] "Item id : " It);
GC.MyChar.RemoveItem(GC.MyChar.NextItem(uint.Parse(It)));
F.Tulips = Flowers;
F.Tulips2day = Flowers;
SaveChar.FlowerName = "Tulips";
break;
}
#endregion
default:
Console.WriteLine("Unknown Flower type " GC.MyChar.FlowerType);
break;
}
World.AllFlowers.Add(SaveChar.EntityID, F);
SaveChar.Flowers = World.AllFlowers[SaveChar.EntityID];
GC.Message(2011, "What a love! " GC.MyChar.Name " has sent " Flowers.ToString() " " SaveChar.FlowerName " to your loved " SaveChar.Name "...");
}
Database.SaveFlowerRank(SaveChar);
}
else
{
GC.LocalMessage(2005, "The target player isn't online right now.");
}
break;
}
case 1151:
{
int sub = Data[4];
switch (sub)
{
case
[ندعوك للتسجيل في المنتدى أو التعريف بنفسك لمعاينة هذا الرابط] {
Struct.Flowers F = GC.MyChar.Flowers;
string ToSend = " " F.RedRoses.ToString() " " F.RedRoses2day.ToString() " " F.Lilies.ToString() " " F.Lilies2day.ToString() " ";
ToSend = F.Orchads.ToString() " " F.Orchads2day.ToString() " " F.Tulips.ToString() " " F.Tulips2day.ToString();
GC.AddSend(Packets.FlowerPacket(ToSend));
break;
}
default:
{
Console.WriteLine("Unknown 1151 Sub type : " sub.ToString());
break;
}
}
break;
}
#endregion
ثم ضيف هذا الى World.cs
كود PHP:
public static Dictionary AllFlowers = new Dictionary();
and now this is the load/save for MySql version.....
كود PHP:
static void SaveFlowerRank(Game.Character C)
{
MySqlConnection Conn = GetConnection();
bool exist = false;
string Name = C.Name;
if (Name.Contains("[PM]"))
Name.Replace("[PM]", "");
try
{
lock (Conn)
{
MySqlCommand Cmd = new MySqlCommand("SELECT * FROM `cq_flowers` WHERE `charuid2` = '" C.Name "'", Conn);
MySqlDataReader DR = Cmd.ExecuteReader();
while (DR.Read())
{
exist = true;
}
DR.Close();
}
lock (Conn)
{
Struct.Flowers F = C.Flowers;
if (exist)
{
MySqlCommand Cmd = new MySqlCommand("UPDATE `cq_flowers` SET `redroses` = " F.RedRoses ", `redrosestoday` = " F.RedRoses2day ",`lilies` = " F.Lilies ",`liliestoday` = " F.Lilies2day ",`redrosestoday` = " F.Tulips ",`redrosestoday` = " F.Tulips2day ",`orchads` = " F.Orchads ",`orchadstoday` = " F.Orchads2day ", WHERE `charuid2` = \"" Name "\"", Conn);
Cmd.ExecuteNonQuery();
}
else
{
MySqlCommand Cmd = new MySqlCommand("INSERT INTO `cq_flowers` (redroses, redrosestoday, lilies, liliestoday, tulips, tulipstoday, orchads, orchadstoday, charuid, charuid2) VALUES (" F.RedRoses "," F.RedRoses2day "," F.Lilies "," F.Lilies2day "," F.Tulips "," F.Tulips2day "," F.Orchads "," F.Orchads2day "," C.EntityID ",'" Name "')", Conn);
Cmd.ExecuteNonQuery();
}
}
lock (Conn)
{
string Save = DateTime.Now.Year "-" DateTime.Now.Month "-" DateTime.Now.Day;
MySqlCommand Cmd = new MySqlCommand("UPDATE `cq_saves` SET `save_flower` = " Save " WHERE `type` = 0", Conn);
Cmd.ExecuteNonQuery();
}
Conn.Close();
}
catch (Exception ex) { Console.WriteLine(ex.ToString()); Conn.Close(); return; }
}