Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges