Error after suicide

Report bugs of MFPS 2.0 here
Post Reply
User avatar
Leonid_RU
Contributor
Contributor
Posts: 50
Joined: Tue Sep 11, 2018 3:04 am

Wed May 20, 2020 2:51 pm

I use MFPS 1.7.

After suicide, an error appears:

Code: Select all

NullReferenceException: Object reference not set to an instance of an object
bl_GameManager.FindActor (Photon.Realtime.Player player) (at Assets/MFPS/Scripts/Network/Room/bl_GameManager.cs:574)
bl_KillCam.SetTarget (Photon.Realtime.Player view, DamageCause cause, System.String killer, UnityEngine.Transform secureTarget) (at Assets/MFPS/Scripts/Misc/Camera/bl_KillCam.cs:135)
bl_PlayerHealthManager.Die (System.String killer, System.Boolean isHeadshot, DamageCause cause, System.Int32 gunID, UnityEngine.Vector3 hitPos, Photon.Realtime.Player sender) (at Assets/MFPS/Scripts/Player/Health/bl_PlayerHealthManager.cs:320)
bl_PlayerHealthManager.SyncDamage (System.Int32 damage, System.String killer, DamageCause cause, UnityEngine.Vector3 m_direction, System.Boolean isHeatShot, System.Int32 weaponID, Photon.Realtime.Player m_sender) (at Assets/MFPS/Scripts/Player/Health/bl_PlayerHealthManager.cs:250)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <fb001e01371b4adca20013e0ac763896>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <fb001e01371b4adca20013e0ac763896>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <fb001e01371b4adca20013e0ac763896>:0)
Photon.Pun.PhotonNetwork.ExecuteRpc (ExitGames.Client.Photon.Hashtable rpcData, Photon.Realtime.Player sender) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:514)
Photon.Pun.PhotonNetwork.RPC (Photon.Pun.PhotonView view, System.String methodName, Photon.Pun.RpcTarget target, Photon.Realtime.Player player, System.Boolean encrypt, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1149)
Photon.Pun.PhotonNetwork.RPC (Photon.Pun.PhotonView view, System.String methodName, Photon.Pun.RpcTarget target, System.Boolean encrypt, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2797)
Photon.Pun.PhotonView.RPC (System.String methodName, Photon.Pun.RpcTarget target, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:411)
bl_PlayerHealthManager.GetDamage (DamageData e) (at Assets/MFPS/Scripts/Player/Health/bl_PlayerHealthManager.cs:167)
bl_PlayerHealthManager.Suicide () (at Assets/MFPS/Scripts/Player/Health/bl_PlayerHealthManager.cs:511)
bl_RoomMenu.Suicide () (at Assets/MFPS/Scripts/GamePlay/Level/bl_RoomMenu.cs:317)
bl_UIReferences.Suicide () (at Assets/MFPS/Scripts/UI/Banks/bl_UIReferences.cs:602)
User avatar
Lovatto
Admin
Admin
Posts: 1541
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

Wed May 20, 2020 5:07 pm

I'm not able to reproduce this problem, can you provide more details, please.

is there a specific environment in order to this error happens or you get it every time that you click on the suicide button?
User avatar
Leonid_RU
Contributor
Contributor
Posts: 50
Joined: Tue Sep 11, 2018 3:04 am

Thu May 21, 2020 2:38 am

I get this error every time I click the suicide button, and also when I go outside the map zone (there is a zone with suicide). As I believe the error is related to killcam, I have a killer tracking installed.

The error occurs when playing with bots. If you log in to the game without bots, the error does not occur.
But if you commit suicide 2 times, the second time the player leave the room...
User avatar
Leonid_RU
Contributor
Contributor
Posts: 50
Joined: Tue Sep 11, 2018 3:04 am

Thu May 21, 2020 11:26 am

The error occurs if no one killed you. If someone has already killed you, the error does not appear.
User avatar
Lovatto
Admin
Admin
Posts: 1541
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

Thu May 21, 2020 12:03 pm

I have a killer tracking installed.
Oh, I see you mean that you are using the Kill Camera Type as Orbit Enemy.

I was able to reproduce the problem, to fix it replace the function: public Transform FindActor(Player player) of bl_GameManager.cs
with this:

Code: Select all

 public Transform FindActor(Player player)
    {
        if (player == null) return null;
        for (int i = 0; i < OthersActorsInScene.Count; i++)
        {
            if (OthersActorsInScene[i].ActorView != null && OthersActorsInScene[i].ActorView.Owner != null && OthersActorsInScene[i].ActorView.Owner.ActorNumber == player.ActorNumber)
            {
                return OthersActorsInScene[i].Actor;
            }
        }
        if (LocalPlayer != null && LocalPlayer.GetPhotonView().Owner.ActorNumber == player.ActorNumber) { return LocalPlayer.transform; }
        return null;
    }
User avatar
Leonid_RU
Contributor
Contributor
Posts: 50
Joined: Tue Sep 11, 2018 3:04 am

Thu May 21, 2020 12:44 pm

Thank you for your help! There is another unsolved problem with suicide. If you click suicide immediately after spawnprotected, there is a probability of leaving the room (sometimes it turns out 2-3 times) and a warning appears.

In the code, I see that the call comes from the health regeneration script. I will tell you in advance that I have health regeneration enabled.

Code: Select all

RaiseEvent(200) failed. Your event is not being sent! Check if your are in a Room
UnityEngine.Debug:LogWarning(Object)
Photon.Pun.PhotonNetwork:RaiseEventInternal(Byte, Object, RaiseEventOptions, SendOptions) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2217)
Photon.Pun.PhotonNetwork:RPC(PhotonView, String, RpcTarget, Player, Boolean, Object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1140)
Photon.Pun.PhotonNetwork:RPC(PhotonView, String, RpcTarget, Boolean, Object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2797)
Photon.Pun.PhotonView:RPC(String, RpcTarget, Object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:411)
bl_PlayerHealthManager:RegenerateHealth() (at Assets/MFPS/Scripts/Player/Health/bl_PlayerHealthManager.cs:493)
bl_PlayerHealthManager:OnUpdate() (at Assets/MFPS/Scripts/Player/Health/bl_PlayerHealthManager.cs:149)
bl_UpdateManager:Update() (at Assets/MFPS/Scripts/Utility/bl_UpdateManager.cs:170)
User avatar
Leonid_RU
Contributor
Contributor
Posts: 50
Joined: Tue Sep 11, 2018 3:04 am

Sat Jun 27, 2020 2:26 am

Hello. Is there a solution for my last answer?
User avatar
Lovatto
Admin
Admin
Posts: 1541
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

Sat Jun 27, 2020 9:03 am

This is an error but not what you think,
By default, players can suicide 2 times only, after that, the third time that they try to suicide in the same match they will be automatically kicked out of the room,
so that is why the player leaves the room automatically.

you can change the maximum number of times that a player can suicide in bl_RoomMenu.cs -> Suicide() ->

Code: Select all

if (bl_GameManager.SuicideCount >= 3)
now the error that you are getting means that the suicide button has been pressed after the third suicide try, and since the player is been kicked out of the room the message couldn't reach the server.

you can fix this error by adding this line:

Code: Select all

 if (!PhotonNetwork.InRoom) return;
at the top of function bl_RoomMenu.cs -> Suicide()
User avatar
Leonid_RU
Contributor
Contributor
Posts: 50
Joined: Tue Sep 11, 2018 3:04 am

Sat Jun 27, 2020 12:20 pm

Thank you!
Post Reply