One Time

One Time 1.0.0.15

No permission to download

Falkor

Squire
Apr 11, 2018
365
128
43
wpshard.com
Shard Name
Whispering Pines
Not only is the stress test with 2.6+ million items impressive, it's also great to know that ServUO will apparently make use of multiple cores.
 
  • Like
Reactions: GoldDraco13

GoldDraco13

Squire
Aug 1, 2014
415
261
63
48
Canada
mycy4.com
Donate
Donate money to this user
I don't recommend putting out 2.6 million items linked with one time, but it does prove the concept that 2.6 (Virtual Timers) work, never tested placing 2.6 million actual timers, too afraid to see the outcome on my poor laptop!

*Using Async is not something to take lightly, specially when applying it to a existing system that you have no idea or access to block the main thread from interacting with objects being changed on the sub threads by other methods unknown to you. Thus, using await and such allows you to control it somewhat by ie: not leaving the calling thread method until all sub threads are completed! Though in trade off, you are holding back work that could be processed on that dead time. Async is amazing if used correctly and hindered when implementing into existing systems.
 

GoldDraco13

Squire
Aug 1, 2014
415
261
63
48
Canada
mycy4.com
Donate
Donate money to this user
GoldDraco13 updated One Time with a new update entry:

Update

*Fixed a issue with CPU Usage - Was coming from the Tick and Millisecond IOneTime methods!

-Removed IOneTime Feilds Tick and Millisecond, use second or above for items and mobiles or use the event tick/millisecond but remember to disconnect the event as per notes in main post, there are two solid ways to remove events in the examples!
Read the rest of this update entry...
 

Finaltwist

Squire
Sep 7, 2019
397
114
43
Thanks for writting this! Looking at cleaning up some timers on the server im running. we use 17,000+ premiumspawners on the server. do you know if each premiumspawner uses its own timer? and if so, would it be tricky to convert to onetime?
 
  • Like
Reactions: GoldDraco13

Falkor

Squire
Apr 11, 2018
365
128
43
wpshard.com
Shard Name
Whispering Pines
Be careful re-inventing the wheel. My last shard has been online for over 12 years with premiumspawners and there is no performance hit with over 4000 spawners active.

I can't imagine the nightmare in serializing and deserializing the existing spawners to use different code!
 

GoldDraco13

Squire
Aug 1, 2014
415
261
63
48
Canada
mycy4.com
Donate
Donate money to this user
I have not looked into the Premium Spawners and have not tested changing out any timers in the distro files, but in theory I don't see why not, just make sure to understand a few things like the difference between the interface and event, the interface is better suited for instances of items and mobiles where the events are great for static systems!

There is nothing stopping an event to be used on instances but be mindful of the cost involved in removing them if there are many instances. Ie, deleting 2 million items each with an event attach will basically freeze the server up!

Disclaimer : I'm still learning so I could be wrong on my theory, though Vorspire made it clearer for me, I'm sure I lack the experience to truly say if it is a good idea or not! If you proceed, I will offer help where needed to implement OneTime as I am curious. I would if I were you, make a copy of the shard, and then test the idea on that copy, if it works, test it live, if it works, great, if not revert back.
 

Finaltwist

Squire
Sep 7, 2019
397
114
43
Hi, im trying to use onetime for the first time, in a baseclass to implement a one second timer for some event to happen.

Ive added this

C#:
        private void TimerTick() //onetime timer 1 sec
        {
            if (!draintimer)
                draintimer = true;   

        }
and getting this error on RUNUO

1595951637689.png


I used void because that's what your code seemed to use, since there's no return. I changed it to bool and had a return true; and get a similar error

I'm trying to add a one second timer (ideally it would be 500 ms but i don't know how to put that in so i used 1sec) to the attached file at line 424 to implement the change in line 427
Post automatically merged:

addon: sorry for the newbie question :/
 

Attachments

Last edited:

GoldDraco13

Squire
Aug 1, 2014
415
261
63
48
Canada
mycy4.com
Donate
Donate money to this user
OneTimeSecEvent.SecTimerTick += bc.TimerTick(); is the problem, you called it in the Curse Drain Method, this is the wrong way to implement a event, you need to call it when the object is created or system initialized and plus you added a ref to bc in the timertick method which is causing the error, signature matters and you broke the rule! But anyways, to fix, register the event properly and drop the ref bc. <Don't change the signature! I just woke up so this isn't the best response and I'll look at your script later to help with a solution!
 
  • Like
Reactions: Finaltwist

Finaltwist

Squire
Sep 7, 2019
397
114
43
LOL okay! I break lots of coding rules, i just take things from one script and try and apply to another, dealing with all the compile errors that causes. I thought i would try and use onetime instead of a regular timer here, but i had no idea how to do it, so i copied what you had in your scripts :D
Post automatically merged:

if i put OneTimeSecEvent.SecTimerTick += bc.TimerTick(); outside the curseddrain method, then how will i apply the delay/timer in the curseddrain?
 

GoldDraco13

Squire
Aug 1, 2014
415
261
63
48
Canada
mycy4.com
Donate
Donate money to this user
After a cup of coffee and a look at your script I found the problems and corrected them for you.

Just to explain a bit, OneTime has two options for implementation, one is using events and another is using an interface!

You were trying to use the event but not properly, one thing with events which are made up of delegates is that they work on method signatures, so you need to make sure methods match! Another thing is implementing them needs to be thought out, in which you need to think if you are using them on a item or mobile which could end up being 10000's for an example, could cause issues if you have each with its own event, which needs to then be unregistered once disposed! This is what was discussed in the conversation with Vorspire. I include interfaces to deal with this in another way as interfaces work on signature but are not tied to a list like delegates are to events, so they offer a great way to have one time control multiple items/mobiles. So in your case, the interface was the better way to go. I took out your using statements, commented out the onetime event and added the interface for you to test.
 

Attachments

  • Love
Reactions: Finaltwist

Finaltwist

Squire
Sep 7, 2019
397
114
43
I Am in your debt, for the wisdom and the system.

as a general rule, once i can see something used in a certain way, i can copy and run from there.
:D
 

GoldDraco13

Squire
Aug 1, 2014
415
261
63
48
Canada
mycy4.com
Donate
Donate money to this user
Let me know if it works, I do not have the AuraCreature to truly do a test to see if it works but I'm sure we'll work out any minor errors, double check too that I removed all your code, I might have missed something as your script in my VS was pretty much entirely red in errors! =D
 

Finaltwist

Squire
Sep 7, 2019
397
114
43
so.. one question (sorry again for noob question!)

i see what you did, but where in the script is OneTimeTick called?

I see
public int OneTimeType = 3;

but then no reference to the timer in the curseddrain ...
Post automatically merged:

you removed this but i don't see anything calling the timer?

1595955992451.png
 

Attachments