|
You last visited: Today at 09:45
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.
08/11/2013, 02:58
|
#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;
}
|
|
|
08/11/2013, 03:06
|
#2
|
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();
|
|
|
08/11/2013, 03:46
|
#3
|
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
|
My reaction @ your code:
|
|
|
08/11/2013, 05:18
|
#4
|
elite*gold: 0
Join Date: Mar 2013
Posts: 118
Received Thanks: 95
|
Quote:
Originally Posted by Korvacs
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
|
|
|
08/11/2013, 10:50
|
#5
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
|
Quote:
Originally Posted by Smaehtin
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.
|
|
|
08/11/2013, 11:34
|
#6
|
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.
|
|
|
08/11/2013, 13:58
|
#7
|
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
|
Just use something like a delayed action.
|
|
|
08/11/2013, 14:29
|
#8
|
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();
}
|
|
|
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?
|
|
|
 |
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.
|
|