Help - MFPS 2.0 Round End on BDMode when all enemy players/teammates are dead

Support for MFPS 2.0 (for verified users)
Forum rules
To request support/assistance for MFPS, you first have to verify your purchase by sending your purchase invoice number to Lovatto in a PM.
Post Reply
User avatar
skr2000
Contributor
Contributor
Posts: 169
Joined: Thu Feb 02, 2017 8:23 pm

Hi,
I'm trying to make BDMode like counter-strike, I wanna make round end on bdround when all enemy players/teammates are dead.
I've tried this code, round winning works fine but it cause strange problem.
Code Part:

Code: Select all

    void Update()
    {
        if (BombDone)
            return;
        if (!CanUseThis)
        {
            CanPlant = false;
            Active = false;
            return;
        }
		if (!RoundFinish && GetPlayerInDeltaCount != 0 && GetPlayerInReconCount != 0)
			CheckPlayerDead ();

        if (CanPlant)
        {
            PlantLogic();
        }
        if (CanDesactive)
        {
            DesactiveLogic();
        }
        if (Active)
        {
            ActiveCountDown();
        }
        LightControll();
    }
    
    	void CheckPlayerDead(){
			if (DeltaDead >= GetPlayerInDeltaCount) {
				StartCoroutine (AllDeadWon (0));
			}
			if (ReconDead >= GetPlayerInReconCount) {
				StartCoroutine (AllDeadWon (1));
			}
	}
	
		IEnumerator AllDeadWon(int team)
	{
		RoundFinish = true;
		if (PhotonNetwork.isMasterClient) { WonDoneByAllDead(team); } else { GetWinnerDead(team); }
		StartCoroutine(GameManager.GetComponent<bl_RoomMenu>().FadeIn());
		yield return new WaitForSeconds(TimeForNextRound);
		//If still missing rounds
		if (SettingsPropierties.CheckForBDRound)
		{
			for (int i = 0; i < AllBombs.Length; i++)
			{
				bl_BombDefuse bd = AllBombs[i];
				bd.Reset();
			}
			GameManager.SpawnPlayer(PhotonNetwork.player.GetPlayerTeam());
		}
		else//if rached max rounds
		{
			PhotonNetwork.LeaveRoom();
			bl_UtilityHelper.LockCursor(false);
		}
	}

	void GetWinnerDead(int team)
	{
		if (team == 0) {
			bl_EventHandler.OnKillEvent ("Round Won", 1000f);
			bl_AnnouncerManager.GetManager.NewKill (7);
			PhotonNetwork.player.PostScore (1500);
		} else {
			bl_EventHandler.OnKillEvent ("Round Won", 1000f);
			PhotonNetwork.player.PostScore(1000);
			bl_AnnouncerManager.GetManager.NewKill (6);
		}
	}
    
	public int GetPlayerInDeltaCount
	{
		get
		{
			int count = 0;
			for (int i = 0; i < PhotonNetwork.playerList.Length; i++)
			{
				PhotonPlayer players = PhotonNetwork.playerList[i];
				if ((string)players.CustomProperties[PropertiesKeys.TeamKey] == Team.Delta.ToString())
				{
					count++;
				}
			}
			return count;
		}
	}

	public int DeltaDead
	{
		get
		{
			int count = 0;
			for (int i = 0; i < GetDeltaPlayerList.Count; i++)
			{
				PhotonPlayer players = GetDeltaPlayerList[i];
				bl_PlayerDamageManager pdm = GameObject.Find (players.NickName).GetComponent<bl_PlayerDamageManager> ();
				if (pdm != null && pdm.dead) {
					count++;
				} else if (FindObjectOfType<bl_Ragdoll>() != null) {
					count++;
				}
			}
			return count;
		}
	}

	public int ReconDead
	{
		get
		{
			int count = 0;
			for (int i = 0; i < GetReconPlayerList.Count; i++)
			{
				PhotonPlayer players = GetReconPlayerList[i];
				bl_PlayerDamageManager pdm = GameObject.Find (players.NickName).GetComponent<bl_PlayerDamageManager> ();
				if (pdm != null && pdm.dead) {
					count++;
				} else if (FindObjectOfType<bl_Ragdoll>() != null) {
					count++;
				}
			}
			return count;
		}
	}
	public int GetPlayerInReconCount
	{
		get
		{
			int count = 0;
			for (int i = 0; i < PhotonNetwork.playerList.Length; i++)
			{
				PhotonPlayer players = PhotonNetwork.playerList[i];
				if ((string)players.CustomProperties[PropertiesKeys.TeamKey] == Team.Recon.ToString())
				{
					count++;
				}
			}
			return count;
		}
	}
}
    
Bug Video:
User avatar
Lovatto
Admin
Admin
Posts: 1834
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

The best way to do this is count all the players at the start of round one count for each team, and decrease the count each time that a player leave or die if one of counts = 0 = end round,
you may want also that players that death in round can't spawn again until next round, you should check bl_Ragdoll.cs for this, in this script call the function to spawn gain, so you need block the spawn with a condition like if(GetGameMode != GameMode.SND){ SpawnFunction();} and when next round start just call automatically the spawn function for all players.

Hope this help.
How to find your Invoice Number: Here
How to find your Order Number: Here
User avatar
skr2000
Contributor
Contributor
Posts: 169
Joined: Thu Feb 02, 2017 8:23 pm

Fixed, Thannks :D
Post Reply