Advertisement
InnovativeStudios

fn_extDBAsync.sqf

Jan 14th, 2023
2,005
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 1.55 KB | None | 0 0
  1. private ["_queryStmt", "_queryResult", "_key", "_mode", "_return", "_loop"];
  2.  
  3. if (!params [
  4.     ["_queryStmt", "", [""]],
  5.     ["_mode", 0, [0]]
  6. ]) exitWith {};
  7.  
  8. _key = "extDB3" callExtension format["%1:%2:%3", _mode, (call extDB_SQL_CUSTOM_ID), _queryStmt];
  9. if (_mode isEqualTo 1) exitWith { true };
  10.  
  11. _key = call compile format["%1",_key];
  12. _key = _key select 1;
  13.  
  14. _start = diag_tickTime;
  15. _sleepLoop = true;
  16. while { _sleepLoop } do {
  17.     if (diag_tickTime > (_start + 30)) then {
  18.         _sleepLoop = false;
  19.     };
  20. };
  21.  
  22. _queryResult = "";
  23. _loop = true;
  24. while{ _loop } do {
  25.     _queryResult = "extDB3" callExtension format["4:%1", _key];
  26.     if (_queryResult isEqualTo "[5]") then {
  27.         // extDB3 returned that result is Multi-Part Message
  28.         _queryResult = "";
  29.         while { true } do {
  30.             _pipe = "extDB3" callExtension format["5:%1", _key];
  31.             if (_pipe isEqualTo "") exitWith { _loop = false };
  32.             _queryResult = _queryResult + _pipe;
  33.         };
  34.     } else {
  35.         if (_queryResult isEqualTo "[3]") then {
  36.             diag_log format ["extDB3: uisleep [4]: %1", diag_tickTime];
  37.             _start = diag_tickTime;
  38.             _sleepLoop = true;
  39.             while {_sleepLoop} do {
  40.                 if (diag_tickTime > (_start + 100)) then {
  41.                     _sleepLoop = false;
  42.                 };
  43.             };
  44.         } else {
  45.             _loop = false;
  46.         };
  47.     };
  48. };
  49.  
  50.  
  51. _queryResult = call compile _queryResult;
  52.  
  53. // Not needed, its SQF Code incase extDB3 ever returns error message i.e Database Connection Died
  54. if ((_queryResult select 0) isEqualTo 0) exitWith { diag_log format ["extDB3: Protocol Error: %1", _queryResult]; [] };
  55. _return = (_queryResult select 1);
  56. _return;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement