Is that possible to get how long player lived, before he died in this action event? if yes, then how?
C# OnEntityDeath, get how long player lived.
Discussion in 'Rust Development' started by Visagalis, Aug 14, 2015.
-
Wulf Community Admin
You'd most likely need to create a timer and count from the time they spawned till the time they died, then store that somewhere if needed.
-
-
Wulf Community Admin
-
1) Save timestamp_one on spawn
2) Save timestamp_two on die
3) Time lived: timestamp_two - timestamp_one;
[DOUBLEPOST=1439569912][/DOUBLEPOST]Also u can get (PlayerLifeStory) lifeStory from player that have: secondsAlive, metersWalked, metersRun, secondsSleeping. -
BasePlayer.lifeStory.secondsAlive, but it is a private field, you will only be able to get it in a c# plugin via reflection...
-
-
Reflexion allows you to access private fields and method in classes, it's a .NET quirk... the process needs to run at elevated privileges for it to work though.. I assume it would be the case for most servers? not sure...