People can’t connect from other networks to my server, i can even with my mobile phone in house connect to my server. Do someone knows why?
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Server : MonoBehaviour {
//The ip adress
public string IP;
//the port
public int Port;
//admin
public bool admin;
//first
public bool First;
//user
public bool User;
//username admin
private string admin_password;
//username admin
private string admin_username;
//username
public string username;
//password
public string password;
//list with username's
public List<string> usernames;
//list with password's
public List<string> passwords;
//list with emails
public List<string> emails;
//network view
public NetworkView networkview;
// Use this for initialization
void Start () {
First = true;
IP = "NOTFORTHISFORUM";
Port = 25001;
admin_username = "NOTFORTHISFORUM";
admin_password = "NOTFORTHISFORUM";
username = "";
password = "";
usernames.Add("henk");
passwords.Add ("henk");
}
// Update is called once per frame
void Update () {
}
void OnGUI(){
//when the program is launched for the first time
if(First == true){
//username typefield
username = GUI.TextArea(new Rect(0, 0, Screen.width/4, Screen.height/10), username);
//password typefield
password = GUI.TextArea(new Rect(0, Screen.height/4, Screen.width/4, Screen.height/10), password);
//login button for the admin
if(GUI.Button(new Rect(0, Screen.height/10 * 8, Screen.width/6, Screen.height/6), "Log in as Admin")){
//when the username and password are equil to the username field and passwordfield
if(username == admin_username && password == admin_password){
//the player is a admin
admin = true;
//the first launch is false
First = false;
//it will start a server
Network.InitializeServer(50, Port);
}
}
if(GUI.Button(new Rect(0, Screen.height /10*6, Screen.width/6, Screen.height/6), "Go to User login")){
Network.Connect(IP, Port);
User = true;
First = false;
}
}
//when the player is the admin
if(admin == true){
//it wil show in the box the number of connections
GUI.Box(new Rect(0, 0, Screen.width, Screen.height), " " + Network.connections.Length);
}
//when the player is a user
if(User == true){
//this is the username type field
username = GUI.TextArea(new Rect(0, 0, Screen.width/4, Screen.height/6), username);
//password typer field
password = GUI.TextArea(new Rect(0, Screen.height/4 * 2, Screen.width/6, Screen.height/6), password);
NetworkPlayer player;
player = Network.player;
if(GUI.Button(new Rect(0, Screen.height/10 * 8, Screen.width/6, Screen.height/6), "Log in as Admin")){
networkview.RPC("Login", RPCMode.Server, username, password, player);
}
}
}
[RPC]
void Login(string Username, string Password, NetworkPlayer Player)
{
if(Network.isServer)
{
for(int i = 0; i < usernames.Count; i++){
if(Username == usernames[i]){
if(Password == passwords[i]){
networkview.RPC("LoadLevel", Player);
}
}
}
}
}
[RPC]
void LoadLevel(){
if(Network.isClient)
{
if(Application.loadedLevel == 0)
{
Application.LoadLevel(1);
}
}
}
}