محمد ياسر
2019-04-21, 04:39 PM
السلام عليكم ورحمة الله وبركاته
طريقة عمل VIP علشان تديه لي لاعب ولفتره محدده اسبوع شهر يومين يوم براحت
يلا نبداء
افتح فلدر Game واعمل فيه كلاس باسم
VIPDays.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using T3Alo.Database;
namespace T3Alo.Game
{
public class VIPDays
{
/*
* All Rights Reserved © Mahmoud Mohammed
*/
public DateTime VIPStartON, VIPEndAt;
public byte VIPLevelDays, OldVIPLevel;
public int VIPLogMessage;
public VIPDays()
{
foreach (Client.GameState client in Program.GamePool)
{
this.VIPLevelDays = 0;
this.OldVIPLevel = client.Entity.VIPLevel;
}
}
public static void READ(Client.GameState client)
{
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("vipdays").Where("UID", client.Entity.UID))
using (var reader = new MySqlReader(cmd))
{
if (reader.Read())
{
client.VIPDays.VIPLevelDays = reader.ReadByte("VIPLevelDays");
client.VIPDays.OldVIPLevel = reader.ReadByte("OldVIPLevel");
client.VIPDays.VIPStartON = DateTime.FromBinary(reader.ReadInt64("VIPStartON"));
client.VIPDays.VIPEndAt = DateTime.FromBinary(reader.ReadInt64("VIPEndAt"));
}
else
{
using (var cmds = new MySqlCommand(MySqlCommandType.INSERT))
cmds.Insert("vipdays").Insert("Name", client.Entity.Name).Insert("UID", client.Entity.UID).Execute();
}
}
}
public static void SAVE(Client.GameState client)
{
xConquer.Database.MySqlCommand cmd = new xConquer.Database.MySqlCommand(xConquer.Database.M ySqlCommandType.UPDATE);
cmd.Update("vipdays")
.Set("VIPLevelDays", client.VIPDays.VIPLevelDays)
.Set("OldVIPLevel", client.VIPDays.OldVIPLevel)
.Set("VIPStartON", client.VIPDays.VIPStartON)
.Set("VIPEndAt", client.VIPDays.VIPEndAt);
cmd.Where("UID", client.Entity.UID);
cmd.Execute();
}
}
}
وتخش علي GameState او GameClient وتحط الكود دا
public Game.VIPDays VIPDays = new Game.VIPDays();
وتخش علي World او Thread على حسب سورسك
هتبحث عن
CharactersCallback
وتحط الكود ده
#region VIPDays Check
/*
* All Rights Reserved © Mahmoud Mohammed
*/
if (client.VIPDays.VIPLevelDays > 0 && DateTime.Now >= client.VIPDays.VIPEndAt)
{
client.Entity.VIPLevel = client.VIPDays.OldVIPLevel;
client.VIPDays.VIPLevelDays = 0;
client.VIPDays.VIPStartON = Convert.ToDateTime(0);
client.VIPDays.VIPEndAt = Convert.ToDateTime(0);
VIPDays.SAVE(client);
client.Send("Your VIP is end, Try to get other item and unlock it.");
}
#endregion
وتخش علي PacketHandler وتبحث علي
تحت الكود ده
Npcs dialog = new Npcs(client);
هتضيف دول
#region VIIPDays.
/*
* All Rights Reserved © T3Alo
*/
if (client.ActiveNpc == 3004121)
{
if (client.Inventory.Contains(client.ActiveNpc, 1))
{
if (req.OptionID == 1)
{
if (client.Entity.VIPLevel > 3)
{
dialog.Text("You are VIPLevel " + client.Entity.VIPLevel + ", So you can't unlock this item.");
dialog.Option("Ohh, Sorry.", 255);
dialog.Send();
}
else
{
if (client.Entity.VIPLevel < 4)
{
dialog.Text("Are you sure you want to unlock this item.");
dialog.Option("Yes I'm sure.", 2);
dialog.Send();
}
}
}
if (req.OptionID == 2)
{
if (client.Entity.VIPLevel < 4)
{
client.VIPDays.OldVIPLevel = client.Entity.VIPLevel;//هنا بيحفظ الفي اي بي القديم بتاعك علشان بعد الاسبوع يرجعهولك تاني
client.VIPDays.VIPLevelDays = 4;//هنا بيديلك الفي اي بي الي موجود في الشنه والي انت هتتحدو
client.VIPDays.VIPStartON = DateTime.Now;//هنا بيسجل بدايه الاسبوع بتاعك من وقت فتح الشنطه
client.VIPDays.VIPEndAt = DateTime.Now.AddDays(7);//هنا بيحدد الوقت الي هيخلص فيه الفي اي بي ويرجعلك الفي اي بي القديم
client.Entity.VIPLevel = client.VIPDays.VIPLevelDays;//هنا بيديلك الفي اي بي
client.Inventory.Remove(client.ActiveNpc, 1);
client.Send("Congratulations " + client.Entity.Name + ", You have got VIPLevel " + client.VIPDays.VIPLevelDays + " to " + client.VIPDays.VIPEndAt + ".");
VIPDays.SAVE(client);
}
}
}
}
#endregion
فى فويد
tatic void UseItem
حط دول تحت اى شنطه
#region VIP7Days
case 3004121:
{
Npcs dialog = new Npcs(client);
dialog.Text("Hello " + client.Entity.Name + ", There is VIPLevel 4 For 7 Days. If you want to get it just confirm.");
dialog.Option("Confirm.", 1);
dialog.Option("Cancel.", 255);
dialog.Avatar(318);
dialog.Send();
client.ActiveNpc = item.ID;
break;
}
#endregion
في EntityTable في الاخر خالص تحت الكود دا
client.Entity.FullyLoaded = true;
تضيف ده
Game.VIPDays.READ(client);
في GameState او GameClient
هتبحث عن
rivate void ShutDown()
تحط الكود ده
Kernel.GamePool.Remove(Entity.UID);
ضيف
VIPDays.SAVE(this);
القاعده في المرفقات ارفعه للقاعده
طريقة عمل VIP علشان تديه لي لاعب ولفتره محدده اسبوع شهر يومين يوم براحت
يلا نبداء
افتح فلدر Game واعمل فيه كلاس باسم
VIPDays.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using T3Alo.Database;
namespace T3Alo.Game
{
public class VIPDays
{
/*
* All Rights Reserved © Mahmoud Mohammed
*/
public DateTime VIPStartON, VIPEndAt;
public byte VIPLevelDays, OldVIPLevel;
public int VIPLogMessage;
public VIPDays()
{
foreach (Client.GameState client in Program.GamePool)
{
this.VIPLevelDays = 0;
this.OldVIPLevel = client.Entity.VIPLevel;
}
}
public static void READ(Client.GameState client)
{
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("vipdays").Where("UID", client.Entity.UID))
using (var reader = new MySqlReader(cmd))
{
if (reader.Read())
{
client.VIPDays.VIPLevelDays = reader.ReadByte("VIPLevelDays");
client.VIPDays.OldVIPLevel = reader.ReadByte("OldVIPLevel");
client.VIPDays.VIPStartON = DateTime.FromBinary(reader.ReadInt64("VIPStartON"));
client.VIPDays.VIPEndAt = DateTime.FromBinary(reader.ReadInt64("VIPEndAt"));
}
else
{
using (var cmds = new MySqlCommand(MySqlCommandType.INSERT))
cmds.Insert("vipdays").Insert("Name", client.Entity.Name).Insert("UID", client.Entity.UID).Execute();
}
}
}
public static void SAVE(Client.GameState client)
{
xConquer.Database.MySqlCommand cmd = new xConquer.Database.MySqlCommand(xConquer.Database.M ySqlCommandType.UPDATE);
cmd.Update("vipdays")
.Set("VIPLevelDays", client.VIPDays.VIPLevelDays)
.Set("OldVIPLevel", client.VIPDays.OldVIPLevel)
.Set("VIPStartON", client.VIPDays.VIPStartON)
.Set("VIPEndAt", client.VIPDays.VIPEndAt);
cmd.Where("UID", client.Entity.UID);
cmd.Execute();
}
}
}
وتخش علي GameState او GameClient وتحط الكود دا
public Game.VIPDays VIPDays = new Game.VIPDays();
وتخش علي World او Thread على حسب سورسك
هتبحث عن
CharactersCallback
وتحط الكود ده
#region VIPDays Check
/*
* All Rights Reserved © Mahmoud Mohammed
*/
if (client.VIPDays.VIPLevelDays > 0 && DateTime.Now >= client.VIPDays.VIPEndAt)
{
client.Entity.VIPLevel = client.VIPDays.OldVIPLevel;
client.VIPDays.VIPLevelDays = 0;
client.VIPDays.VIPStartON = Convert.ToDateTime(0);
client.VIPDays.VIPEndAt = Convert.ToDateTime(0);
VIPDays.SAVE(client);
client.Send("Your VIP is end, Try to get other item and unlock it.");
}
#endregion
وتخش علي PacketHandler وتبحث علي
تحت الكود ده
Npcs dialog = new Npcs(client);
هتضيف دول
#region VIIPDays.
/*
* All Rights Reserved © T3Alo
*/
if (client.ActiveNpc == 3004121)
{
if (client.Inventory.Contains(client.ActiveNpc, 1))
{
if (req.OptionID == 1)
{
if (client.Entity.VIPLevel > 3)
{
dialog.Text("You are VIPLevel " + client.Entity.VIPLevel + ", So you can't unlock this item.");
dialog.Option("Ohh, Sorry.", 255);
dialog.Send();
}
else
{
if (client.Entity.VIPLevel < 4)
{
dialog.Text("Are you sure you want to unlock this item.");
dialog.Option("Yes I'm sure.", 2);
dialog.Send();
}
}
}
if (req.OptionID == 2)
{
if (client.Entity.VIPLevel < 4)
{
client.VIPDays.OldVIPLevel = client.Entity.VIPLevel;//هنا بيحفظ الفي اي بي القديم بتاعك علشان بعد الاسبوع يرجعهولك تاني
client.VIPDays.VIPLevelDays = 4;//هنا بيديلك الفي اي بي الي موجود في الشنه والي انت هتتحدو
client.VIPDays.VIPStartON = DateTime.Now;//هنا بيسجل بدايه الاسبوع بتاعك من وقت فتح الشنطه
client.VIPDays.VIPEndAt = DateTime.Now.AddDays(7);//هنا بيحدد الوقت الي هيخلص فيه الفي اي بي ويرجعلك الفي اي بي القديم
client.Entity.VIPLevel = client.VIPDays.VIPLevelDays;//هنا بيديلك الفي اي بي
client.Inventory.Remove(client.ActiveNpc, 1);
client.Send("Congratulations " + client.Entity.Name + ", You have got VIPLevel " + client.VIPDays.VIPLevelDays + " to " + client.VIPDays.VIPEndAt + ".");
VIPDays.SAVE(client);
}
}
}
}
#endregion
فى فويد
tatic void UseItem
حط دول تحت اى شنطه
#region VIP7Days
case 3004121:
{
Npcs dialog = new Npcs(client);
dialog.Text("Hello " + client.Entity.Name + ", There is VIPLevel 4 For 7 Days. If you want to get it just confirm.");
dialog.Option("Confirm.", 1);
dialog.Option("Cancel.", 255);
dialog.Avatar(318);
dialog.Send();
client.ActiveNpc = item.ID;
break;
}
#endregion
في EntityTable في الاخر خالص تحت الكود دا
client.Entity.FullyLoaded = true;
تضيف ده
Game.VIPDays.READ(client);
في GameState او GameClient
هتبحث عن
rivate void ShutDown()
تحط الكود ده
Kernel.GamePool.Remove(Entity.UID);
ضيف
VIPDays.SAVE(this);
القاعده في المرفقات ارفعه للقاعده