عرض مشاركة واحدة
احصائياتى

الردود
63

المشاهدات
39677
تفاعلات العضو
 
QR تعريفي
QR Code
Commander

Commander is on a distinguished road

    غير متواجد

المشاركات
127

+التقييم
0.05

تاريخ التسجيل
Jul 2019

الاقامة
https://www.facebook.com/Hossam.eldein123/

نظام التشغيل

رقم العضوية
407
2019-08-05, 06:08 PM
المشاركة 1 
#1  
Happy الدونشن بوقت :DonationTime
بسم الله الرحمن الرحيم
ده هيفيد الناس الي عايزه تعمل شحن في سيرفراتها كنج بوقت معين ومش عارفه
نخش في الاضافه علي طول والاضافه سهله جدا ومش طويله
اول حاجه هنعمل كلاس جديد

كود:
using Extreme.Game;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ResidentEvil.Network.GamePackets;
using System.Threading;
using System.Threading.Generic;
using ResidentEvil.Network.Sockets;
using ResidentEvil.Game.ConquerStructures;
using ResidentEvil.Game.ConquerStructures.Society;
using ResidentEvil.Client;
using System.Drawing;
using ResidentEvil.Game.Events;
using ResidentEvil.Database;
using System.Data.SqlClient;
using System.Configuration;

namespace 
ResidentEvil
{
    public class 
NobilityTimer
    
{
        public 
DateTime StartOn, EndOn;
        public 
ulong OldDonation;
        public 
byte Donation;
        public 
Time32 CheckStamp = Time32.Now;
        public 
void Insert(DateTime _StartOn, DateTime _EndOn, byte _Donation, ulong _OldDonation, Client.GameState client)
        {
            
this.StartOn = _StartOn;
            
this.EndOn = _EndOn;
            
this.Donation = _Donation;
            
this.OldDonation = _OldDonation;
            
client.NobilityInformation.Donation = this.OldDonation;
            
#region Insert
            
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("nobilitytimer").Where("UID", client.Entity.UID))
            
using (var reader = new MySqlReader(cmd))
            {
                if (!
reader.Read())
                    
using (var cmds = new MySqlCommand(MySqlCommandType.INSERT))
                        
cmds.Insert("nobilitytimer").Insert("UID", client.Entity.UID).Execute();
            }
            
#endregion
            
this.Save(client);
            
client.Send("Your Rank Will End In " + this.EndOn + "");
            
        }
        public 
void Load(Client.GameState c)
        {
            
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("nobilitytimer").Where("UID", c.Entity.UID))
            
using (var reader = new MySqlReader(cmd))
            {
                if (
reader.Read())
                {
                    
this.Donation = reader.ReadByte("Number");
                    
this.OldDonation = reader.ReadByte("OldDonation");
                    
this.StartOn = Kernel.FromDateTimeInt(reader.ReadUInt64("StartOn"));
                    
this.EndOn = Kernel.FromDateTimeInt(reader.ReadUInt64("EndOn"));
                }
            }
        }
        public 
void Save(Client.GameState client)
        {
            
Database.MySqlCommand cmd = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
            
cmd.Update("nobilitytimer").Set("Number", this.Donation).Set("OldDonation", this.OldDonation).Set("StartOn", Kernel.ToDateTimeInt(this.StartOn)).Set("EndOn", Kernel.ToDateTimeInt(this.EndOn))
            .
Where("UID", client.Entity.UID).Execute();
        }
    }
} 

بعد كدا هنروح علي كلاس

كود:
 GameState or GameClient 

ونحط فيه ده

كود:
 public NobilityTimer NobilityTimer = new NobilityTimer(); 

بعد كدا في نفس الكلاس وندور علي

كود:
void ShutDown() 

وننزل لحد

كود:
    Database.EntityTable.SaveEntity(this, conn); 

ونحط فوقيها ده

كود:
  NobilityTimer.Save(this); 

بعد كدا نروح لكلاس

كود:
EntityTable 

ونبحث عن

كود:
 client.Entity.FullyLoaded = true; 

ونحط تحتو ده

كود:
   client.NobilityTimer.Load(client); 

بعد كدا نروح لكلاس

كود:
Nobility

ندور علي

كود:
 case NobilityInfo.Donate: 

وتحت القوس نحط

كود:
  if (client.NobilityTimer.Donation == 1 || client.NobilityTimer.Donation == 2 || client.NobilityTimer.Donation == 3)
                        {
                            
client.MessageBox("Sorry U Can't Donate Now.", null, null, 60);
                            return;
                        } 

بعد كدا نروح لكلاس باكت هاندلر وندور علي

كود:
 void DoLogin 

وتحت القوس نحط

كود:
 client.NobilityTimer.Load(client); 

بعد كدا نروح كلاس ورلد وندور علي

كود:
 void CharactersCallback 

ونحط فيه ده

كود:
#region NobilityTimer Check
           
            
if (client.NobilityTimer.Donation > 0 && DateTime.Now >= client.NobilityTimer.EndOn)
            {
                
client.NobilityInformation.Donation = client.NobilityTimer.OldDonation; 
                
Game.ConquerStructures.Nobility.Sort(client.Entity.UID);
                
Database.NobilityTable.UpdateNobilityInformation(client.NobilityInformation);
                
client.NobilityTimer.Save(client);
                
client.Send("Your Rank, Is Ended, Now Your Rank is Back.");
                
MySqlCommand cmd = new MySqlCommand(MySqlCommandType.DELETE);
                
cmd.Delete("nobilitytimer", "UID", client.Entity.UID).Execute();
                
client.NobilityTimer.Donation = 0;
            }
          
            
#endregion 

بعد كدا اخر حاجه في الاضافه في السي شارب وهيا الان بي سي

كود:
#region DonationTime
                
case 38213:
                    {

                        switch (
npcRequest.OptionID)
                        {
                            case 
0:
                                {

                                    
dialog.Text("Hey there " + client.Entity.Name + ", I'm Here to Up Ur Rank 7 Days For Cps.");
                                    
dialog.Option("Up Me To King/Queen", 1);
                                    
dialog.Option("Up Me To Prince/Princess.", 2);
                                    
dialog.Option("Up Me To Duke/Duchess.", 3);
                                    
dialog.Option("No Thanks.", 255);
                                    
dialog.Avatar(50);
                                    
dialog.Send();
                                    break;
                                }
                            case 
1:
                                {

                                    
dialog.Text("I'll Up U To King/Queen to 7 Days For 200.000 Cps.");
                                    
dialog.Option("Ok, Up Me.", 4);
                                    
dialog.Option("No Thanks.", 255);
                                    
dialog.Avatar(50);
                                    
dialog.Send();
                                    break;
                                }
                            case 
2:
                                {

                                    
dialog.Text("I'll Up U To Prince/Princess to 7 Days For 100.000 Cps.");
                                    
dialog.Option("Ok, Up Me.", 5);
                                    
dialog.Option("No Thanks.", 255);
                                    
dialog.Avatar(50);
                                    
dialog.Send();
                                    break;
                                }
                            case 
3:
                                {

                                    
dialog.Text("I'll Up U To Duke/Duchess to 7 to Days 50.000 Cps.");
                                    
dialog.Option("Ok, Up Me.", 6);
                                    
dialog.Option("No Thanks.", 255);
                                    
dialog.Avatar(50);
                                    
dialog.Send();
                                    break;
                                }
                            case 
4:
                                {
                                    if (
DateTime.Now >= client.NobilityTimer.EndOn)
                                    {
                                        if (
client.Entity.ConquerPoints >= 200000)
                                        {
                                            
client.Entity.ConquerPoints -= 200000;
                                            
client.NobilityTimer.Insert(DateTime.Now, DateTime.Now.AddDays(7), 1, client.NobilityInformation.Donation, client);
                                            
client.NobilityTimer.Save(client);
                                            
client.NobilityInformation.Donation = 1;
                                            
Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " Has been King/Queen For 7 Days. ", Color.Red, Message.Center));
                                            
Game.ConquerStructures.Nobility.Sort(client.Entity.UID);
                                            
Database.NobilityTable.UpdateNobilityInformation(client.NobilityInformation);
                                        }
                                        else
                                        {
                                            
dialog.Text("Please come back to me with 200.000 Conquer Points.");
                                            
dialog.Option("Ahh sorry.", 255);
                                            
dialog.Avatar(50);
                                            
dialog.Send();
                                        }
                                    }
                                    else
                                    {
                                    
dialog.Text("U Already do it.");
                                    
dialog.Option("Ahh sorry.", 255);
                                    
dialog.Avatar(50);
                                    
dialog.Send();
                                    }
                                    break;
                                }
                            case 
5:
                                {
                                    if (
DateTime.Now >= client.NobilityTimer.EndOn)
                                    {
                                        if (
client.Entity.ConquerPoints >= 100000)
                                        {
                                            
client.Entity.ConquerPoints -= 100000;
                                            
client.NobilityTimer.Insert(DateTime.Now, DateTime.Now.AddDays(7), 2, client.NobilityInformation.Donation, client);
                                            
client.NobilityTimer.Save(client);
                                            
client.NobilityInformation.Donation = 2;
                                            
Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " Has been Prince/Princess For 7 Days. ", Color.Red, Message.Center));
                                            
Game.ConquerStructures.Nobility.Sort(client.Entity.UID);
                                            
Database.NobilityTable.UpdateNobilityInformation(client.NobilityInformation);
                                        }
                                        else
                                        {
                                            
dialog.Text("Please come back to me with 100.000 Conquer Points.");
                                            
dialog.Option("Ahh sorry.", 255);
                                            
dialog.Avatar(50);
                                            
dialog.Send();
                                        }
                                    }
                                    else
                                    {
                                        
dialog.Text("U Already do it.");
                                        
dialog.Option("Ahh sorry.", 255);
                                        
dialog.Avatar(50);
                                        
dialog.Send();
                                    }
                                    break;
                                }
                            case 
6:
                                {
                                    if (
DateTime.Now >= client.NobilityTimer.EndOn)
                                    {
                                        if (
client.Entity.ConquerPoints >= 50000)
                                        {
                                            
client.Entity.ConquerPoints -= 50000;
                                            
client.NobilityTimer.Insert(DateTime.Now, DateTime.Now.AddDays(7), 3, client.NobilityInformation.Donation, client);
                                            
client.NobilityTimer.Save(client);
                                            
client.NobilityInformation.Donation = 3;
                                            
Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " Has been Duke/Duchess For 7 Days. ", Color.Red, Message.Center));
                                            
Game.ConquerStructures.Nobility.Sort(client.Entity.UID);
                                            
Database.NobilityTable.UpdateNobilityInformation(client.NobilityInformation);
                                        }
                                        else
                                        {
                                            
dialog.Text("Please come back to me with 50.000 Conquer Points.");
                                            
dialog.Option("Ahh sorry.", 255);
                                            
dialog.Avatar(50);
                                            
dialog.Send();
                                        }
                                    }
                                    else
                                    {
                                        
dialog.Text("U Already do it.");
                                        
dialog.Option("Ahh sorry.", 255);
                                        
dialog.Avatar(50);
                                        
dialog.Send();
                                    }
                                    break;
                                }
                        }
                        break;
                    }
                
#endregion 

روح لكلاس

كود:
nobility 

ابحث عن

كود:
  if (Place >= 51) 

وضيف تحت القوس

كود:
  if (entry.Donation == 1)
                        {
                            
Rank = NobilityRank.King;
                        }
                        if (
entry.Donation == 2)
                        {
                            
Rank = NobilityRank.Prince;
                        }
                        if (
entry.Donation == 3)
                        {
                            
Rank = NobilityRank.Duke;
                        } 

والتحكم في الوقت من هنا

كود:
DateTime.Now.AddDays(7), 

بعد كدا نرفع ده في القاعده
عفواً لايمكن عرض الرابط إلا بعد الرد على الموضوع

يا رب اكون عرفت اشرحلكم الاضافه كويس والسلام عليكم ورحمة الله وبركاته