NETWORK_IS_SESSION_STARTED in C#

Hi, I try to use Function.Call(Hash.NETWORK_IS_SESSION_STARTED) in c# for define to server when my client is connected but I have this error:

47031] Failed to instantiate instance of script RP_Main.RPMain: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.MethodAccessException: Error verifying RP_Main.RPMain:checkPlayerConnected (): Method System.Array:Empty () is not accessible at 0x0030

[ 47031] at RP_Main.RPMain…ctor () [0x00011] in <909288c757f84169892ac3b0a33f9f03>:0

[ 47031] at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)

[ 47031] at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in :0

[ 47031] — End of inner exception stack trace —

[ 47031] at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00014] in :0

[ 47031] at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x000a8] in :0

[ 47031] at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00009] in :0

[ 47031] at System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00027] in :0

[ 47031] at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00020] in :0

[ 47031] at System.Activator.CreateInstance (System.Type type) [0x00000] in :0

[ 47031] at CitizenFX.Core.InternalManager.CreateAssemblyInternal (System.Byte[] assemblyData, System.Byte[] symbolData) [0x00060] in <5d49e01e11b94174ac4a79284a8734f0>:0
[

I dont understand why…

Thanks

Try the following as a workaround:

Function.Call<bool>(Hash.NETWORK_IS_SESSION_STARTED, new InputArgument[0]);

Of note is that this should always be true, as the client will not run scripts until the session is actually running. If it does not, that is a bug, and should be reported.

Thanks but same error.

That’d be on a different line, then, not this one.

This is the code:

public void checkPlayerConnected()
        {
            while (true)
            {
                BaseScript.Delay(1);


                if (Function.Call<bool>(Hash.NETWORK_IS_SESSION_STARTED, new InputArgument[0]))
                {
                    TriggerServerEvent("rp:playerJoinedDone");
                    Utils.DebugMsg("Joined !!");

                    return;
                }
            }
        }

I dont think so…

Try not building in Release mode. In addition, this isn’t how you’re supposed to run a waiting loop.