منتدي اكواد

منتدي اكواد (https://code.vpscairo.com/index.php)
-   تطوير سيرفرات كونكر (https://code.vpscairo.com/forumdisplay.php?f=11)
-   -   سيستم كويستت SteedRace [طلبات الاعضاء] (https://code.vpscairo.com/showthread.php?t=2784)

Hassan Emprator 2019-11-05 07:26 AM

سيستم كويستت SteedRace [طلبات الاعضاء]
 
بسم الله الرحمن الرحيم

يله نبدا

سيرش في Handel

كود PHP:

public static IEnumerable<Client.GameStateEntityinRange(Entity attackerEntity attacked

ضيف

كود PHP:

 public static void QuitSteedRace(Entity attacker)
        {
            
attacker.Owner.MessageBox("Do you want to quit the steed race?", (pClient) =>
            {
                
pClient.Entity.Teleport(1002301279);
                
pClient.Entity.RemoveFlag(Update.Flags.Ride);
            });
            
//attacker.Owner.Send(new NpcReply(NpcReply.MessageBox, "Do you want to quit the steed race?"));
            //attacker.Owner.MessageOK = (pClient) =>
            //{
            //    pClient.Entity.Teleport(1002, 301, 279);
            //    pClient.Entity.RemoveFlag(Update.Flags.Ride);
            //};
            //attacker.Owner.MessageCancel = null;
        


بعدين هتعمل كلاس تسميه SteedRace

وضيف

كود PHP:

using MrHassan.Game;
using MrHassan.Network.GamePackets;
using System;
using System.Threading.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 
MrHassan.Game
{
    
using Colors System.Drawing.Color;
    
using MrHassan.Client;
    
using System.Threading.Generic;

    public class 
SteedRace
    
{
        public 
uint[][] RaceSettings = new[]
        {
            new 
uint[]{ (uint)Enums.Maps.MarketRace88149
                
4204314,  
                
65174621,
                
12324360
                
21433470
                
346459100},
            new 
uint[]{ (uint)Enums.Maps.IceRace175250
                
2001536//255, 535*
                
154267621,
                
14639270,
                
283351100,
                
295079100},
            new 
uint[]{ (uint)Enums.Maps.IslandRace60400
                
89981610,
                
96392621,
                
220234200,
                
472160200,
                
777464300},
            new 
uint[]{ (uint)Enums.Maps.DungeonRace450520,
                
682484 10,
                
435559621,
                
471759200,
                
714598250,
                
48967920},
            new 
uint[]{ (uint)Enums.Maps.LavaRace150350,
                
3301706,
                
101397623,
                
327553100,
                
526477200,
                
283275100}
        };
        public static 
ushort MAPID 1950;
        public static 
uint[] Settings;
        public static 
uint RaceRecord;

        private 
Map Map;
        private 
bool isOnInvitationsOutInvitationsExpiredFiveSecondsLeftGateOpen;
        private 
DateTime InvitationsSentOutInvitationsExpireDateLast5SecondsGateOpened;

        public 
int SecondsLeftUntilStart get { return (int)(InvitationsSentOut.AddMinutes(1) - DateTime.Now).TotalSeconds 5; } }
        public 
bool CanJoin get { return isOn && !GateOpen; } }
        public 
bool IsOn get { return isOn; } }
        private 
SobNpcSpawn Gate;
        private 
ushort GateSetXGateSetY;
        public 
ushort GateX get { return GateSetX; } }
        public 
ushort GateY get { return GateSetY; } }

        private 
volatile int Records;
        private 
IDisposable Subscriber;

        public 
SteedRace()
        {
            
Subscriber World.Subscribe(work1000);
        }

        public 
void Create()
        {
            while (
true)
            {
                
//Console.WriteLine("Looking for a race map!");
                
int rand Kernel.Random.Next(RaceSettings.Length);
                if (
Database.MapsTable.MapInformations.ContainsKey((ushort)RaceSettings[rand][0]))
                {
                    if (!
Kernel.Maps.ContainsKey((ushort)RaceSettings[rand][0]))
                        new 
Map((ushort)RaceSettings[rand][0], "");
                    if (
Kernel.Maps.ContainsKey((ushort)RaceSettings[rand][0]))
                        
Create(RaceSettings[rand][0]);
                    break;
                }
            }
        }
        public 
void Create(uint mapId)
        {
            
int index = -1;
            for (
int i 0RaceSettings.Lengthi++)
            {
                if (
RaceSettings[i][0] == mapId)
                {
                    
index i;
                    break;
                }
            }
            if (
index == -1) return;
            
Settings RaceSettings[index];
            
MAPID = (ushort)Settings[0];
            var 
info Database.MapsTable.MapInformations[MAPID];

            
RaceRecord info.RaceRecord;
            
Map Kernel.Maps[MAPID];
            foreach (var 
item in Map.StaticEntities.Values)
                
Map.Floor[item.Xitem.YMapObjectType.StaticEntitynull] = true;
            
Map.StaticEntities.Clear();
            
Map.Npcs.Clear();
            
Map.Entities.Clear();

            
Gate = new SobNpcSpawn();
            
Gate.UID 19501;
            
Gate.= (ushort)Settings[6];
            
Gate.= (ushort)Settings[7];
            
Gate.Mesh = (ushort)Settings[8];
            
Gate.ShowName true;
            
Gate.Name " ";
            
Gate.Type Enums.NpcType.Furniture;
            
GateSetX Gate.XGateSetY Gate.Y;
            
Map.AddNpc(Gate);//, false);
            
MAPID = (ushort)mapId;
            
Init();
        }

        private 
void Init()
        {
            
isOn InvitationsOut InvitationsExpired GateOpen FiveSecondsLeft false;
            
GeneratePotions();
            
Records 0;
        }

        private 
void GeneratePotions()
        {
            
uint count 100;
            
ushort xy;
            
Tuple<ushortushortint>[] limits = new[]
            {
                new  
Tuple<ushort,ushort,int>( (ushort)Settings[9], (ushort)Settings[10], (int)Settings[11] ),
                new  
Tuple<ushort,ushort,int>( (ushort)Settings[12], (ushort)Settings[13], (int)Settings[14] ),
                new  
Tuple<ushort,ushort,int>( (ushort)Settings[15], (ushort)Settings[16], (int)Settings[17] )
            };

            while (
count 0)
            {
                
= (ushort)Kernel.Random.Next(0Map.Floor.Bounds.Width);
                
= (ushort)Kernel.Random.Next(0Map.Floor.Bounds.Height);
                
bool valid false;
                foreach (var 
range in limits)
                    
valid |= (Kernel.GetDistance(xyrange.Item1range.Item2) < range.Item3);
                if (
valid)
                {
                    if (
Map.Floor[xyMapObjectType.StaticEntitynull] && Map.Floor[xyMapObjectType.Entitynull])
                    {
                        
bool v true;
                        
// so they wont be anywhere near the bounds
                        // and also there wont be one too near to another
                        
for (int i 0Game.Map.XDir.Lengthi++)
                            if ((!
Map.Floor[Game.Map.XDir[i], Game.Map.YDir[i], MapObjectType.Entitynull] ||
                                !
Map.Floor[Game.Map.XDir[i], Game.Map.YDir[i], MapObjectType.StaticEntitynull]) && v)
                                
false;
                        if (!
v) continue;

                        
StaticEntity item = new StaticEntity((uint)(1000 y), xyMAPID);
                        
item.Pick();

                        
item.MapID MAPID;
                        
Map.AddStaticEntity(item);
                        
count--;
                    }
                }
            }
        }

        public 
void work(int time)
        {
            
DateTime now DateTime.Now;
            
//bool rightHour = now.Hour == 8 || now.Hour == 12 || now.Hour == 18;
            
bool rightHour now.Hour == || now.Hour == || now.Hour == ||
                 
now.Hour == || now.Hour == || now.Hour == || now.Hour == ||
                  
now.Hour == || now.Hour == || now.Hour == 10 || now.Hour == 11 ||
                   
now.Hour == 12 || now.Hour == 13 || now.Hour == 14 || now.Hour == 15 ||
                    
now.Hour == 16 || now.Hour == 17 || now.Hour == 18 || now.Hour == 19 ||
                     
now.Hour == 20 || now.Hour == 21 || now.Hour == 22 || now.Hour == 23 ||
                      
now.Hour == 24;
            if (
rightHour && now.Minute 31)
            {
                if (!
InvitationsOut)
                {
                    if (
now.Minute == 00)
                    {
                        
Create();
                        
SendInvitations();
                    }
                }
                else if (!
InvitationsExpired)
                {
                    if (
now >= InvitationsExpireDate)
                    {
                        
InvitationsExpired true;
                        
FiveSecondsLeft false;
                        
Last5Seconds InvitationsSentOut.AddMinutes(1).AddSeconds(-12);
                    }
                }
                else if (!
FiveSecondsLeft)
                {
                    if (
now Last5Seconds)
                    {
                        
FiveSecondsLeft true;
                        
SendData(Data.BeginSteedRaceuid1);
                        
Last5Seconds Last5Seconds.AddSeconds(5);
                    }
                }
                else if (!
GateOpen)
                {
                    if (
now Last5Seconds)
                    {
                        
OpenGate();
                    }
                }
            }
            else if (
rightHour && now.Minute >= 31)
            {
                if (
isOn)
                {
                    
End();
                }
            }
        }

        private 
void SendInvitations()
        {
            
isOn true;
            
InvitationsOut true;
            
InvitationsExpired false;
            
InvitationsSentOut DateTime.Now;
            
InvitationsExpireDate InvitationsSentOut.AddSeconds(30);

            foreach (var 
client in Program.Values)
            {
                if (
client.Entity.MapID >= 6000 && client.Entity.MapID <= 6002) continue;
                
client.MessageCancel = (pClient) =>
                {
                    
pClient.Send(new Message("If you change your mind about joining the Steed Race you can see the Mount Trainer (Twin City qqq,www)."System.Drawing.Color.RedMessage.World));
                };
                
client.MessageOK = (pClient) =>
                {
                    if (!
isOn)
                    {
                        
pClient.Send(new Message("The tournament has ended."System.Drawing.Color.RedMessage.Center));
                    }
                    else if (
isOn && InvitationsExpired)
                    {
                        
pClient.Send(new Message("You lost your chance to join the steed race."System.Drawing.Color.RedMessage.Center));
                    }
                    else if (
InvitationsOut && !InvitationsExpired)
                    {
                        if (!
pClient.Spells.ContainsKey(7001))
                        {
                            
pClient.Send("You need learn the riding skill!");
                        }
                        else
                        {
                            if (!
pClient.Equipment.Free(ConquerItem.Steed))
                                
Join(pClient);
                            else
                                
pClient.Send("You need to wear a horse first!");
                        }
                    }
                };
                
client.Send(new Network.GamePackets.NpcReply(Network.GamePackets.NpcReply.MessageBox"Would you like to join the Steed Race?"));
                
client.Send(new Data(true) { UID client.Entity.UIDID Data.CountDowndwParam 60 });
            }
            
Kernel.SendWorldMessage(new Network.GamePackets.Message("SteedRace has started You have 1 minute to signup go to TC HorseRaceManager!."System.Drawing.Color.WhiteNetwork.GamePackets.Message.Center), Program.Values);
        }

        public 
void Join(Client.GameState client)
        {
            
int seconds SecondsLeftUntilStart;
            if (
seconds 0)
                
client.Send(new Data(true) { UID client.Entity.UIDID Data.CountDowndwParam = (uint)seconds });
            
client.Entity.AddFlag(Update.Flags.Ride);
            
client.Entity.Teleport(MAPID, (ushort)Settings[1], (ushort)Settings[2]);
            
client.Send(new RaceRecord()
            {
                
Type RaceRecordTypes.BestTime,
                
Rank = (int)Database.MapsTable.MapInformations[MAPID].RaceRecord// best time in milliseconds
                
dwParam 1800000 //a constant? 
            
});
            
client.Send(new RacePotion(true) { PotionType Enums.RaceItemType.NullAmount });
            
client.Send(new RacePotion(true) { PotionType Enums.RaceItemType.NullAmount });
            
client.Potions = new UsableRacePotion[5];
        }
        private 
void OpenGate()
        {
            
GateOpened DateTime.Now;
            
GateOpen true;
            
Gate.0;
            
Gate.0;
            
Send(new Data(true) { UID Gate.UIDID Data.RemoveEntity });
        }

        private 
void Send(Interfaces.IPacket packet)
        {
            
Kernel.SendWorldMessage(packetProgram.ValuesMAPID);
        }
        private 
void SendData(ushort IDuint value 0uint uid 0)
        {
            
Data data null;
            if (
uid != 0)
                
data = new Data(true) { UID uidID IDdwParam value };

            foreach (var 
player in Program.Values)
            {
                if (
player.Entity.MapID == MAPID)
                {
                    if (
uid == 0)
                    {
                        
data = new Data(true) { UID player.Entity.UIDID IDdwParam value };
                        
player.Send(data);
                    }
                    else
                    {
                        
player.Send(data);
                    }
                }
            }
        }

        private 
void Status(Client.GameState clientint rankint timeint award)
        {
            var 
packet = new RaceRecord()
            {
                
Type RaceRecordTypes.AddRecord,
                
Rank rank,
                
Name client.Entity.Name,
                
Time time,
                
Prize award
            
};
            
Send(packet);
        }

        private 
void End()
        {
            
InvitationsOut false;
            
Gate.GateSetX;
            
Gate.GateSetY;
            foreach (var 
player in Program.Values)
                if (
player.Entity.MapID == MAPID)
                    Exit(
player);
            
Init();
        }

        public 
void FinishRace(Client.GameState client)
        {
            
// if (Kernel.GetDistance(client.Entity.X, client.Entity.Y, (ushort)Settings[3], (ushort)Settings[4]) > 22)
            //  {
            //      return;
            //  }
            //  else
            
{
                if (
Records 5)
                {
                    
Records++;
                    
int rank Records;
                    
TimeSpan span DateTime.Now GateOpened;
                    var 
key Database.MapsTable.MapInformations[MAPID];
                    if (
key.RaceRecord span.TotalMilliseconds)
                    { 
// new best record
                        
key.RaceRecord = (uint)span.TotalMilliseconds;
                        
Database.MapsTable.SaveRecord(key);
                    }
                    
int award AwardPlayer(client, (int)span.TotalMillisecondsrank);
                    
client.RacePoints += (uint)award;
                    
Status(clientrank, (int)span.TotalMillisecondsaward);
                    
client.Send(new RaceRecord()
                    {
                        
Type RaceRecordTypes.EndTime,
                        
Rank rank,
                        
dwParam = (int)span.TotalMilliseconds,
                        
dwParam2 award,
                        
Time = (int)span.TotalMilliseconds,
                        
Prize award
                    
});
                }
                Exit(
client);
            }
        }

        private 
int AwardPlayer(Client.GameState clientint timeint rank)
        {
            return 
Math.Max(3500100000 rank time 2);
        }

        public 
void Exit(Client.GameState client)
        {
            switch (
client.Entity.PreviousMapID)
            {
                default:
                    {
                        
client.Entity.Teleport(1002301278);
                        break;
                    }
                case 
1000:
                    {
                        
client.Entity.Teleport(1000500650);
                        break;
                    }
                case 
1020:
                    {
                        
client.Entity.Teleport(1020565562);
                        break;
                    }
                case 
1011:
                    {
                        
client.Entity.Teleport(1011188264);
                        break;
                    }
                case 
1015:
                    {
                        
client.Entity.Teleport(1015717571);
                        break;
                    }
            }
        }
    }


وبعدين ابحث عن

كود PHP:

 public const ushort 

ضيف

كود PHP:

 BeginSteedRace 401,
                
FinishSteedRace 402

بعدين هتبحث عن

كود PHP:

#region NPC Dialog (2031 + 2032) 

هتلاقي اكواد كتير شبه دا

كود PHP:

 if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 251 && client.Map.BaseID != 700)// Critical PK
                        
{
                            
Random R = new Random();
                            
client.Entity.Teleport(1002415383);
                        } 

ضيف فيه دا

كود PHP:

if (client.Map.BaseID != 6001 && client.Map.BaseID != 6004 && !client.Entity.Dead && req.OptionID == 242 && client.Map.BaseID != 700)//SteedRace
                        
{
                            
client.Entity.Teleport(1002423245);
                        } 

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

ابحث عن

كود PHP:

case 408

ضيف فوقه دا

كود PHP:

case Data.FinishSteedRace:
                    if (
client.Entity.MapID == SteedRace.MAPID)
                        
Program.World.SteedRace.FinishRace(client);
                    break; 

ابحث عن

كود PHP:

 static void EntityGroundMovment(GroundMovement groundMovementClient.GameState client

ضيف

كود PHP:

 if (client.Entity.MapID == Game.SteedRace.MAPID)
            {
              if (!
Program.World.SteedRace.IsOn)
                {
                 if (
client.Entity.<= Program.World.SteedRace.GateX 1)
                   {
                       
client.Entity.Teleport(client.Entity.PXclient.Entity.PY);
                       return;
                 }
                }
            }
            if (
client.Entity.MapID == Game.SteedRace.MAPID)
                
CheckForRaceItems(client); 

بعدين ابحث عن

كود PHP:

Database.EntityTable.LoginNow(client); 

ضيف

كود PHP:

#region AtSteedRace
            
if (client.Entity.MapID == 1950client.Entity.Teleport(1002300278);
            if (
client.Entity.MapID == 2064client.Entity.Teleport(1002300278);
            if (
client.Entity.MapID == 2063client.Entity.Teleport(1002300278);
            if (
client.Entity.MapID == 2062client.Entity.Teleport(1002300278);
            if (
client.Entity.MapID == 2061client.Entity.Teleport(1002300278);
            
#endregion 

ابحث عن

كود PHP:

public uint LastXLocationLastYLocation

هتلاقي دول فيهم

ضيف فيهم

دا
يعني
هيكون كدا

كود PHP:

  public bool InSteedRaceInvisableIsBlackSpottedIsEagleEyeShooted false

بعدين ضيف
الانبي سي دا

كود PHP:

#region HorseRace
                #region HorseRaceIn
                
case 4488521:
                    {
                        switch (
npcRequest.OptionID)
                        {
                            case 
0:
                                {
                                    
dialog.Text("Hey there " client.Entity.Name "! The race is held every two hours, on even hours(0,2,4,..). Are you interested in joining the race? You might receive amazing gifts upon reaching the finish line!");
                                    
dialog.Option("Yes, please."1);
                                    
dialog.Option("Open the shop."2);
                                    
dialog.Option("I don't care."255);
                                    
dialog.Send();
                                    break;
                                }
                            case 
1:
                                {
                                    
DateTime now DateTime.Now;
                                    
//bool rightHour = now.Hour == 8 || now.Hour == 12 || now.Hour == 18;
                                    
bool rightHour now.Hour == || now.Hour == || now.Hour == ||
     
now.Hour == || now.Hour == || now.Hour == || now.Hour == ||
      
now.Hour == || now.Hour == || now.Hour == 10 || now.Hour == 11 ||
       
now.Hour == 12 || now.Hour == 13 || now.Hour == 14 || now.Hour == 15 ||
        
now.Hour == 16 || now.Hour == 17 || now.Hour == 18 || now.Hour == 19 ||
         
now.Hour == 20 || now.Hour == 21 || now.Hour == 22 || now.Hour == 23 ||
          
now.Hour == 24;
                                    if (
rightHour)
                                    {
                                        if (
now.Minute == 0)
                                        {
                                            if (
client.Equipment.Free(ConquerItem.Steed))
                                            {
                                                
dialog.Text("You need a horse first.");
                                                
dialog.Option("I don't care."255);
                                                
dialog.Send();
                                                return;
                                            }
                                            if (!
client.Spells.ContainsKey(7001))
                                            {
                                                
dialog.Text("You need to learn the ride spell first!");
                                                
dialog.Option("I don't care."255);
                                                
dialog.Send();
                                                return;
                                            }
                                            
Program.World.SteedRace.Join(client);
                                        }
                                    }
                                    else
                                    {
                                        
dialog.Text("HorseRace is held during HH:44 in every two hours.");
                                        
dialog.Option("I don't care."255);
                                        
dialog.Send();
                                        break;
                                    }
                                    break;
                                }
                            case 
2:
                                {
                                    
INpc npc null;
                                    if (
client.Map.Npcs.TryGetValue(client.ActiveNpcout npc))
                                    {
                                        
Data data = new Data(true);
                                        
data.ID Data.OpenWindow;
                                        
data.UID client.Entity.UID;
                                        
data.TimeStamp Time32.Now;
                                        
data.dwParam 464;
                                        
data.wParam1 npc.X;
                                        
data.wParam2 npc.Y;
                                        
client.Send(data);
                                    }
                                    break;
                                }
                        }
                        break;
                    }
                
#endregion
                #region Winner of HorseRace
                
case 4488522:
                    {
                        switch (
npcRequest.OptionID)
                        {
                            case 
0:
                                {
                                    
dialog.Text("Hey there " client.Entity.Name " Would you like to claim your Prize?.");
                                    
dialog.Option("Yes Please"1);
                                    
dialog.Option("I don't care."255);
                                    
dialog.Send();
                                    break;
                                }
                            case 
1:
                                {
                                    
Program.World.SteedRace.FinishRace(client);
                                    
client.Entity.ConquerPoints += 25000;
                                    
client.Entity.ChampionPoints += 155;
                                    
//Daily.CheackAlive();
                                    /*if (DateTime.Now.Minute >= 45 && DateTime.Now.Minute <= 59)
                                    {
                                        if (Game.Tournaments.SteedRace.IsRace)
                                        {
                                            Game.Tournaments.SteedRace.GiveReward(client);
                                            client.Entity.Teleport(1002, 302, 278);
                                        }
                                        else
                                        {
                                            dialog.Text("Sorry SteedRace not running Atm so u cant claim any shit!");
                                            dialog.Option("okay", 255);
                                            dialog.Send();
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        dialog.Text("Hey there " + client.Entity.Name + "You can only claim the prize when the Tourment Online");
                                        dialog.Option("okay", 255);
                                        dialog.Send();
                                        break;
                                    }*/
                                    
break;
                                }
                        }
                        break;
                    }
                
#endregion
                #endregion 

طبعا كلنا عارفين طريقه الاضافه

واهي كمان

كود PHP:

4488522    SteedRaceMan2    2    5150    1950    420    420    
4488521    SteedRaceMan    2    5150    1002    308    143 

بس كدا تم بنجاح الاضافه كامله

سلام عليكم

وانتظرو حجات جميله مني انشاء الله :)
InSteedRace




محمد ياسر 2019-11-05 09:38 AM

رد: سيستم كويستت SteedRace [طلبات الاعضاء]
 
عاش

ALz3em 2019-11-05 12:12 PM

رد: سيستم كويستت SteedRace [طلبات الاعضاء]
 
عاش

سمير 2019-11-05 04:24 PM

رد: سيستم كويستت SteedRace [طلبات الاعضاء]
 
عااااش

Rihanna 2019-11-05 08:03 PM

رد: سيستم كويستت SteedRace [طلبات الاعضاء]
 
عاش

karem1q 2023-10-11 10:02 PM

رد: سيستم كويستت SteedRace [طلبات الاعضاء]
 
عاش


الساعة الآن 04:29 AM

مرحبا بكم في منتدي اكواد لتطوير الالعاب