Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 16:11

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Adding a timer inbetween an item use

Discussion on Adding a timer inbetween an item use within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jan 2013
Posts: 24
Received Thanks: 0
Adding a timer inbetween an item use

Im basically trying to add a small timer in packethandler inbetween the "client.Send(Buf);" & the "Random Rand = new Random();" part so there is say a 5 second wait bewteen those 2 parts for the player when he uses the item.

Can anyone help with this?


Code:
 byte[] Buf = new byte[150 + 8]; 
                                 Writer.WriteUInt16(150, 0, Buf);
                                 Writer.WriteUInt16(10010, 2, Buf);
                                 Writer.WriteUInt32(client.Entity.UID, 4, Buf);
                                 Writer.WriteUInt32(0xD2, 8, Buf);
                                 Writer.WriteUInt32(164, 20, Buf);
                                 Writer.WriteUInt32(1, 22, Buf); 
                                 Writer.WriteUInt32(1, 32, Buf);
                                 Writer.WriteUInt32(1, 37, Buf);
                                 Writer.WriteUInt32(30, 38, Buf);
                                 Writer.WriteString("Planting Flower", 39, Buf);
                                 client.Send(Buf);

// add 5 second timer inbetween these 2 parts
                            
                        Random Rand = new Random();
                        int seed = Rand.Next(1, 5);
                        if (seed == 1) seed = 1;
                        if (seed == 2) seed = 2;
                        if (seed == 3) seed = 2;
                        if (seed == 4) seed = 1;
                        if (seed == 5) seed = 1;

                   if (seed == 2 && client.Entity.MapID == 1806)
                     {
ajstyles316 is offline  
Old 04/12/2013, 01:52   #2
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,376
You have two real options.

#1: Create a timer and execute that code inside the timer callback.

#2: Create some sort of timed events system for your server. This is the more scalable option in most cases but it's all personal preference really.
pro4never is offline  
Thanks
1 User
Old 04/12/2013, 03:07   #3
 
elite*gold: 0
Join Date: Jan 2013
Posts: 24
Received Thanks: 0
Could i use something like this inbetween there but instead of sending it to "MyTimer_Tick" once the timer is up make it just continue on from where it is to the next part, Is there a way to do that or not?

Code:
Timer MyTimer = new Timer();
        MyTimer.Interval = 3000;
        MyTimer.Tick += new EventHandler(MyTimer_Tick);
        MyTimer.Start();
ajstyles316 is offline  
Old 04/12/2013, 12:57   #4
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
add this instance in Entity.cs

Time32 PlantTime;
then when u send the player the effect make sure u set PlantTime to Time32.Now;

then in TimerCall Back Or Thread make smthing like
if (Now >= client.Entity.PlantTime.AddSeconds(5)) { // ur cases }
shadowman123 is offline  
Thanks
1 User
Old 04/12/2013, 17:00   #5
 
elite*gold: 0
Join Date: Jan 2013
Posts: 24
Received Thanks: 0
Thanks Shadowman got it working with a few modifications, I notice a slight cpu hit with the way im doing it when when someone plants, Is it because of the "tryagain" loop im using to check if the time has run out? and if so is there another better way to do this check?

entity
Code:
public Time32 PlantStamp;
public byte PlantTime;
Timer callback
Code:
                       
 if (Now >= Owner.Entity.PlantStamp.AddSeconds(PlantTime))
     {
      Owner.Entity.PlantTime = 0;
     }
use code
Code:
#region Anemone Flower
  case 4000053:
        {
         Game.Features.LoadingBar.Loading.Bar1(client); 
         client.Entity.PlantStamp = Time32.Now;
         client.Entity.PlantTime = 5;
   tryagain:
         if (client.Entity.PlantTime == 0)
           {
            Game.Features.Plants.Anemone1.Anemone11(client);
          }
       else
            {
         goto tryagain;
          }
       }
   break;
#endregion
ajstyles316 is offline  
Old 04/12/2013, 18:31   #6
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
Quote:
Originally Posted by ajstyles316 View Post

Code:
#region Anemone Flower
  case 4000053:
        {
         Game.Features.LoadingBar.Loading.Bar1(client); 
         client.Entity.PlantStamp = Time32.Now;
         client.Entity.PlantTime = 5;
   tryagain:
         if (client.Entity.PlantTime == 0)
           {
            Game.Features.Plants.Anemone1.Anemone11(client);
          }
       else
            {
         goto tryagain;
          }
       }
   break;
#endregion
Remove Plant time ...
Code:
                       
 if (Now >= Owner.Entity.PlantStamp.AddSeconds(5))
 {
    Owner.Entity.FinishedPlanting = true;
 }
as its obvious FinishedPlanting is Boolean instance inside Entity.cs
then in the Itemusing part

if (client.FinishedPlanting) { //ur cases }
else { send message to player telling him that he have to w8 few secs }
shadowman123 is offline  
Reply


Similar Threads Similar Threads
Item icon gone when adding new item (ItemMinIcon Problem)
04/13/2012 - EO PServer Hosting - 0 Replies
When i adding new casual for my new quest,and try to login to my Test server for checking it all item icon are gone.I really confident this problem was cause by ItemMinIcon.ani,why im saying that? cause when i move the item from ItemMinIcon.ani the problem solve...but the casual dont have icon...i bet some of ElitePvpers member know especially TheFlames ;) (Im Using Client Flames LOL) Screenshot: Item that i add (Casual) :
S4 League Item Timer Hack?
08/02/2011 - S4 League - 5 Replies
Hi Epvp, I Was Wondering If Anybody Here Knows Of A Hack That Stops The Time Of Your Equipment Or That It Fakes The Equipment Idk Something Like That As Long As The Item Doesn't Expires. If Someone Knows Of Any Please Post It Here? =0
Dot timer und item bonus
11/22/2009 - World of Warcraft - 9 Replies
Wie topic ! Suche halt addons die mir sagen wie lang mein dot noch auf dem gener drauf sind , egal welche dots! Und hab da mal bild gesehen wo jemand die allgemein stats der getragen sachen sehen kann ! ausserdem wurde angezeigt wieviel bonus auf crit und so das dann ergibt! Ich komm bei der suche dazu ned weiter! Thx 4 reading
S4 League Item Timer
11/02/2009 - S4 League - 1 Replies
I heard theres a hack / glitch that freeze your item 's timer ? is it true , i cant find it anywhere on the net , and wonder if its still working . help anyone ?



All times are GMT +2. The time now is 16:11.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.