// Start is called before the first frame update void Awake() { gameManager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>(); player = GameObject.FindGameObjectWithTag("Player"); playerPickupScript = player.GetComponent <PlayerPickupScript>(); inventory = player.GetComponent <Inventory>(); }
public override void OnUpdate() { playerHealthManagement = (PlayerHealthManagement)GameObject.Find("Player").GetComponent(typeof(PlayerHealthManagement)); MultiplayerPlayerInformation multiplayerPlayerInformation = (MultiplayerPlayerInformation)GameObject.Find("Player").GetComponent(typeof(MultiplayerPlayerInformation)); MultiplayerPlayerScript[] multiplayerPlayerScripts = (MultiplayerPlayerScript[])UnityEngine.Object.FindObjectsOfType(typeof(MultiplayerPlayerScript)); switch (modes.Selected) { case "BUILTIN": //Shitty built in godmode when health reaches 0 and below you go invisible. if (!playerHealthManagement.Equals(null)) { playerHealthManagement.godmode = true; } break; case "PICKUP": //Now works when none host. Just annoying with its sound and stuff. if (!playerHealthManagement.Equals(null) && playerHealthManagement.myhealth < 200f) { PlayerPickupScript script = (PlayerPickupScript)GameObject.Find("Player").GetComponent(typeof(PlayerPickupScript)); if (!script.Equals(null)) { fakeHealth = new GameObject(); fakeHealth.AddComponent <DummyClass>(); fakeHealth.tag = "HolyHealthTag"; fakeHealth.transform.position = multiplayerPlayerInformation.myplayer.transform.position; script.pickupholyhealth(fakeHealth); } } break; case "CLIENT": //Works only when host. if (multiplayerPlayerScripts.Length > 0) { foreach (var clients in multiplayerPlayerScripts) { if (clients.name == multiplayerPlayerInformation.myplayer.name) { clients.myhealth = health.GetValueFloat(); clients.myarmor = armour.GetValueFloat(); } } } break; case "CLIENTPICKUP": //Works none host and no annoying sounds plus other players can't hear it. if (multiplayerPlayerScripts.Length > 0 && !playerHealthManagement.Equals(null) && playerHealthManagement.myhealth < 200f) { foreach (var clients in multiplayerPlayerScripts) { if (clients.name == multiplayerPlayerInformation.myplayer.name) { clients.CallCmdSetHealth(health.GetValueFloat(), armour.GetValueFloat()); } } } break; } }