sm1 asked me to do that system for him so i finished it and Decided to Release it For all members in case sm1 wanted to add it too ... anyways its pretty easy to be added
This Guide Is For Beginers ..Im Sure All Expert Members dont need Explaination for these methods
Lets Start By Database
The Add that Line In GameState.cs
Add this Line in program.cs ... that line Loads All VIP values inside VIP Table when server starts
This Void Should Be Called When Restarting The Server in order to Decrease the Suscribtion Days by 1
Add this In EntityTable.cs To Check If The Player is Suscribed IN VIP .. if Days == 0 This Means that his Suscribtion is Expired So Deleting This Player From VIP Database
NOTE : SendMessage is My Method of Sending Messages so Dont use Mine Or you are going to have Errors so Replace it With Yours
Add it In LoginMessages Void Inside PacketHandler.cs To Send Vip Packet to Player if he is VIP
NOTE : You Should Handle The way of Adding Players In Database Yourself Either using Commands , Website or w.e ur way is ..thats y i didnt do the SavePlayer Method Calling
Then you are done with adding the System
Hope it helps you guyz
VIP Table in Attachment .. just Upload it to your Server Database
BTW I Dont Mind Sharing My Codes As long As you are giving me The Credits
Regards
Shadowman123
This Guide Is For Beginers ..Im Sure All Expert Members dont need Explaination for these methods
Lets Start By Database
PHP Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Conquer_Online_Server.Database
{
public class VipVariables
{
public string PlayerName, SuscribtionDate;
public byte Days = 0, VIPLevel = 0;
}
class VipTable
{
public static Dictionary<string, VipVariables> VipList = new Dictionary<string, VipVariables>();
public static void LoadAllVips()
{
VipList.Clear();
MySqlCommand Cmd = new MySqlCommand(MySqlCommandType.SELECT);
Cmd.Select("VIP");
MySqlReader Reader = new MySqlReader(Cmd);
while (Reader.Read())
{
VipVariables vip = new VipVariables();
vip.PlayerName = Reader.ReadString("PlayerName");
vip.SuscribtionDate = Reader.ReadString("SuscribtionDate");
vip.Days = Reader.ReadByte("Days");
vip.VIPLevel = Reader.ReadByte("VIPLevel");
VipList.Add(vip.PlayerName, vip);
}
Reader.Close();
Reader.Dispose();
Program.WriteLine("All Vip Players Are Loaded.");
}
public static void SavePlayer(Client.GameState client, byte VIPLevel, byte Days)
{
new MySqlCommand(MySqlCommandType.INSERT).Insert("VIP").Insert("PlayerName", client.Entity.Name).Insert("SuscribtionDate", DateTime.Now.ToShortTimeString()).Insert("VIPLevel", VIPLevel).Insert("Days", Days).Execute();
LoadAllVips();
}
public static void Delete(string PlayerName)
{
new MySqlCommand(MySqlCommandType.DELETE).Delete("VIP", "PlayerName",PlayerName).Execute();
Program.WriteLine(PlayerName + "'s Vip Suscribtion is Expired");
}
}
}
PHP Code:
public Database.VipVariables VIPInformation = new Database.VipVariables();
PHP Code:
Database.VipTable.LoadAllVips();
PHP Code:
static void VIPDaysReduction()
{
foreach (var VIPMember in Database.VipTable.VipList.Values)
{
byte Days = VIPMember.Days;
new MySqlCommand(MySqlCommandType.UPDATE).Update("VIP").Set("Days", Days > 0 ? Days-- : 0).Where("PlayerName", VIPMember.PlayerName).Execute();
}
}
Add this In EntityTable.cs To Check If The Player is Suscribed IN VIP .. if Days == 0 This Means that his Suscribtion is Expired So Deleting This Player From VIP Database
PHP Code:
if (Database.VipTable.VipList.ContainsKey(client.Entity.Name))
{
client.VIPInformation = Database.VipTable.VipList[client.Entity.Name];
if (client.VIPInformation.Days == 0)
{
client.SendMessage("Your VIP Suscribtion Has Expired", Message.TopLeft);
Database.VipTable.Delete(client.Entity.Name);
}
}
Add it In LoginMessages Void Inside PacketHandler.cs To Send Vip Packet to Player if he is VIP
PHP Code:
client.Entity.VIPLevel = client.VIPInformation.VIPLevel;
if (client.Entity.VIPLevel > 0)
{
client.Send(new VIPAdvanced(true) { UID = client.Entity.UID });
}
Then you are done with adding the System
Hope it helps you guyz
VIP Table in Attachment .. just Upload it to your Server Database
BTW I Dont Mind Sharing My Codes As long As you are giving me The Credits
Regards
Shadowman123