I think this should work, but it does'nt.Code:[ChatCommand("test")] void FindPlayer(BasePlayer player) { var targetPlayer = BasePlayer.Find("steamid"); if (targetPlayer.IsConnected()) { //targetPlayer is online } else { //targetPlayer is offline } }
Code:[Debug] at Oxide.Plugins.ExtraPlugins.FindPlayer (.BasePlayer player) [0x00000] in <filename unknown>:0 at Oxide.Plugins.ExtraPlugins.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0 at Oxide.Plugins.CSharpPlugin.InvokeMethod (HookMethod 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 name, System.Object[] args) [0x00000] in <filename unknown>:0
Solved BasePlayer.Find error
Discussion in 'Rust Development' started by Reynostrum, Jun 11, 2016.
-
Code:
public static BasePlayer Find(string strNameOrIDOrIP)
Code:var targetPlayer = BasePlayer.Find("Reynostrum"); var targetPlayer = BasePlayer.Find("12345678987654321"); var targetPlayer = BasePlayer.Find("127.0.0.1");
-
Sorry, I don't follow, I am new with C#
Code:var targetPlayer = BasePlayer.Find("12345678987654321");
-
It will return null if nothing found, so make sure it's not null
-
Code:
void FindPlayer(BasePlayer player) { var targetPlayer = BasePlayer.Find("steamid"); if (targetPlayer != null) { if(targetPlayer.IsConnected()) { //online } else { //offline } } else { //offline } }
-
Really if it's not null, they're online