Is there an easy/efficient way of getting BasePlayer info when all you have is their 7656xxxxxxxxxxx SteamID?
CSharp.
Thanks!
Solved Getting BasePlayer from Steam ID (7656 format)?
Discussion in 'Rust Development' started by Rusty, Jan 9, 2017.
-
Wulf Community Admin
Using Rust's code:
Code:var player = BasePlayer.FindByID(ulong userId);
Code:var player = RustCore.FindPlayerById(string userId);
Code:var basePlayer = players.FindPlayerById(string userId)?.Object as BasePlayer;
-
Boss. Thx.
-
More to the point, and a n00b question here, but what does the internals of BasePlayer look like, I am writing my first plugin (well actually a patch for NoEscape plugin to be precise) and I wanted to extract the players SteamID, but I have no idea what BasePlayer objects look like.
-
Wulf Community Admin
-
Alright I'll give this a go when I am back at my Windows box tommorow...
-
Wulf Community Admin
-
Mono *shudders*, that won't be going on my Mac any time soon. It's all good I have other headaches to deal with concerning Steam OpenID for this evening
-
Apologies for a quick follow up point, but I came across this thread while looking for information on this topic, and figured I'd help the next poor sod.
BasePlayer.FindByID(ulong userId) only works for players actively logged into the server. It doesn't list anyone who's logged off.
BasePlayer.sleepingPlayerList.Find(o => o.userID == userId) should work for finding sleepers who have not died. Once they've been eaten by a bear, etc. they're pulled off the sleepingPlayerList.
The Oxide Colvalance library give us
Interface.Oxide.GetLibrary<Covalence>().Players.FindPlayerById("userIdAsString") for anyone who's ever connected, but this is not a BasePlayer object but an IPlayer with different methods. You also need a using Oxide.Core.Libraries.Covalence; command. Not sure of the scope of this function.
Found some of this on Getting "BasePlayer of some disconnected?", so thanks to Wulf and those people. -
Wulf Community Admin