How Server Side Citizen.Wait(0) command?


#1

EXAMPLE :

AddEventHandler('es:playerLoaded', function( source )

  getIdentity(source, function(data)
    Citizen.Wait(12000)
    
    print(data.firstname)
    if data.firstname == '' or data.firstname == nil or data.firstname == 0 or data.firstname == '0' then
       TriggerClientEvent('jsfour-register:open', source)
    else
      print('^2Basarili bir sekilde karakter yuklendi: ^1' .. data.firstname .. '^0' .. data.lastname)
    end
  end)
end)

Working but really big console error’s here :

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00029] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00000] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
  at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
  at (wrapper dynamic-method) System.Object:CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object,int)
  at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet] (System.Runtime.CompilerServices.CallSite site, T0 arg0, T1 arg1) [0x0010f] in <48501e5f32e8491e924f8b8beae3e4f6>:0
  at CitizenFX.Core.MsgPackDeserializer+<>c__DisplayClass36_1.<CreateRemoteFunctionReference>b__1 (System.Object res, System.Object err) [0x00246] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\MsgPackDeserializer.cs:290
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
   --- End of inner exception stack trace ---
Server stack trace:
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00048] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x000e7] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00008] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
  at CitizenFX.Core.FunctionReference.Invoke (System.Int32 reference, System.Byte[] arguments) [0x00062] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\FunctionReference.cs:65
  at CitizenFX.Core.InternalManager.CallRef (System.Int32 refIndex, System.Byte[] argsSerialized, System.IntPtr& retvalSerialized, System.Int32& retvalSize) [0x00000] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\InternalManager.cs:249
  at (wrapper remoting-invoke-with-check) CitizenFX.Core.InternalManager:CallRef (int,byte[],intptr&,int&)
  at (wrapper xdomain-dispatch) CitizenFX.Core.InternalManager:CallRef (object,byte[]&,byte[]&,int,byte[],int&)

Exception rethrown at [0]:
  at (wrapper xdomain-invoke) CitizenFX.Core.InternalManager:CallRef (int,byte[],intptr&,int&)
  at (wrapper remoting-invoke-with-check) CitizenFX.Core.InternalManager:CallRef (int,byte[],intptr&,int&)
  at CitizenFX.Core.MonoScriptRuntime.CallRef (System.Int32 refIndex, System.Byte[] argsSerialized, System.Int32 argsSize, System.IntPtr& retvalSerialized, System.Int32& retvalSize) [0x00013] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\MonoScriptRuntime.cs:151
Error resuming coroutine: citizen:/scripting/lua/MessagePack.lua:830: missing bytes
stack traceback:
        [C]: in function 'error'
        citizen:/scripting/lua/MessagePack.lua:830: in method 'underflow'
        citizen:/scripting/lua/MessagePack.lua:465: in field 'any'
        citizen:/scripting/lua/MessagePack.lua:860: in field 'unpack'
        citizen:/scripting/lua/scheduler.lua:578: in field 'cb'
        citizen:/scripting/lua/scheduler.lua:353: in function <citizen:/scripting/lua/scheduler.lua:343>

What is my fault?


#2

I dont think the Citizen.Wait(1) is your issue Because it works fine for me


#3

You need to be inside of a Citizen.CreateThread to Citizen.Wait I believe. Also remove source AddEventHandler('es:playerLoaded', function( source ) on recent builds I get console errors if source is included in an event handler function. It’s always present so you don’t need to include it, just use it later in the event.


#4

Thanks for help…

20


#5

LOL

@Thaisen isnt this your code??? :laughing:


#6

Nope haha. I think it’s jsfour


#7

ahh ok lel

20charssss