Code:
Problem description:Hello coders out there i need a small help from you guys
i want to make a verb(event schedule) for player when they click it show them when a event was last held or at which time will the next event will start
Like: in my game if there is a tourney system and the tourney starts after every 45 min
i want to make a verb for players like when they use it it will show them when the tourney is with the game in time
eg :- when is the next event again - name of the event
Thank you any kind of help appreciated
In response to Braekyn
|
|
Braekyn wrote:
Look into the "timeofday" var. Using some simple subtraction, you can figure this out easily enough :) i have dealt with timeofday var but didnt get what you tryna say srry wanted to say in this manner like the event is executed at 12:00 then next event 12:45 like it will show time for next event when it will be held again sorry i wrote time for next event to start |
First, some definitions for time:
#define DAY (HOUR * 24) Next Scheduling Let us say we're creating a new datum to handle events. This datum will include the last time an event ran, and the next time an event will run. var/EventManager/EventManager The first thing we need to do is setup the first run. This will be 45 * 60 * 10 ticks (Minutes/Seconds/Ticks) - using the defined values above, we can write this as '45 * MINUTE' To determine when this will run, you will want to use world.time. This is because this value will never reset, unless the server has a restart. This will make sure that we don't have to handle logic between different days when checking the value. EventManager Now we have it scheduled, we'd want to be able to display this to our users. Simply enough, we'll get the delta from now, and add it to world.timeofday. This will show in server time, the time of the next run. //NextEvent - Current Server Time = duration...offset the timeofday and handle day looping Now, not all users are in the timezone, so we may want to show a duration too. proc/FormatDuration(ticks) That would allow you to display the information you're looking for. |
Thank you buddy for help i saw your code did some changesto it and make it working
it was a good one i need another thing can i make a proc spawn every hour at the same minute like 1:20 not it happens then 2:20 again it gets executed i tried to do using world.timeofday and text2time but didnt work out making too much cpu damage |
This would be the work of some sort of Event Scheduler.
Lucky that there are a few that have been released as libraries. http://www.byond.com/developer/Stephen001/EventScheduling |
but I want the proc to be executed according to the time zone not by the uptime of the game
|
Fair enough, in order to do that - you'd want to create a custom scheduler that is based of from world.timeofday, converting to world.time.
The post here details how it would work with world.time. http://www.byond.com/members/DreamMakers/ forum?id=729915&view=1&display=1#729877 |
just world/var/time might work for you as well