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 /
avatar image
0
Question by R1pnd1p · Oct 23, 2013 at 01:39 AM · listphotonrpctostring

c# basics question.

im trying to set a PhotonPlayer variable .tostring, but its saying im not doing it in the right format. heres the code.

            void OnPhotonPlayerConnected (PhotonPlayer netPlayer)
     {
         //Add the player to the list. This is executed on the server.
         
         photonView.RPC("AddPlayerToList", PhotonTargets.AllBuffered, netPlayer);
     }
     
     
     void OnPhotonPlayerDisconnected (PhotonPlayer netPlayer)
     {
         //Remove the player from the list. This is executed on the server.
         
         photonView.RPC("RemovePlayerFromList", PhotonTargets.AllBuffered, netPlayer);
     }
     
     
     [RPC]
     void AddPlayerToList (PhotonPlayer nPlayer)
     {
         //Create a new entry in the PlayerList and supply the
         //player's network ID as the first entry.
         joinedlist = true;
         Playerdataclas capture = new Playerdataclas();
         
         capture.networkPlayer = int.Parse(nPlayer.ToString());
         
         PlayerList.Add(capture);
     }
     
 
 


the variable for the list is

 public List<Playerdataclas> PlayerList = new List<Playerdataclas>();


its telling me im using a wrong format for the string :/ i dont get what i have to do.

Comment
Add comment · Show 3
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 DaveA · Oct 23, 2013 at 01:48 AM 0
Share

Please paste in the exact error message

avatar image R1pnd1p · Oct 23, 2013 at 02:08 AM 0
Share

FormatException: Input string was not in the correct format System.Int32.Parse (System.String s) (at /Applications/buildAgent/work/c514da0c8183631c/mcs/class/corlib/System/Int32.cs:629) playerdb.AddPlayerToList (.PhotonPlayer nPlayer) (at Assets/Scripts/playerdb.cs:117) * System.Reflection.$$anonymous$$ono$$anonymous$$ethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/c514da0c8183631c/mcs/class/corlib/System.Reflection/$$anonymous$$ono$$anonymous$$ethod.cs:222) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.$$anonymous$$ono$$anonymous$$ethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/c514da0c8183631c/mcs/class/corlib/System.Reflection/$$anonymous$$ono$$anonymous$$ethod.cs:232) System.Reflection.$$anonymous$$ethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Applications/buildAgent/work/c514da0c8183631c/mcs/class/corlib/System.Reflection/$$anonymous$$ethodBase.cs:115) NetworkingPeer.ExecuteRPC (ExitGames.Client.Photon.Hashtable rpcData, .PhotonPlayer sender) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1778) NetworkingPeer.RPC (.PhotonView view, System.String methodName, PhotonTargets target, System.Object[] parameters) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2657) PhotonNetwork.RPC (.PhotonView view, System.String methodName, PhotonTargets target, System.Object[] parameters) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:1891) PhotonView.RPC (System.String methodName, PhotonTargets target, System.Object[] parameters) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:253) playerdb.OnPhotonPlayerConnected (.PhotonPlayer netPlayer) (at Assets/Scripts/playerdb.cs:97) UnityEngine.GameObject:Send$$anonymous$$essage(String, Object, Send$$anonymous$$essageOptions) NetworkingPeer:Send$$anonymous$$ono$$anonymous$$essage(PhotonNetworking$$anonymous$$essage, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1605) NetworkingPeer:OnEvent(EventData) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1464) ExitGames.Client.Photon.PeerBase:Deserialize$$anonymous$$essageAndCallback(Byte[]) ExitGames.Client.Photon.EnetPeer:DispatchInco$$anonymous$$gCommands() ExitGames.Client.Photon.PhotonPeer:DispatchInco$$anonymous$$gCommands() PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:76)

i highlited where the issue is with stars *

avatar image rutter · Oct 23, 2013 at 02:25 AM 0
Share

int.Parse() expects a string that looks like an integer, such as "21" or "42".

Have you checked what you're actually getting from nPlayer.ToString()? A simple Debug.Log() (or a peek in $$anonymous$$ono's visual debugger) can often work wonders.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

17 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 avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

C# list bug using addRange after call toString method only on unity ios 2 Answers

Photon network doesn't call RPC/OnPhotonSerializeView 1 Answer

Using RPC to send a List 1 Answer

List clients connected? 2 Answers


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