To get through a server with a password, how would I go about changing the requestdeny to an approve?
Code:
private void OnConnectionRequest(ConnectionRequestEvent e)
{
ConnectionRequest request = e.Request;
if (!Game.HasLoaded && ((e.Connection == null) || !e.Connection.IsServer))
{
request.Deny(ConnectionError.ServerNotReady);
}
else if ((e.Connection != null) && e.Connection.IsServer)
{
ConnectionLoginData loginData = new ConnectionLoginData {
Version = GameInfo.Version,
PlayerName = User.Name,
PlayerId = User.SteamID
};
this.ServerPlayer = Player.Local;
this.ServerPlayer.Id = loginData.PlayerId;
this.ServerPlayer.Connection = Connection.Server;
this.ServerPlayer.SessionId = Connection.Server.SessionId;
ConnectionApprovedData approvedData = this.GetApprovedData(loginData);
this._pendingConnections[e.Connection.Endpoint] = approvedData;
PlayerLoginEvent theEvent = new PlayerLoginEvent(approvedData.LoginData.PlayerId, e.Error, approvedData);
EventManager.CallEvent(theEvent);
}
else
{
e.Error = this.ProcessConnectionRequest(e.Request);
ConnectionApprovedData data3 = this.GetApprovedData(request.LoginData);
PlayerLoginEvent event3 = new PlayerLoginEvent(data3.LoginData.PlayerId, e.Error, data3);
EventManager.CallEvent(event3);
if (event3.Error == ConnectionError.NoError)
{
this._pendingConnections[request.Endpoint] = event3.ApprovedData;
request.Approve(data3);
}
else
{
request.Deny(e.Error);
e.Cancel();
}
}
}