Forum C# Need help about timers

Need help about timers

Postby uterian » April 19th, 2013, 4:51 pm

Hi.
There is a searching mechanism in my game which sends a message to server to search an item in an area and I want to put a timer that makes clients wait 2 minutes to find that item, for the security reasons I have to make this countdown on serverside.
So clients send message to ask permission from server to search that item then server registers it's starting time then it counts 2minutes and when 2minutes pass, server sends a message to client to say "2 minutes has passed, you've found that item". How can I make my server count that time synchronously. I don't want my server to stop all other works to count 2minutes.
Thank you
Uterian.
uterian
 
Posts: 8
Joined: March 29th, 2013, 2:09 am

Re: Need help about timers

Postby Henrik » April 19th, 2013, 5:38 pm

http://playerio.com/documentation/refer ... leCallback

It's very simple, you schedule a future callback.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Need help about timers

Postby uterian » April 19th, 2013, 5:41 pm

Thank you very much Henrik. :)
uterian
 
Posts: 8
Joined: March 29th, 2013, 2:09 am

Re: Need help about timers

Postby uterian » April 19th, 2013, 8:50 pm

But there is another problem.
What if player cancels this process? How can I stop ScheduleCallback?
uterian
 
Posts: 8
Joined: March 29th, 2013, 2:09 am

Re: Need help about timers

Postby Henrik » April 20th, 2013, 3:08 pm

ScheduleCallback returns a Timer object:

http://playerio.com/documentation/refer ... rary.timer
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm


Return to C#



cron