Player alive time?
Discussion in 'Rust Development' started by Rusty, Jun 12, 2016.
-
Wulf Community Admin
You'd need to start a timer, track, and store using OnPlayerInit or OnPlayerConnected.
-
I was trying to avoid that .. couldnt find anything in dll, even though i know theres something because of kill screen: you were alive for xx:xx:xx
-
Wulf Community Admin
Mmm, I believe the LifeStory may keep something in there, but unsure. Otherwise there are plugins that handle it too. -
example
This is only for current life, which is what you would see on the death screen, not a total time playedCode:using System.Reflection; FieldInfo pLifeStory = typeof(BasePlayer).GetField("lifeStory", (BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic)); [ChatCommand("alivetime")] private void cmdAliveTime(BasePlayer player, string command, string[] args) { PlayerLifeStory story = (PlayerLifeStory)pLifeStory.GetValue(player); if (story != null) { var time = story.secondsAlive; Puts(time.ToString()); } } -
Damn..thats good mate.
