@@ -38,6 +38,9 @@ void CLuaUtilDefs::LoadFunctions ( void )
38
38
CLuaCFunctions::AddFunction ( " pregFind" , PregFind );
39
39
CLuaCFunctions::AddFunction ( " pregReplace" , PregReplace );
40
40
CLuaCFunctions::AddFunction ( " pregMatch" , PregMatch );
41
+
42
+ // Debug functions
43
+ CLuaCFunctions::AddFunction (" debugSleep" , DebugSleep);
41
44
}
42
45
43
46
int CLuaUtilDefs::DisabledFunction ( lua_State* luaVM )
@@ -559,3 +562,44 @@ int CLuaUtilDefs::PregMatch ( lua_State* luaVM )
559
562
lua_pushboolean ( luaVM, false );
560
563
return 1 ;
561
564
}
565
+
566
+ int CLuaUtilDefs::DebugSleep (lua_State* luaVM)
567
+ {
568
+ std::size_t milliseconds;
569
+
570
+ CScriptArgReader argStream (luaVM);
571
+ argStream.ReadNumber (milliseconds);
572
+
573
+ if (!argStream.HasErrors ())
574
+ {
575
+ #ifdef MTA_CLIENT
576
+ if (!g_pClientGame->GetDevelopmentMode ())
577
+ #else
578
+ if (!g_pGame->GetDevelopmentMode ())
579
+ #endif
580
+ {
581
+ m_pScriptDebugging->LogError (luaVM, " This function can only be used in development mode" );
582
+ lua_pushboolean (luaVM, false );
583
+ return 1 ;
584
+ }
585
+
586
+
587
+ // Process HTTP
588
+ #ifdef MTA_CLIENT
589
+ g_pNet->GetHTTPDownloadManager (EDownloadMode::CALL_REMOTE_RESTRICTED)->ProcessQueuedFiles ();
590
+ #else
591
+ g_pNetServer->GetHTTPDownloadManager (EDownloadMode::CALL_REMOTE)->ProcessQueuedFiles ();
592
+ #endif
593
+
594
+ // Sleep a bit
595
+ std::this_thread::sleep_for (std::chrono::milliseconds (milliseconds));
596
+
597
+ lua_pushboolean (luaVM, true );
598
+ return 1 ;
599
+ }
600
+ else
601
+ m_pScriptDebugging->LogCustom (luaVM, argStream.GetFullErrorMessage ());
602
+
603
+ lua_pushboolean (luaVM, false );
604
+ return 1 ;
605
+ }
0 commit comments