Getting player connection time in seconds?Solved

Hello everyone, I came across a problem with getting the time in seconds of a player, the essence:


This used to work correctly

TimeSpan.FromSeconds(player.Connection.GetSecondsConnected());​


It getting the player time from the moment he connected to the server 00:00:00 and counter was increment.

But recently, I noticed that this counter began to display the original value with a minus of -00:50:00 and count it -00:49:59 and so on.

I tried to change this time in such a way:

private void OnPlayerInit(BasePlayer player)
        {
            player.Connection.connectionTime = (double)0.0d;
        }

But it did not give me a result. This method removes the player’s counter with a minus, but does not assign 0 but makes huge numbers, about 60,000 seconds.

Sorry for my bad English, I tried to clearly explain the problem.

There is speculation that it broke after one of the Umod updates.
What broke exactly? The method you are using to get the time is not something provided by Oxide. If the hook is being called (you can test with a simple debug message), what Oxide provides is working.
This method is in Oxide, I want to get the player’s time from the moment of his enter to the server and until his leave to record how much he played on the time server. Previously, using this method it turned out to do it, now something is working wrong.
Or can you tell me how I can do this now? without crutches.
Thank you in advance.
Did you verify if the hook is called? There are other hooks such as OnPlayerConnected you can use as well. The hook (OnPlayerInit) is from Oxide, the method (player.Connection.connectionTime) is from Rust.
I’m writing about this method (player.Connection.connectionTime) used to work fine, now it writes incomprehensible numbers, I am trying to implement my plugin through this method.
5b6db91224b34.png DEUS
I’m writing about this method (player.Connection.connectionTime) used to work fine, now it writes incomprehensible numbers, I am trying to implement my plugin through this method.

It may not be set anymore within Rust, set at a later point, or entirely different format. I'm not really familiar with it, or what may have changed with that in Rust.

I understand you, I would like it to appear again in the future =) thanks.
Have you tried with BasePlayer.net.connection.GetSecondsConnected()? Shouldn't be any different than without the net.* though.

The GetSecondsConnected() method returns: (float)(TimeEx.realtimeSinceStartup - this.connectionTime)
Also works
https://i.imgur.com/FdIOrdN.png

Merged post

Method player.secondsConnected also works incorrectly, it only considers time when it goes out of range with a minus
just doing the 'status' command and seeing player connected times can be wrong, sometimes displaying negitive numbers, it has been broken for a few updates now... if this has anything todo with the 'methods'/functions maybe?
Locked automatically