Advertisement
Diamond32_Tutoriales

Untitled

Apr 14th, 2024
840
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. //CAMBIAR VALORES DESDE ADENTRO DE LAS SALAS
  2.         if (PhotonNetwork.InRoom)
  3.         {
  4.             Hashtable newdata = PhotonNetwork.CurrentRoom.CustomProperties;
  5.  
  6.             newdata["HOLA"] = 3000;
  7.  
  8.             PhotonNetwork.CurrentRoom.SetCustomProperties(newdata);
  9.         }
  10.  
  11.  
  12. //CREAR SALA Y ASIGNAR CUSTOMS PROPERTIES
  13. RoomOptions roomOptions = new RoomOptions();
  14. roomOptions.MaxPlayers = 5;
  15. roomOptions.IsVisible = true;
  16. roomOptions.IsOpen = true;
  17.  
  18. Hashtable roomSettings = new Hashtable();
  19. roomSettings["HOLA"] = 100;
  20.  
  21. roomOptions.CustomRoomProperties = roomSettings;
  22. roomOptions.CustomRoomPropertiesForLobby = new string[] { "HOLA" };
  23.  
  24. string roomName = "Room" + (Random.Range(10000, 99999)).ToString();
  25.  
  26. PhotonNetwork.JoinRandomOrCreateRoom(null, 0, MatchmakingMode.FillRoom, TypedLobby.Default, null, roomName, roomOptions);
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33. //OBTENER CUSTOMS PROPERTIES DESDE EL ROOMINFO DESDE EL LOBBY
  34.     public RoomInfo info_room;
  35.  
  36.     private void Start()
  37.     {
  38.         Hashtable customs = info_room.CustomProperties;
  39.  
  40.         if (customs.ContainsKey("HOLA"))
  41.         {
  42. #if UNITY_EDITOR
  43.             Debug.Log(customs["HOLA"]);
  44. #endif
  45.             GetComponentInChildren<TextMeshProUGUI>().text = "Room: " + info_room.Name + " | Players: " + info_room.PlayerCount + "/" + info_room.MaxPlayers + " | VALOR: " + (int)customs["HOLA"];
  46.         }
  47.         else
  48.         {
  49.             GetComponentInChildren<TextMeshProUGUI>().text = "Room: " + info_room.Name + " | Players: " + info_room.PlayerCount + "/" + info_room.MaxPlayers;
  50.         }
  51.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement