I want to make it so the player's age increases while the server is up, regardless of whether the player is logged in or not. I was thinking of using world.time but that resets when the server reboots. I could also make another variable such as Year and make it go up with sleep(). Unless I'm constantly updating Year (shouldn't create much lag since its 1 global var, right?) anytime the server goes down between update times, the counter for Year restarts. I've a few questions on how to do this well.
Is it better to update everyones age at a set time(each new day, month, etc) or would it be better to be constantly updating age?
Is it better to use world.time or sleep() for keeping track of the date ingame, or is there some other way that would be more effective?
When it comes to character age, are there any variables that I should save for technical reasons? (eg. Using DOB to calculate a characters age if their age var somehow gets messed up, anything i should save as tmp, global, etc)
It`s pointless to make that players also age when they are not logged in because that would be a waste. (Because server would constantly updating its year even if he is not playing and you dont want 100 proc running for players that aint even playing the game) That's... not actually true. OP actually seems to know what he's doing to some degree here, Phat T. The trick to making a player able to age when they are offline, is to save their year of birth, and when the player is read from a savefile, calculate how long it's been since the player was born. #define YEAR_TICKER 18000 //world is saved every 30 minutes That pretty much covers saving the world's time, as well as running the event. I decided it would be best to save the world every 30 minutes, and I decided to use a 24hr = 1yr sort of setup. Next, is the players. var/list/players = list() That's pretty much all there is to it. Make sure age is marked as temporary, because we don't need to save it. As long as we save the player's year of birth, as well as save the date of the world, we can have offline aging. If you want this to happen even when the server is down, you should use world.realtime, although, I'd argue that's of questionable reasoning. Hell, even players aging when offline seems a little unreasonable. |
Thank you very much, still so much to learn so this will help me out immensely.
while(.=0;.<YEAR_TICKS;count++) This line seems to draw an error. World.dm:26:error: .: missing comma ',' or right-paren ')' Also, why did you use a semicolon in that statement? I've only been learning DM for a week or so now and I thought they were used as a type of newline. However in here I don't know why its being used (but its clear its important in the situation, did some playing around and only semicolon will work as a divider(?) of the three statements) for a different reason. I couldn't find anything in the documentation about it either. Well, no semicolon operator that is. |
It`s pointless to make that players also age when they are not logged in because that would be a waste. (Because server would constantly updating its year even if he is not playing and you dont want 100 proc running for players that aint even playing the game)
Good luck