Hello @Wulf! Why with latest update hook broken? OnPlayerDisconnected returning null!
Solved Identity returning null in OnPlayerDisconnected (pirated servers, unsupported)
Discussion in 'Hurtworld Development' started by SannyOK, Dec 14, 2015.
-
Wulf Community Admin
How is it returning null? I can't really tell you what is wrong without details of what you are doing.
-
For example:
void OnPlayerDisconnected(PlayerIdentity player)
{
Debug.Log(player.Name)
}
Later it was returning PlayerIdentity, now - null.so the code in body not working and creating errors. -
Wulf Community Admin
-
Code:
[HookMethod("OnPlayerDisconnected")] void OnPlayerDisconnected(PlayerIdentity player) { if (player.IsAdmin) { ulong playerID = player.SteamId.m_SteamID; if (!adminToggle.ContainsKey(playerID)) return; adminToggle[playerID] = false; return; } }
-
Wulf Community Admin
Also, you don't need [HookMethod("OnPlayerDisconnected")] and you can get the Steam ID with player.SteamId, you don't need m_SteamID. -
Hi, same problems
void OnPlayerDisconnected(PlayerIdentity player)
{
Interface.Oxide.LogDebug(player.Name);
}
Code:10:12 PM [Debug] at Oxide.Plugins.Tested.OnPlayerDisconnected (.PlayerIdentity player) [0x00000] in <filename unknown>:0 at Oxide.Plugins.Tested.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0 at Oxide.Plugins.CSharpPlugin.InvokeMethod (System.Reflection.MethodInfo method, System.Object[] args) [0x00000] in <filename unknown>:0 at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0 at Oxide.Core.Plugins.Plugin.CallHook (System.String hookname, System.Object[] args) [0x00000] in <filename unknown>:0
-
-
Wulf Community Admin
[DOUBLEPOST=1450160267][/DOUBLEPOST] -
-
Wulf Community Admin
-
-
Wulf Community Admin
-
Maybe better to fix some problems with hook? -
Wulf Community Admin
As I said previously as well, the hook should be fixed in the upcoming snapshot. -
-
Nothing changed
Code:void OnPlayerDisconnected(PlayerIdentity identity, uLink.NetworkPlayer player) { Interface.Oxide.LogDebug(identity.SteamId.ToString()); }
Code:void OnPlayerDisconnected(PlayerIdentity identity, uLink.NetworkPlayer player) { if (identity != null) Debug.Log("Work!"); }
Attached Files:
-
-
Tried again and nothing...
-
Wulf Community Admin
I can't reproduce it. With my tests the identity is working 100%. All I can suggest is making sure you are using Oxide 2.0.1637+ and to do some null checks. We don't provide the identity, we just pass it along.
Code:void OnPlayerConnected(PlayerIdentity identity) => Puts(identity.Name + " " + identity.SteamId); void OnPlayerDisconnected(PlayerIdentity identity) => Puts(identity.Name + " " + identity.SteamId);
-
I don't know...
Code:void OnPlayerDisconnected(PlayerIdentity identity) => Puts(identity.Name + " " + identity.SteamId);
Code:void OnPlayerDisconnected(PlayerIdentity identity, uLink.NetworkPlayer player) { PlayerIdentity testPlayer = GameManager.GetPlayerEntity(player).GetComponent<PlayerIdentity>(); if (testPlayer != null) Debug.Log(testPlayer.Name + " " + testPlayer.SteamId); else Debug.Log("uLink Player: " + player.ToString()); }
Attached Files:
-