public LimitsGUI() { ErrorGUIStyle.normal.textColor = new Color(255f, 0f, 0f); CaptainStyle.alignment = TextAnchor.MiddleCenter; CaptainStyle.normal.textColor = PLPlayer.GetClassColorFromID(0); CaptainStyle.fixedWidth = 100f; CaptainStyle.clipping = TextClipping.Clip; PilotStyle.alignment = TextAnchor.MiddleCenter; PilotStyle.normal.textColor = PLPlayer.GetClassColorFromID(1); PilotStyle.fixedWidth = 100f; PilotStyle.clipping = TextClipping.Clip; ScienceStyle.alignment = TextAnchor.MiddleCenter; ScienceStyle.normal.textColor = PLPlayer.GetClassColorFromID(2); ScienceStyle.fixedWidth = 100f; ScienceStyle.clipping = TextClipping.Clip; WeaponsStyle.alignment = TextAnchor.MiddleCenter; WeaponsStyle.normal.textColor = PLPlayer.GetClassColorFromID(3); WeaponsStyle.fixedWidth = 100f; WeaponsStyle.clipping = TextClipping.Clip; EngineerStyle.alignment = TextAnchor.MiddleCenter; EngineerStyle.normal.textColor = PLPlayer.GetClassColorFromID(4); EngineerStyle.fixedWidth = 100f; EngineerStyle.clipping = TextClipping.Clip; }
private static bool Prefix(PLServer __instance, ref int playerID, ref int classID, PhotonMessageInfo pmi) { //runs vanilla if client isn't hosting if (!PhotonNetwork.isMasterClient) { return(true); } //fails if client not trying to be class -1 through 4 if (classID < -1 || classID > 4) { return(false); } //Protect Players from bad actors changing other player's classes. PLPlayer playerForPhotonPlayer = PLServer.GetPlayerForPhotonPlayer(pmi.sender); if (playerForPhotonPlayer != null && playerForPhotonPlayer.GetPlayerID() != playerID) { return(false); } PLPlayer PlayerFromID = __instance.GetPlayerFromPlayerID(playerID); if (PlayerFromID != null) { //stop if player is already in the specified class if (PlayerFromID.GetClassID() == classID) { return(false); } Global.Generateplayercount(); if (CanJoinClass(classID)) { //sends the classchangemessage, sets the player to the class id PlayerFromID.SetClassID(classID); AccessTools.Method(__instance.GetType(), "ClassChangeMessage", null, null).Invoke(__instance, new object[] { PlayerFromID.GetPlayerName(false), classID }); } else //Couldn't become role, send available options. { string options = ""; for (int classid = 0; classid < 5; classid++) { if (CanJoinClass(classid)) { options += $"{PLPlayer.GetClassNameFromID(classid)}\n"; } } if (string.IsNullOrEmpty(options)) { Messaging.Centerprint("There are no slots available. Ask the host to change this or leave.", PlayerFromID, "ROL", PLPlayer.GetClassColorFromID(classID), EWarningType.E_NORMAL); Messaging.Notification($"Player {PlayerFromID.GetPlayerName()} Is trying to join as {PLPlayer.GetClassNameFromID(classID)}. There are no Roles available."); } else { Messaging.Centerprint("That slot is full, choose another one. options on the left", PlayerFromID, "ROL", PLPlayer.GetClassColorFromID(classID), EWarningType.E_NORMAL); Messaging.Notification(options, PlayerFromID, playerID, 10000 + PLServer.Instance.GetEstimatedServerMs()); Messaging.Notification($"Player {PlayerFromID.GetPlayerName()} Is trying to join as {PLPlayer.GetClassNameFromID(classID)}"); } } } return(false); }