SphereCommunity
Player age - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: Player age (/Thread-Player-age)



Player age - Leonidas - 09-16-2015 08:02 AM

Hey I was wondering if there is a way to redo the player age system.

Like for example, a player joins the server, he starts off at age 10, a real time month later, he turns 11, month later 12, month later, 13.


RE: Player age - pointhz - 09-16-2015 08:11 AM

ON=@LOGIN

IF !(<SRC.TAG0.AGE>)
SRC.TAG.AGE=10
TIMERF 2592000, f_age // 1 month in seconds
ENDIF

[FUNCTION f_age]
SRC.TAG.AGE=<EVAL (<SRC.TAG.AGE>+1)>
SRC.SYSMESSAGE You are now <EVAL <SRC.TAG.AGE>> years old. Type .age to see your current age.
IF (<EVAL <SRC.TAG0.AGE>> == 100)
SRC.SYSMESSAGE You'r old enough. Time to rest.
SRC.KILL
SRC.STONE
SRC.FLAGS=<SRC.FLAGS> & statf_war
ELSE
TIMERF 2592000, f_age
ENDIF

[FUNCTION age]
SRC.SYSMESSAGE You are <EVAL <SRC.TAG.AGE>> years old.


Something like that I guess? xD


RE: Player age - Coruja - 09-16-2015 09:01 AM

you can compare the current time with ACCOUNT.FIRSTCONNECTDATE

something like this
Code:
[FUNCTION AccountAge]
ARGS=<EXPLODE /., <ACCOUNT.FIRSTCONNECTDATE>>
LOCAL.Timestamp=<SERV.RTICKS.FROMTIME <ARGV0>,<ARGV1>,<ARGV2>,<ARGV3>,<ARGV4>,<ARGV5>>
LOCAL.Timestamp=<eval <SERV.RTICKS>-<LOCAL.Timestamp>>
//add here something to format <LOCAL.Timestamp> into a readable value (eg: 1 month, 8 days, etc)
return <LOCAL.Timestamp>

or if you want make the timer count only when the account is online, this value is already stored in <ACCOUNT.TOTALCONNECTTIME> (in minutes). You just need to read this value and format it, since it makes more sense show that an account have an age of "4hr 2min" instead "14520 minutes"


RE: Player age - Leonidas - 09-16-2015 09:12 AM

Thanks man, works perfectly!