Advertisement
jasonjohn

Error

Jun 29th, 2014
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. error:
  2. Assets/Scripts/Network/Menu.cs(81,25): error CS0246: The type or namespace name `Player' could not be found. Are you missing a using directive or an assembly reference?
  3.  
  4. using UnityEngine;
  5. using System.Collections;
  6.  
  7. public class Menu : MonoBehaviour {
  8.  
  9. private string CurMenu;
  10. public string Name;
  11. public string MatchName;
  12. public int Players;
  13. // Use this for initialization
  14. void Start () {
  15. CurMenu = "Main";
  16. Name = PlayerPrefs.GetString("PlayerName");
  17. }
  18.  
  19. // Update is called once per frame
  20. void Update () {
  21.  
  22. }
  23.  
  24. void ToMenu(string menu){
  25. CurMenu = menu;
  26. }
  27. void OnGUI(){
  28. if (CurMenu == "Main")
  29. Main();
  30. if (CurMenu == "Host")
  31. Host();
  32. if (CurMenu == "Lobby")
  33. Lobby();
  34. if (CurMenu == "List")
  35. MatchList();
  36. }
  37. private void Main(){
  38.  
  39. Error:(Sending RPC 'Client_PlayerJoined' failed because the number of supplied parameters doesn't match the rpc declaration. Expected 2 but got 3 parameters
  40. .
  41. using UnityEngine;
  42. using System.Collections;
  43. using System.Collections.Generic;
  44.  
  45. public class NetworkManager : MonoBehaviour
  46. {
  47. public string PlayerName;
  48. public string MatchName;
  49. public static NetworkManager Instance;
  50. public List<Player>PlayerList = new List<Player>();
  51. public Player MyPlayer;
  52.  
  53. // Use this for initialization
  54. void Start () {
  55. Instance = this;
  56. DontDestroyOnLoad(gameObject);
  57. }
  58.  
  59. // Update is called once per frame
  60. void Update () {
  61. PlayerName = PlayerPrefs.GetString("PlayerName");
  62.  
  63. }
  64.  
  65. public void StartServer(string ServerName, int MaxPlayers)
  66. {
  67. Network.InitializeSecurity();
  68. Network.InitializeServer (MaxPlayers, 25565, true);
  69. MasterServer.RegisterHost("Tut", ServerName, "");
  70.  
  71. Debug.Log("Started Server");
  72. }
  73. void OnPlayerConnected(NetworkPlayer id)
  74. {
  75. //networkView.RPC ("Server_PlayerJoined", RPCMode.Server, PlayerName, id);
  76. foreach (Player pl in PlayerList)
  77. {
  78. networkView.RPC("Client_PlayerJoined",id,pl.PlayerName, pl.OnlinePlayer);
  79. }
  80. }
  81.  
  82. void OnServerInitialized()
  83. {
  84. Server_PlayerJoined (PlayerName, Network.player);
  85. }
  86.  
  87. void OnConnectedToServer()
  88. {
  89. networkView.RPC ("Server_PlayerJoined", RPCMode.All, PlayerName, Network.player);
  90. }
  91.  
  92. [RPC]
  93. public void Server_PlayerJoined(string Username,NetworkPlayer id)
  94. {
  95. networkView.RPC("Client_PlayerJoined", RPCMode.All,PlayerName,Username, id);
  96. }
  97.  
  98. [RPC]
  99. public void Client_PlayerJoined(string Username,NetworkPlayer id)
  100. {
  101. Player temp = new Player();
  102. temp.PlayerName = Username;
  103. temp.OnlinePlayer = id;
  104. PlayerList.Add(temp);
  105. if (Network.player == id)
  106. {
  107. MyPlayer = temp;
  108. }
  109. }
  110.  
  111. [System.Serializable]
  112. public class Player{
  113. public string PlayerName;
  114. public NetworkPlayer OnlinePlayer;
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement