• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed May 10, 2013 at 07:44 AM by Fattie for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by TheIncognito · May 10, 2013 at 03:04 AM · errormultiplayergame

Multiplayer Script error

I am a novice at Unity, and was making a Javascript to make a direct connect lobby system for a game i'm working on. But keep getting 2 errors: No appropriate version of 'UnityEngine.Network.InitializeServer' for the argument list '(int, String)' was found.

and Cannot Convert 'int' to 'String'

how can i fix these?

 #pragma strict
 
 var remoteIPadress = "127.0.0.1";
 var remotePort = "25000";
 var listenPort = "25000";
 
 var useNAT = true;
 
 var myIP = "";
 var myPort = "";
 
 var MaxPlayer = 32;
 
 
 function OnConnectedToServer ()
 {
     
 }
 
 function OnDisconnectedToServer ()
 {
     
 }
 
 function OnGUI ()
 {
     if(Network.peerType == NetworkPeerType.Disconnected)
     {
         if(GUI.Button(Rect(5,5,60,30),"Connect"))
         {
             Network.useNat = useNAT;
             Network.Connect(remoteIPadress, remotePort);
         }
         if(GUI.Button(Rect(5, 40, 60, 30),"StartServer"))
         {
             Network.useNat = useNAT;
             Network.InitializeServer(MaxPlayer,listenPort);
         }
         
         remoteIPadress = GUI.TextField(Rect(5, 75, 60, 30),remoteIPadress);
         remotePort = parseInt(GUI.TextField(Rect(5, 10, 60, 30),remoteIPadress));
     
     }
     else
     {
         if(GUI.Button(Rect(5,5,60,30),"Disconnect"))
         {
             Network.Disconnect(200);
         }
     }
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by ByteSheep · May 10, 2013 at 03:07 AM

http://docs.unity3d.com/Documentation/ScriptReference/Network.InitializeServer.html

Network.InitializeServer() requires the first two parameters to be integer values.
In your code the second value (listenPort) is a string, so you need to change the declaration to:

 var listenPort = 25000;
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TheIncognito · May 10, 2013 at 04:57 AM 0
Share

1 error down, 1 to go,

Line 41: Cannot convert int to string. must...solve...on...own

avatar image ByteSheep · May 10, 2013 at 05:00 AM 0
Share

Again the same problem - your remotePort variable is declared as a string, but on line 41 you are trying to assign an int value to it. So again the new line would look like:

 var remotePort = 25000;
avatar image TheIncognito · May 10, 2013 at 05:04 AM 0
Share

Thanks dood, I should work on this more often :D

avatar image
0

Answer by small-U · May 10, 2013 at 03:49 AM

 static function InitializeServer (connections : int, listenPort : int, useNat : bool) : NetworkConnectionError
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Error CS1502 Help! 1 Answer

Error CS1502 help! 1 Answer

Error UCE0001 ";"Expected 2 Answers

2D bullet script errors. 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges