ID:2257104
 
(See the best response by Nadrew.)
Code:
YearAdd()
set category = "Admin"
switch(input("Are you sure you want to add a year?") in list("Yes","Cancel"))
if("Yes")
Year+=1
for(var/mob/M in world)
M.age += 1
M.Log_Year=Year
if(M.age>=14)
if(M.gender=="female")
M.icon='Human_Female_Tan.dmi'
if(M.gender=="male")
M.icon='human_male_tan.dmi'


Problem description:

This is a portion of how aging works but when a year is added by an admin. I found out that because of the ''in world'' part it doesn't age you while you're offline but that's what im aiming to have happen.

Can someone offer me any help on how i would do this?
Best response
You'd need to store the birth time of that player in their savefile, then apply their new age based on that when they loaded their save.

Or if admin interaction is the only way to age, you'd need to make it so the admin can pick from a list of saves, and modify the age within them manually -- if the person is offline when trying to change their age.
If you wanna keep it admin only you could increase a world variable called year and save that then just set everyone's age to the 'year - the year they created' when they login or just change it right away if they're logged in during the year change
You can store the value of world.realtime when they log out. When they log back in, the difference between the current realtime value and the stored value should be the amount of time IRL that they were logged out.

Of course, if you have a custom in-game timer, it's the same concept, but with the custom time instead of real time.
LiquidWhip wrote:
Problem description:

This is a portion of how aging works but when a year is added by an admin. I found out that because of the ''in world'' part it doesn't age you while you're offline but that's what im aiming to have happen.

Can someone offer me any help on how i would do this?

Nadrew is on point with what he said. Below is an example.

#define TIMELINE_CONVERT2SECONDS(_x) (_x*10)  //converts a number into seconds
#define TIMELINE_CONVERT2MINUTES(_x) (TIMELINE_CONVERT2SECONDS(_x) * 60) //as well as into minutes
#define TIMELINE_CONVERT2HOURS(_x) (TIMELINE_CONVERT2MINUTES(_x) * 60) //....and hours
#define TIMELINE_CONVERT2DAYS(_x) (TIMELINE_CONVERT2HOURS(_x) * 24) //...days
#define TIMELINE_CONVERT2WEEKS(_x) (TIMELINE_CONVERT2DAYS(_x) * 7) //..................weeks
#define TIMELINE_CONVERT2MONTHS(_x) (TIMELINE_CONVERT2WEEKS(_x) * 4) //..................MONTHS!!!
#define TIMELINE_CONVERT2YEARS(_x) (TIMELINE_CONVERT2MONTHS(_x) * 12) ///..................YEARS...
#define TIMELINE_CONVERT2DECADES(_x) (TIMELINE_CONVERT2YEARS(_x) * 10) //...AND DECADES!!!!!
#define TIMELINE_CONVERT2CENTURIES(_x) (TIMELINE_CONVERT2DECADES(_x) * 10) //CENTURIES!!!!!!!!!!!!!!!!!!!!!!!!!
#define TIMELINE_CONVERT2MILLENIUMS(_x) (TIMELINE_CONVERT2CENTURIES(_x) * 10) //and MILLENIUMS... I don't BYOND supports this number.
//okay, okay, maybe I was being a bit excessive here...

var/_timeline/_timeController = new; //because why not.
var/list/players_connected = new //just a way to track the players connected.

_timeline //a datum to handle all of time
var
_daySpan = TIMELINE_CONVERT2MINUTES(10); //The number in (){parentheses} will be mow many minutes need to pass by
//before a new day begins.
_currentDay = 1; //to keep track of what day it is.

_days_in_a_year = 6; //after every 6 "_daySpans", a year has concluded
//This would in turn be every hour.

proc
GetAge(mob/player/_player) //a function to get the age of the player
if(ismob(_player) && istype(_player,/mob/player)) //make sure that they are a player and not an NPC
. = round(((_currentDay - _player.birthday)) / _days_in_a_year); //returns their age

GetDay() //want to see that day it is...
. = _currentDay //don't know why we just don't do _timelineController._currentDay, but eh
//if you wished to call UnNeeded functions, go for it :)

GetYear() //incase you want the year too...
. = round(_currentDay / _days_in_a_year) //i prefer to make a variable for this but
//a function would suffice until you
//decide you'd want a varibale ;P

New() //once it's been instantiated
spawn() //just so we can continue other shit..
while(src) //as long as the timeline exists.. time moves forward?
sleep(_daySpan); //wait our _daySpan variable, which would be 10 minutes
_currentDay++; //new day begins
for(var/mob/player/_player in players_connected) //for every player conencted
_player.my_age = GetAge(_player); //lets update their age.
..() //because why the fuck not?

mob/player
var/birthday = 3; //lets say we were born on day 3
var/tmp/my_age = 0;
Login() //just for demo purposes
_timeController._currentDay = 19; //lets say 19 days passed, at our current rate
//that'll be (19 / 6), which is 3 years.

//since we were born on the 3rd day, it's actually
//(16 / 6), which means we were only born for 2
//so below should output the age of 2.
my_age = _timeController.GetAge(src);//sets the age
players_connected += src; //adds the player so we can track them later.

Stat() //just so we can see our age
statpanel("GARBAGE"); //cause it's garbage.... right?
stat("Years spent alone: [my_age]"); //so lonely :(
stat("Current Year: [_timeController.GetYear()]") //just so we can see the current year. I prefer a variable
//but that's on you.

world //a datum placeholder i presume
mob = /mob/player; //and tells the game that we want our default mobs to be a player


Above is a small snippet I just done. I haven't tested it but it may be something you're looking for.

Read it, understand it and how everything works.

From there, all you got to do is save the players birthday, the tmp vars shouldn't be saved.

Then just make a saving and loading for the Time Controller and it should be good to go o.o

Of course it isn't so Plug N' Play, just see what I did there and work up a snippet of your own that'll work :)

EDIT: Maybe I was being a bit excessive...
Also, the Player Login was just for DEMO purposes.