Solved CanClientLogin hook

Discussion in 'Hurtworld Development' started by Reneb, Dec 13, 2015.

  1. Hey, can we maybe get a "canclientlogin"?
    like somewhere in uLink_OnPlayerConnected
    maybe after the STEAM Auth Ticket failed basic validation?
     
  2. you think this:
    • OnPlayerConnected(PlayerIdentity identity, uLink.NetworkPlayer player)
     
  3. Wulf

    Wulf Community Admin

    @Reneb, I'll take a look.

    That isn't for the same purpose as what he is requesting.
     
  4. Wulf

    Wulf Community Admin

    Implemented this locally, which it will most likely be as shown below.
    Code:
    CanClientLogin(PlayerSession session)
    Should be ready for the next update that is coming out soon.
     
  5. I just want to share a comment, the code below works as expected. However, the client does not get the message and loading screen hangs up.
    Code:
      bool CanClientLogin(PlayerSession session)
      {
      return session.IsAdmin;
      }
    
     
  6. Wulf

    Wulf Community Admin

    The client may still need to be kicked. I haven't tested the hook much, as I currently can't use the client due to EAC.
     
  7. I tested this code - works perfect!
    Code:
      bool CanClientLogin(PlayerSession session)
      {
        if (!session.IsAdmin)
        {
          GameManager.Instance.KickPlayer(session.SteamId.ToString(), "Only admins allowed");
          return false;
        }
        return true;
      }
    
     
  8. Wulf

    Wulf Community Admin

    I'd use GameManager.Instance.DisconnectPlayerSync (I think that's it) instead so that it doesn't show messages to everyone that they were kicked.
     
  9. Unfortunately, this method hang ups client. I check it too... =(
     
  10. See now I can get it to kick me during login, but I can't get it to work with GameManager.Instance.DisconnectPlayerSync.

    This is the code I wrote to try and make it simple.

    Code:
    static string kickReason = "Sorry, the maximum number of players are connected!";
    Kick:
    Code:
    void CanClientLogin(PlayerSession session)
            {
                GameManager instance = Singleton<GameManager>.Instance;
                if (instance == null) return;
                instance.KickPlayer(session.SteamId.ToString(), kickReason);
                return;
            }
    
    DisconnectPlayerSync:
    Code:
    void CanClientLogin(PlayerSession session)
            {
                GameManager instance = Singleton<GameManager>.Instance;
                if (instance == null) return;
                instance.DisconnectPlayerSync(session.Player, kickReason);
                return;
            }
    Kick will kick me, DisconnectPlayerSync will just allow me to keep loading in to the game.
    [DOUBLEPOST=1450762452][/DOUBLEPOST]Yea looks like our only option right now is to kick the client. DisconnectPlayerSync seems to hang the client at the connecting screen until they quit through console.