Register for your free account! | Forgot your password?

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

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

Advertisement



Adding a pause when using an item

Discussion on Adding a pause when using an item within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Feb 2006
Posts: 41
Received Thanks: 2
Adding a pause when using an item

I am currently using the code below to add a pause inbetween when an item is clicked and when it performs the main code, The code below works but gives a cpu spike while its being bounced between the (tryagain) waiting for the timer to let it through, So was wondering if there is any better way of handling this pause?

Item Use Code:

Code:
 case 4000058:
        {
          client.Entity.LoadStamp = Time32.Now;
          client.Entity.LoadTime = 3;
  tryagain:
           if (client.Entity.LoadTime == 0)
                {
                     Game.Features.lock3.Open(client);
                }
               else
                {
                      goto tryagain;
                }
         }
   break;
Timer Handle in Entity.cs

Code:
if (Now >= client.Entity.LoadStamp.AddSeconds(client.Entity.LoadTime))
     {
          client.Entity.LoadTime = 0;
     }
hacksaw is offline  
Old 08/11/2013, 03:06   #2


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
Oh dear ***...

Remove the goto for the love of ***. Use Thread.Sleep();
Korvacs is offline  
Old 08/11/2013, 03:46   #3
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
My reaction @ your code:
Super Aids is offline  
Old 08/11/2013, 05:18   #4
 
elite*gold: 0
Join Date: Mar 2013
Posts: 118
Received Thanks: 95
Quote:
Originally Posted by Korvacs View Post
Oh dear ***...

Remove the goto for the love of ***. Use Thread.Sleep();
I really don't think using Thread.Sleep inside a packet handler routine is a good idea
Smaehtin is offline  
Old 08/11/2013, 10:50   #5


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
Quote:
Originally Posted by Smaehtin View Post
I really don't think using Thread.Sleep inside a packet handler routine is a good idea
Well of course it isn't, but I don't really care about the effects that will have on his server, if he wants to pause the packet handler then let him, just so long as he's not using an infinite loop hacked into place using goto.
Korvacs is offline  
Old 08/11/2013, 11:34   #6
 
_Emme_'s Avatar
 
elite*gold: 1142
Join Date: Aug 2006
Posts: 2,464
Received Thanks: 1,162
Don't give advice if you know it's a extremely bad idea, that's just retarded.

@hacksaw
You have the right thinking, sort of. The easiest way for you to handle it is to make a new variable for this specific item ID/action. When Now => LoadTime, check if the itemid/action is not 0, if not perform the code (in this case Features.lock3.Open(Client) ).

Don't use an infinite loop, or pausing the entire Thread, but rather a timethread that works asynchronicity.
_Emme_ is offline  
Thanks
1 User
Old 08/11/2013, 13:58   #7
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
Just use something like a delayed action.
Super Aids is offline  
Old 08/11/2013, 14:29   #8
 
_Emme_'s Avatar
 
elite*gold: 1142
Join Date: Aug 2006
Posts: 2,464
Received Thanks: 1,162
Considering his first version of the code is fairly poor, I don't want to confuse OP too much. But if you're looking for as good functionality as possible, Reactive Extensions ( ) should do the trick nicely.

Here's an example:

Code:
case 4000058:
{
      IDisposable GLSubcription = Observable.Interval(TimeSpan.FromSeconds(3)).Subscribe(1 => Game.Features.lock3.Open(client));
      GLSubcription.Dispose();
}
_Emme_ is offline  
Thanks
1 User
Old 08/11/2013, 14:45   #9
 
elite*gold: 0
Join Date: Feb 2006
Posts: 41
Received Thanks: 2
Thanks Emil, I was just testing out your first way of doing it and it works a lot better that way, I shall have a read on the reactive extensions page in a few.

Nvm i see now ive read up on it, Although i read that using IDisposable & Observable together causes problems, Have you had any issues with them?
hacksaw is offline  
Reply


Similar Threads Similar Threads
[HELP] Bug Adding Item :(
05/11/2013 - Flyff Private Server - 7 Replies
ScreenShot: Screenshot by Lightshot InGame Bug: http://prntscr.com/14d6ma i add item to my server and I wear my fashion and i give the o3d,dds and NewPatcher UPDATE of my fashion to my players but my players cant see it :handsdown:
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) :
[Help] Adding New Item
05/04/2010 - CO2 Private Server - 4 Replies
Hey, i'm trying to add a new blade. I got a new c3>effect>blade folder called 410999 with edits in it cause i'm making my own weapon. This is what I have as my 3dtexture.ini: 919191=c3/effect/blade/410999/1.dds 929292=c3/effect/blade/410999/2.dds 939393=c3/effect/blade/410999/3.dds 949494=c3/effect/blade/410999/4.dds 959595=c3/effect/blade/410999/5.dds
[HELP] adding an item
06/19/2008 - EO PServer Hosting - 2 Replies
hey all, can somone give me a guide or video for doing hex editing to add a item i have tryed the itemtype editor that was posted but that messed up it so i need to manuly edit it :) thanks all hio77



All times are GMT +1. The time now is 09:46.


Powered by vBulletin®
Copyright ©2000 - 2026, 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 ©2026 elitepvpers All Rights Reserved.