private static void Postfix(NicknameSync __instance) { if (__instance.hub.characterClassManager.IsHost || string.IsNullOrEmpty(__instance.hub.characterClassManager.UserId)) { return; } if (!API.Features.Player.Dictionary.TryGetValue(__instance.gameObject, out API.Features.Player player)) { player = new API.Features.Player(ReferenceHub.GetHub(__instance.gameObject)); API.Features.Player.Dictionary.Add(__instance.gameObject, player); } API.Features.Log.Debug($"Player {player?.Nickname} ({player?.UserId}) connected with the IP: {player?.IPAddress}"); if (PlayerManager.players.Count >= CustomNetworkManager.slots) { API.Features.Log.Debug($"Server is full!"); } Timing.CallDelayed(0.25f, () => { if (player != null && player.IsMuted) { player.ReferenceHub.characterClassManager.SetDirtyBit(1UL); } }); var ev = new JoinedEventArgs(API.Features.Player.Get(__instance.gameObject)); Player.OnJoined(ev); }
public void OnDestroy() { orig_OnDestroy(); CharacterClassManager player = this.GetComponent <CharacterClassManager>(); NicknameSync name = this.GetComponent <NicknameSync>(); if (string.IsNullOrEmpty(player.UserId) || !player.UserId.Contains('@')) { return; } else { try { Base.Debug("Triggering PlayerLeaveEvent"); PluginManager.TriggerEvent <IEventHandlerPlayerLeave>(new PlayerLeaveEvent(new PheggPlayer(this.gameObject))); } catch (Exception e) { Base.Error($"Error triggering PlayerLeaveEvent: {e.InnerException.ToString()}"); } } if (PlayerManager.players.Count - 1 < 1 && RoundSummary.RoundInProgress()) { PMRoundSummary.RoundFix(); } }
public void OnSCP914Activate(SCP914ActivateEvent ev) { if (!enabled) { return; } object[] inputs = ev.Inputs; Scp914 objectOfType = UnityEngine.Object.FindObjectOfType <Scp914>(); if ((UnityEngine.Object)objectOfType == (UnityEngine.Object)null) { this.plugin.Error("Couldnt find SCP-914"); return; } // string[] strArray = new string[5] { "Very Rough", "Rough", "1 to 1", "Fine", "Very Fine" }; // for (byte index1 = 0; index1 < objectOfType.recipes.Length; ++index1) //item id // { // this.plugin.Debug("==== Recipe for: " + component.availableItems[index1].label + " ===="); // for (byte index2 = 0; index2 < objectOfType.recipes[index1].outputs.Count; ++index2) //knob setting id // { // foreach(sbyte itm in objectOfType.recipes[index1].outputs[index2].outputs) //output item id // { // this.plugin.Debug(strArray[index2] + ": " + (itm == -1 ? "NULL" : component.availableItems[itm].label)); // } // } // } foreach (UnityEngine.Collider collider in inputs) { Pickup component1 = collider.GetComponent <Pickup>(); if ((UnityEngine.Object)component1 == (UnityEngine.Object)null) { NicknameSync component2 = collider.GetComponent <NicknameSync>(); CharacterClassManager component3 = collider.GetComponent <CharacterClassManager>(); PlyMovementSync component4 = collider.GetComponent <PlyMovementSync>(); PlayerStats component5 = collider.GetComponent <PlayerStats>(); if ((UnityEngine.Object)component2 != (UnityEngine.Object)null && (UnityEngine.Object)component3 != (UnityEngine.Object)null && ((UnityEngine.Object)component4 != (UnityEngine.Object)null && (UnityEngine.Object)component5 != (UnityEngine.Object)null) && (UnityEngine.Object)collider.gameObject != (UnityEngine.Object)null) { UnityEngine.GameObject gameObject = collider.gameObject; ServerMod2.API.SmodPlayer player = new ServerMod2.API.SmodPlayer(gameObject); if (player.TeamRole.Team != Smod2.API.Team.SCP && player.TeamRole.Team != Smod2.API.Team.NONE && player.TeamRole.Team != Smod2.API.Team.SPECTATOR) { if (currentonly) { Smod2.API.Item item = player.GetCurrentItem(); doRecipe(item, objectOfType, player, ev.KnobSetting); } else { foreach (Smod2.API.Item item in player.GetInventory()) { doRecipe(item, objectOfType, player, ev.KnobSetting); } } } } } } }
public static void Prefix(NicknameSync __instance, ref string n) { var databasePlayer = __instance.gameObject.GetPlayer().GetDatabasePlayer(); if (databasePlayer == null) { return; } if (!string.IsNullOrEmpty(databasePlayer.CustomNickName) && databasePlayer.CustomNickName != "None") { n = databasePlayer.CustomNickName; } }
public void OnPlayerJoin(PlayerJoinEvent ev) { NicknameSync sync = ((GameObject)ev.Player.GetGameObject()).GetComponent <NicknameSync>(); string name = sync.NetworkmyNick; foreach (string str in bList.Select(x => x = x.ToLower().Trim())) { for (int i = 0; i < Regex.Matches(name.ToLower(), str).Count; i++) { name = Regex.Replace(name, str, new string('-', str.Length), RegexOptions.IgnoreCase); } } sync.UpdateNickname(name); }
private static void Prefix(NicknameSync __instance, ref string n) { try { var player = __instance.GetPlayer(); if (!string.IsNullOrEmpty(player.UserId)) { SynapseController.Server.Events.Player.InvokePlayerJoinEvent(player, ref n); } } catch (Exception e) { SynapseController.Server.Logger.Error($"Synapse-Event: PlayerJoin failed!!\n{e}"); } }
// ReSharper disable once InconsistentNaming public static bool Prefix(NicknameSync __instance, ref string n) { try { var player = __instance.GetPlayer(); if (!string.IsNullOrEmpty(player.UserId)) { Events.InvokePlayerJoinEvent(player, ref n); } } catch (Exception e) { Log.Error($"PlayerJoin Event Error: {e}"); } return(true); }
private static void Prefix(NicknameSync __instance, ref string n) { try { var player = __instance.GetPlayer(); Task.Run(() => { if (!SynapseController.Server.Configs.SynapseConfiguration.DatabaseEnabled) { return; } if (!DatabaseManager.PlayerRepository.ExistGameId(player.UserId)) { var dbo = new PlayerDbo() { GameIdentifier = player.UserId, Name = player.DisplayName, DoNotTrack = player.DoNotTrack, Data = new Dictionary <string, string>() }; DatabaseManager.PlayerRepository.Insert(dbo); } else { var dbo = DatabaseManager.PlayerRepository.FindByGameId(player.UserId); dbo.Name = player.DisplayName; dbo.DoNotTrack = player.DoNotTrack; DatabaseManager.PlayerRepository.Save(dbo); } }); if (!string.IsNullOrEmpty(player.UserId)) { SynapseController.Server.Events.Player.InvokePlayerJoinEvent(player, ref n); } } catch (Exception e) { SynapseController.Server.Logger.Error($"Synapse-Event: PlayerJoin failed!!\n{e}\nStackTrace:\n{e.StackTrace}"); } }
public static void Postfix(NicknameSync __instance) { if (EventPlugin.PlayerJoinEventPatchDisable) { return; } Log.Info($"Player connect: "); if (PlayerManager.players.Count >= CustomNetworkManager.slots) { Log.Info($"Server full"); } try { Timing.CallDelayed(0.25f, () => { foreach (ReferenceHub player in Player.GetHubs()) { if (player.characterClassManager.NetworkMuted) { player.characterClassManager.SetDirtyBit(1ul); } } }); ReferenceHub hub = Player.GetPlayer(__instance.gameObject); if (!string.IsNullOrEmpty(hub.characterClassManager.UserId)) { Events.InvokePlayerJoin(hub); } } catch (Exception e) { Log.Error($"PlayerJoin Event error: {e}"); } }
public static void Postfix(NicknameSync __instance) { if (EventPlugin.PlayerJoinEventPatchDisable) { return; } EventPlugin.ToMultiAdmin($"Player connect: "); if (PlayerManager.players.Count >= CustomNetworkManager.slots) { EventPlugin.ToMultiAdmin($"Server full"); } try { ReferenceHub player = __instance.gameObject.GetPlayer(); Timing.CallDelayed(0.25f, () => { if (player != null && player.IsMuted()) { player.characterClassManager.SetDirtyBit(1UL); } }); if (!string.IsNullOrEmpty(player.characterClassManager.UserId)) { Events.InvokePlayerJoin(player); } } catch (Exception exception) { Log.Error($"PlayerJoinEvent error: {exception}"); } }
private static void NicknameSync_UpdateNickname(On.NicknameSync.orig_UpdateNickname orig, NicknameSync self, string n) { orig(self, n); EventManager.Manager.HandleEvent <IEventHandlerPlayerJoin>(new PlayerJoinEvent(new LabPlayer(self.gameObject))); }
/// <summary> /// Represents a player object which is to be rendered in the OnGUI() call. /// </summary> /// <param name="PlayerGameObject">The GameObject of the player.</param> public ESPPlayerObject(GameObject PlayerGameObject) { ESPPlayerGameObject = PlayerGameObject; playerNicknameSync = ESPPlayerGameObject.transform.GetComponent <NicknameSync>(); playerClassManager = ESPPlayerGameObject.GetComponent <CharacterClassManager>(); }
private void Update() { if (base.isLocalPlayer) { bool flag = false; RaycastHit raycastHit; if (Physics.Raycast(new Ray(this.spectCam.position, this.spectCam.forward), out raycastHit, this.viewRange, this.raycastMask)) { NicknameSync component = raycastHit.transform.GetComponent <NicknameSync>(); if (component != null && !component.isLocalPlayer) { CharacterClassManager component2 = component.GetComponent <CharacterClassManager>(); CharacterClassManager component3 = base.GetComponent <CharacterClassManager>(); flag = true; if (component2.curClass != -1 && !TutorialManager.status) { this.n_text.color = component2.klasy[component2.curClass].classColor; this.n_text.text = component.role.GetColoredRoleString() + "\n"; Text text = this.n_text; text.text += component.myNick; Text text2 = this.n_text; text2.text = text2.text + "\n" + component2.klasy[component2.curClass].fullName; } try { if (component2.curClass >= 0 && component2.klasy[component2.curClass].team == Team.MTF && component3.klasy[component3.curClass].team == Team.MTF) { int num = 0; int num2 = 0; if (component2.curClass == 4 || component2.curClass == 11) { num2 = 200; } else if (component2.curClass == 13) { num2 = 100; } else if (component2.curClass == 12) { num2 = 300; } if (component3.curClass == 4 || component3.curClass == 11) { num = 200; } else if (component3.curClass == 13) { num = 100; } else if (component3.curClass == 12) { num = 300; } Text text3 = this.n_text; text3.text = text3.text + " (" + GameObject.Find("Host").GetComponent <NineTailedFoxUnits>().GetNameById(component2.ntfUnit) + ")\n\n<b>"; num -= component3.ntfUnit; num2 -= component2.ntfUnit; if (num > num2) { Text text4 = this.n_text; text4.text += TranslationReader.Get("Legancy_Interfaces", 0); } else if (num2 > num) { Text text5 = this.n_text; text5.text += TranslationReader.Get("Legancy_Interfaces", 1); } else if (num2 == num) { Text text6 = this.n_text; text6.text += TranslationReader.Get("Legancy_Interfaces", 2); } Text text7 = this.n_text; text7.text += "</b>"; } } catch { MonoBehaviour.print("Error"); } } } this.transparency += Time.deltaTime * (float)((!flag) ? -3 : 3); if (flag) { float max = (this.viewRange - Vector3.Distance(base.transform.position, raycastHit.point)) / this.viewRange; this.transparency = Mathf.Clamp(this.transparency, 0f, max); } this.transparency = Mathf.Clamp01(this.transparency); CanvasRenderer component4 = this.n_text.GetComponent <CanvasRenderer>(); component4.SetAlpha(this.transparency); } }
private void OnGUI() { GUI.Label(new UnityEngine.Rect(10, 30, 500, 30), "Everfree v0.1"); GUI.Label(new UnityEngine.Rect(10, 50, 500, 30), "Debug Trace (ALT): " + (isTrace ? "ON" : "OFF")); GUI.Label(new UnityEngine.Rect(10, 70, 500, 30), "Noclip (MOUSE3): " + (isNoclip ? "ON" : "OFF")); GUI.Label(new UnityEngine.Rect(10, 90, 500, 30), " > NoclipMode [" + (isBlink ? "blink" : "move") + "] (End)"); GUI.Label(new UnityEngine.Rect(10, 110, 500, 30), "+Run Speed: " + (isSpeedhack ? "increased" : "off")); GameObject lp = PlayerManager.localPlayer;// FindLocalPlayer(); PlyMovementSync move = lp.GetComponent <PlyMovementSync>(); move.isGrounded = true; //move.CallCmdSyncData(rot, pos, lp.GetComponent<PlayerInteract>().playerCamera.transform.localRotation.eulerAngles.x); GUI.Label(new UnityEngine.Rect(10, 130, 500, 30), " > eulerAngles.x: " + lp.GetComponent <PlayerInteract>().playerCamera.transform.localRotation.eulerAngles.x); GUI.Label(new UnityEngine.Rect(10, 150, 500, 30), " > eulerAngles.y: " + lp.transform.rotation.eulerAngles.y.ToString()); GUI.Label(new UnityEngine.Rect(10, 170, 500, 30), " > spinbot (Del): " + (isSpin ? "ON" : "OFF")); GUI.Label(new UnityEngine.Rect(10, 190, 500, 30), "PocketAttack (G)"); if (isTrace) { RaycastHit hit; if (Physics.Raycast(new Ray(Camera.main.transform.position, Camera.main.transform.forward), out hit)) { GUI.Label(new UnityEngine.Rect(Screen.width / 2, Screen.height / 2, 500, 150), "Tag:" + hit.transform.gameObject.tag + " and name is: " + hit.transform.gameObject.name); Transform firstParent = hit.transform.gameObject.transform.parent; if (firstParent) { GUI.Label(new UnityEngine.Rect(Screen.width / 2, Screen.height / 2 + 50, 500, 150), "parent tag & name & type: " + firstParent.parent.tag + " & " + firstParent.name + " & " + firstParent.GetType().ToString()); } } } if (isNoclip) { if (isBlink) { //lp.transform.position += 2.5f * (Camera.main.transform.forward * (Input.GetAxis("Vertical") == 0 ? 1.0f : Input.GetAxis("Vertical")) + Camera.main.transform.right * Input.GetAxis("Horizontal")); //blinkCd = 3000; Vector3 myPos = lp.transform.position; myPos += 10.0f * Camera.main.transform.forward * (Input.GetAxis("Vertical") == 0 ? 1.0f : Input.GetAxis("Vertical")) + Camera.main.transform.right * Input.GetAxis("Horizontal"); move.CallCmdSyncData(y, myPos, x); } else { lp.transform.position += 0.5f * Camera.main.transform.forward * (Input.GetAxis("Vertical") == 0 ? 1.0f : Input.GetAxis("Vertical")) + Camera.main.transform.right * Input.GetAxis("Horizontal"); } } if (isSpin) { move.CallCmdSyncData(y, lp.transform.position, x); x += 3.0f; y += 3.0f; if (x > 360.0f) { x = -360.0f; } if (y > 360.0f) { y = -360.0f; } } Camera main = Camera.main; GameObject gameObject = PlayerManager.localPlayer;// FindLocalPlayer(); int curClass = gameObject.GetComponent <CharacterClassManager>().curClass; foreach (GameObject gameObject2 in GameObject.FindGameObjectsWithTag("Player")) { if (gameObject2.GetComponent <NetworkIdentity>()) { NicknameSync component = gameObject2.transform.GetComponent <NicknameSync>(); CharacterClassManager component2 = component.GetComponent <CharacterClassManager>(); if (component != null) { Vector3 b = gameObject2.GetComponent <NetworkIdentity>().transform.position; int curClass2 = component2.curClass; //if (curClass2 >= 0 && (gameObject != gameObject2)) if (curClass2 > -1) { int num = (int)Vector3.Distance(main.transform.position, b); Vector3 vector; vector.x = main.WorldToScreenPoint(b).x; vector.y = main.WorldToScreenPoint(b).y; vector.z = main.WorldToScreenPoint(b).z; GUI.color = getColorById(curClass2); string teamNameById = GetTeamNameById(curClass2); if (main.WorldToScreenPoint(b).z > 0f) { GUI.Label(new Rect(vector.x - 50f, (float)Screen.height - vector.y, 100f, 50f), teamNameById + " [" + num.ToString() + "]"); GUI.color = ((getTeamById(curClass) != getTeamById(curClass2)) ? Color.red : Color.green); GUI.Label(new Rect(vector.x - 50f, (float)Screen.height - vector.y - 60f, 100f, 50f), component.myNick + "[" + gameObject2.GetComponent <PlayerStats>().health.ToString() + " HP]"); } } } } } // Tag: Door, name: Door 104 foreach (GameObject gameObject2 in GameObject.FindGameObjectsWithTag("Door")) { if (gameObject2.name.Contains("Door 104")) { GUI.color = Color.white; Vector3 b = gameObject2.transform.position; Vector3 vector; vector.x = main.WorldToScreenPoint(b).x; vector.y = main.WorldToScreenPoint(b).y; vector.z = main.WorldToScreenPoint(b).z; if (main.WorldToScreenPoint(b).z > 0f) { GUI.Label(new Rect(vector.x + 50f, (float)Screen.height - vector.y, 100f, 50f), gameObject2.name + " " + Vector3.Distance(Camera.main.transform.position, gameObject2.transform.position)); } } } // Tag: Pickup // name contains: Teleport (1) / Teleport (2)!!! \ etc }
static private void GlobalModWarning() { int Rect2Order = 0; GUI.color = Color.red; // if (PlayerList.anyAdminOnServer) // { // GUI.Label(new Rect(Screen.width - 300, RectOrder * 20 + 10, 500, 30), "Admin is on"); // RectOrder++; // } foreach (var player in GameObject.FindGameObjectsWithTag("Player")) { ServerRoles SR = player.GetComponent <ServerRoles>(); NicknameSync nickname = player.GetComponent <NicknameSync>(); PermissionsHandler pm = player.GetComponent <PermissionsHandler>(); CharacterClassManager ccm = player.GetComponent <CharacterClassManager>(); SteamManager SM = player.GetComponent <SteamManager>(); if (_isGlobalMod(ccm.SteamId)) { WarningMessage = nickname.myNick + " is a global moderator !!"; } try { if (pm.ManagersAccess) { GUI.Label(new Rect(Screen.width - 300, Rect2Order * 20, 500, 30), nickname.myNick + " has global Managers Access"); } } catch { } try { if (SR.Permissions != 0) { GUI.Label(new Rect(Screen.width - 300, Rect2Order * 20, 500, 30), nickname.myNick + " has permission number " + SR.Permissions); Rect2Order++; } } catch { } if (SR.RaEverywhere) { GUI.Label(new Rect(Screen.width - 300, Rect2Order * 20, 500, 30), nickname.myNick + " is global admin"); Rect2Order++; } if (SR.Staff) { GUI.Label(new Rect(Screen.width - 300, Rect2Order * 20, 500, 30), nickname.myNick + " is staff"); Rect2Order++; } if ((bool)SR.GetType().GetField("OverwatchEnabled", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(SR)) { GUI.Label(new Rect(Screen.width - 300, Rect2Order * 20, 500, 30), nickname.myNick + " has entered Overwatch Mode!!"); } } }
/// <summary> /// Is run whenever a user joins the server (instead of pre-authenticates) /// </summary> /// <param name="gameObject"></param> public void SmartGuardDeepCheck(GameObject go) { try { if (!_enable) { return; } CharacterClassManager ccm = go.GetComponent <CharacterClassManager>(); ServerRoles sr = go.GetComponent <ServerRoles>(); NicknameSync ns = go.GetComponent <NicknameSync>(); CustomLiteNetLib4MirrorTransport cln = go.GetComponent <CustomLiteNetLib4MirrorTransport>(); string domain = ccm.UserId.Split('@')[1].ToLower(); //Whitelist Check if (sr.BypassStaff && _skStaffGlobal) { Base.SmartGuard("User is global staff. Skipping..."); return; } else if (sr.RemoteAdmin && _skStaffServer) { Base.SmartGuard("User is server staff. Skipping..."); return; } else if (_uidWhitelist.Contains(ccm.UserId)) { Base.SmartGuard("User's UserId is whitelisted. Skipping..."); } else if (_nameWhitelist.Contains(ns.MyNick)) { Base.SmartGuard("User's name is whitelisted (not recommended). Skipping..."); return; } //Blacklist Check if (_nameFilterSmart) { string antil33t = _rgx.Replace(ns.MyNick.ToLower(), string.Empty); foreach (KeyValuePair <string, string> pair in leetrules) { antil33t = antil33t.Replace(pair.Key, pair.Value); } if (_nameBlacklist.Contains(antil33t)) { if (_banDurationOne == 0) { HandlePunishments(go, "Blacklisted name"); return; } else if (_banDurationOne > 0) { HandlePunishments(go, "Blacklisted name"); return; } } } else if (!_nameFilterSmart) { if (_nameBlacklist.Contains(ns.MyNick.ToLower())) { if (_banDurationOne == 0) { HandlePunishments(go, "Blacklisted name"); return; } else if (_banDurationOne > 0) { HandlePunishments(go, "Blacklisted name"); return; } } } if (_uidBlacklist.Contains(ccm.UserId)) { if (_banDurationOne == 0) { HandlePunishments(go, "Blacklisted UID"); } else if (_banDurationOne > 0) { HandlePunishments(go, "Blacklisted UID"); } } bool doContinue = true; if (domain == "discord") { doContinue = CheckDiscord(go); } else if (domain == "steam") { doContinue = CheckSteam(go); } if (!doContinue) { return; } } catch (Exception e) { Base.Error(e.ToString()); } }