The record is not deleted, nothing has changed in the code.
Problem with call OnPlayerDisconnected
Also a problem with OnPlayerInit()Code:void OnPlayerDisconnected(BasePlayer player) { Sql.Insert(Core.Database.Sql.Builder.Append("DELETE FROM stats_player_online WHERE id = @0", player.UserIDString), _mySqlConnection); }
I to work through CanClientLogin(), which is very inconvenientCode:void OnPlayerInit(BasePlayer player) { string normalName = player.displayName; int ping = Network.Net.sv.GetAveragePing(player.net.connection); Sql.Insert(Core.Database.Sql.Builder.Append( "INSERT IGNORE INTO stats_player_online (id, name, ip, ping, time) VALUES (@0, @1, @2, @3, @4) ON DUPLICATE KEY UPDATE name = @1, ip = @2, ping = @3", player.userID, normalName, player.net.connection.ipaddress, ping, ConvertToUnixTime(DateTime.Now)), _mySqlConnection); if (loginTime.ContainsKey(player)) OnPlayerDisconnected(player); loginTime.Add(player, (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds); }
The question is why something is constantly changing ?????!
Fixed OnPlayerDisconnected hook not being called
Discussion in 'Rust Development' started by Cerber0s, Oct 2, 2017.
-
Which Oxide version are you on?
-
Those hooks works fine, so problem is in your code.
-
Wulf Community Admin
It sounds like you're on build 3505 which was promptly replaced with 3508 and higher builds where the issue was resolved.
-
alternatively you could try:
void OnUserDisconnected(IPlayer player)
void OnUserConnected(IPlayer player)
They are not documented on Oxide API for Rust, but seem to be working in a plugin I am developing.
I convert the IPlayer to baseplayer with:
BasePlayer Bplayer = player.Object as BasePlayer;
I do wish there was a decomposition document that showed what each of these objects contained. The lack of documentation leads to a lot of hunting for the right object and/or function to do a task. -
Wulf Community Admin