Infecting random range player issues
Options
No this is not the same post from the previous one the one where the zombie wouldnt get synced, i still didnt manage to fix it but i will manage to fix it by my self.
so in my game i made that if players join a room that has the mode called zombie escape they will be already spawned but they will be human, once they are human some humans will be infected and when they spawn they will become a zombie but in my code it always spawns players as zombies but after 5 seconds they will become a zombie and this is for all players, i dont know why it doesnt make you a human.
parts of the script that infects players:
so in my game i made that if players join a room that has the mode called zombie escape they will be already spawned but they will be human, once they are human some humans will be infected and when they spawn they will become a zombie but in my code it always spawns players as zombies but after 5 seconds they will become a zombie and this is for all players, i dont know why it doesnt make you a human.
parts of the script that infects players:
[PunRPC] private void Infect() { SpawnPlayer(team_zombie.teamName); iszombie = true; }
private void InfectRandomPlayer() { if (PhotonNetwork.isMasterClient) { PhotonPlayer[] array = PhotonNetwork.playerList; int num = 1; if (array.Length > 6) { num = 2; } { int num2 = UnityEngine.Random.Range(0, array.Length); base.photonView.RPC("Infect", array[num2]); } } }
if (gameMode == "ZOM") { SpawnPlayer(team_survivor.teamName); InfectRandomPlayer(); }
0
Comments
-
hello? please i need help im really stuck here0
-
Hard to tell from what you are giving.
[PunRPC] private void Infect() { SpawnPlayer(team_zombie.teamName); iszombie = true; }
You saying the a player should spawn as a Zombie. If im right ?
and Idk where thisif (gameMode == "ZOM") { SpawnPlayer(team_survivor.teamName); InfectRandomPlayer(); }
snippet belongs to.0 -
nevermind i got it working kinda but everytime i die and i become a zombie i cannot get damaged but i can get damaged when im survivor
public void TotalDamage(float damage) { if (disableDamage) return; fadeValue = 2; photonView.RPC("DoDamage", PhotonTargets.All, damage, PhotonNetwork.player); }
public void ApplyFallDamage(float damage) { if (photonView.isMine) { photonView.RPC("DoDamage", PhotonTargets.All, damage, PhotonNetwork.player); } }
[PunRPC] void DoDamage(float damage, PhotonPlayer player) { screenblood.minAlpha += Mathf.Clamp01(damageBloodAmount * (int)currentHp / currentHp); if (weKilled) return; if (currentHp > 0 && photonView.isMine) { this.StopAllCoroutines(); StartCoroutine(doCameraShake()); } fadeValueB = 2; currentHp -= damage; if (currentHp < 0) { for (int i = 0; i < transform.childCount; i++) { transform.GetChild(i).gameObject.SetActive(false); } GameObject temp; temp = Instantiate(ragdoll, transform.position, transform.rotation) as GameObject; if (!photonView.isMine) { temp.SendMessage("clearCamera"); if (PhotonNetwork.player == player) { networkObject.SendMessage("AddKillNotification", gameObject.name, SendMessageOptions.DontRequireReceiver); int teamScore = new int(); if ((string)PhotonNetwork.player.customProperties["TeamName"] == rmm.team_a.teamName) { int totalKIlls = (int)PhotonNetwork.player.customProperties["Kills"]; totalKIlls++; Hashtable setPlayerKills = new Hashtable() { { "Kills", totalKIlls } }; PhotonNetwork.player.SetCustomProperties(setPlayerKills); } if ((string)PhotonNetwork.player.customProperties["TeamName"] == rmm.team_b.teamName) { teamScore = (int)PhotonNetwork.room.customProperties["Team1Score"]; teamScore--; Hashtable setTeam1Score = new Hashtable() { { "Team1Score", teamScore } }; PhotonNetwork.room.SetCustomProperties(setTeam1Score); int totalKIlls = (int)PhotonNetwork.player.customProperties["Kills"]; totalKIlls++; Hashtable setPlayerKills = new Hashtable() { { "Kills", totalKIlls } }; PhotonNetwork.player.SetCustomProperties(setPlayerKills); } } } else { print("dead reeee"); temp.SendMessage("RespawnAfter"); //PhotonNetwork.player.SetCustomProperties(setPlayerTeam); int totalDeaths = (int)PhotonNetwork.player.customProperties["Deaths"]; totalDeaths++; Hashtable setPlayerDeaths = new Hashtable() { { "Deaths", totalDeaths } }; PhotonNetwork.player.SetCustomProperties(setPlayerDeaths); StartCoroutine(DestroyPlayer(0.0f)); if (PhotonNetwork.player == player) { networkObject.SendMessage("PlayerFellDown", PhotonNetwork.player.name, SendMessageOptions.DontRequireReceiver); teamLives = (int)PhotonNetwork.room.customProperties["Team1Score"]; teamLives--; Hashtable setTeam1Score_fell = new Hashtable() { { "Team1Score", teamLives } }; PhotonNetwork.room.SetCustomProperties(setTeam1Score_fell); } } currentHp = 0; weKilled = true; } }
0 -
the error is
PhotonView with ID 0 has no method "DoDamage" marked with the [PunRPC](C#) or @PunRPC(JS) property! Args: Single, PhotonPlayer UnityEngine.Debug:LogError(Object) NetworkingPeer:ExecuteRpc(Hashtable, Int32) (at Assets/stuff/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3132) NetworkingPeer:RPC(PhotonView, String, PhotonTargets, PhotonPlayer, Boolean, Object[]) (at Assets/stuff/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3898) PhotonNetwork:RPC(PhotonView, String, PhotonTargets, Boolean, Object[]) (at Assets/stuff/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:2934) PhotonView:RPC(String, PhotonTargets, Object[]) (at Assets/stuff/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:597) PlayerDamage:ApplyFallDamage(Single) (at Assets/_Scripts/important scripts/PlayerDamage.cs:88) FPScontroller:FixedUpdate() (at Assets/_Scripts/important scripts/FPScontroller.cs:388)
Illegal view ID:0 method: DoDamage GO:zombie(Clone) UnityEngine.Debug:LogError(Object) NetworkingPeer:RPC(PhotonView, String, PhotonTargets, PhotonPlayer, Boolean, Object[]) (at Assets/stuff/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3837) PhotonNetwork:RPC(PhotonView, String, PhotonTargets, Boolean, Object[]) (at Assets/stuff/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:2934) PhotonView:RPC(String, PhotonTargets, Object[]) (at Assets/stuff/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:597) PlayerDamage:ApplyFallDamage(Single) (at Assets/_Scripts/important scripts/PlayerDamage.cs:88) FPScontroller:FixedUpdate() (at Assets/_Scripts/important scripts/FPScontroller.cs:388)
0 -
Hard to tell from what you are giving.
[PunRPC] private void Infect() { SpawnPlayer(team_zombie.teamName); iszombie = true; }
You saying the a player should spawn as a Zombie. If im right ?
and Idk where thisif (gameMode == "ZOM") { SpawnPlayer(team_survivor.teamName); InfectRandomPlayer(); }
snippet belongs to.
Hello i put another code part but if a player chooses it will spawn as a survivor and then infectrandomplayer will start so a random player will be infected0