1. Hiya, I'd like to get players IP address on connection but am unsure if this is possible. I had a look at a couple of other plugins that use player.Address but I gsther this is an IPlayer property rather than BasePlayer?

    I'd like to use with:

    void OnPlayerInit(BasePlayer player) {}

    Thanks in advance for any help with this,


    Tony.
     
  2. Wulf

    Wulf Community Admin

    IPlayer is an interface from Oxide, to use IPlayer, you'd need to use a hook intended for use with that or look up the IPlayer. You can get the address from the BasePlayer (Rust object) the same way Oxide does to set it in the IPlayer.Address field (look at our GitHub repo). You can also use an earlier hook if you wants to for Rust to get the address if you wanted to as well, but it wouldn't be from the BasePlayer.
     
  3. Found these:

    /// <summary>
    /// Gets the player's IP address
    /// </summary>
    public string Address(Network.Connection connection) => Regex.Replace(connection.ipaddress, ipPattern, "");
    /// <summary>
    /// Gets the player's IP address
    /// </summary>
    public string Address(BasePlayer player) => player?.net?.connection != null ? Address(player.net.connection) : null;


    Not sure how I can use that, if these are what you were referring to?
     
  4. Code:
    string playerAddress = player.net.connection.ipaddress.Split(':')[0];
     
  5. That worked perfectly - thanks for you help :)