Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. #include "script_macros.hpp"
  2. /*
  3. File: fn_asyncCall.sqf
  4. Author: Bryan "Tonic" Boardwine
  5. Description:
  6. Commits an asynchronous call to ExtDB
  7. Parameters:
  8. 0: STRING (Query to be ran).
  9. 1: INTEGER (1 = ASYNC + not return for update/insert, 2 = ASYNC + return for query's).
  10. 3: BOOL (True to return a single array, false to return multiple entries mainly for garage).
  11. */
  12. private["_queryStmt","_mode","_multiarr","_queryResult","_key","_return","_loop"];
  13. _queryStmt = [_this,0,"",[""]] call BIS_fnc_param;
  14. _mode = [_this,1,1,[0]] call BIS_fnc_param;
  15. _multiarr = [_this,2,false,[false]] call BIS_fnc_param;
  16.  
  17. _key = EXTDB format["%1:%2:%3",_mode,FETCH_CONST(life_sql_id),_queryStmt];
  18.  
  19. if (_mode isEqualTo 1) exitWith {true};
  20.  
  21. _key = call compile format["%1",_key];
  22. _key = (_key select 1);
  23. _queryResult = EXTDB format["4:%1", _key];
  24.  
  25. //Make sure the data is received
  26. if (_queryResult isEqualTo "[3]") then {
  27. for "_i" from 0 to 1 step 0 do {
  28. if (!(_queryResult isEqualTo "[3]")) exitWith {};
  29. _queryResult = EXTDB format["4:%1", _key];
  30. };
  31. };
  32.  
  33. if (_queryResult isEqualTo "[5]") then {
  34. _loop = true;
  35. for "_i" from 0 to 1 step 0 do { // extDB2 returned that result is Multi-Part Message
  36. _queryResult = "";
  37. for "_i" from 0 to 1 step 0 do {
  38. _pipe = EXTDB format["5:%1", _key];
  39. if (_pipe isEqualTo "") exitWith {_loop = false};
  40. _queryResult = _queryResult + _pipe;
  41. };
  42. if (!_loop) exitWith {};
  43. };
  44. };
  45. _queryResult = call compile _queryResult;
  46. if ((_queryResult select 0) isEqualTo 0) exitWith {diag_log format ["extDB2: Protocol Error: %1", _queryResult]; []};
  47. _return = (_queryResult select 1);
  48. if (!_multiarr && count _return > 0) then {
  49. _return = (_return select 0);
  50. };
  51.  
  52. _return;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement