Search Unity

[Solved]How to check match password.

Discussion in 'Multiplayer' started by lesmasamuray, Aug 2, 2018.

  1. lesmasamuray

    lesmasamuray

    Joined:
    Dec 26, 2015
    Posts:
    2
    Hello folks!

    Just wanna know, how do i check if the match password is correct before joining it?
    But i can't find the password option into "match", theres only a bool that returns if the match as or not a password...

    I'm trying to accomplish something like this.

    Thanks!

    Code (CSharp):
    1.  
    2. public void JoinRoom()
    3.  {
    4.      if (match.isPrivate)
    5.      {
    6.          // Does have password
    7.          // Check password
    8.          string tempPassword = password.text;
    9.          if ( match.password == tempPassword)
    10.          {
    11.              // Password is corect
    12.              // Join Room Code here...
    13.          }
    14.          else
    15.          {
    16.              // Password is wrong!
    17.              // Incorrect password code here...
    18.          }
    19.      }
    20.      else
    21.      {
    22.          // Doesn't have password
    23.          // Join room code here...
    24.      }
    25.  }
    26.  
     
  2. lesmasamuray

    lesmasamuray

    Joined:
    Dec 26, 2015
    Posts:
    2
    Figured it out.

    Add this to your NetworkLobbyManager:

    Code (CSharp):
    1. public override void OnMatchJoined(bool success, string extendedInfo, MatchInfo matchInfo)
    2.     {
    3.         base.OnMatchJoined(success, extendedInfo, matchInfo);
    4.         if ( !success )
    5.         {
    6.             // Conection error, incorrect password included
    7.             // Show incorrect password
    8.         }
    9.     }
     
unityunity