Guest User

Untitled

a guest
Jul 27th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. /*
  2. File: fn_asyncCall.sqf
  3. Author: Bryan "Tonic" Boardwine
  4.  
  5. Description:
  6. Commits an asynchronous call to ExtDB
  7.  
  8. Parameters:
  9. 0: STRING (Query to be ran).
  10. 1: INTEGER (1 = ASYNC + not return for update/insert, 2 = ASYNC + return for query's).
  11. 3: BOOL (True to return a single array, false to return multiple entries mainly for garage).
  12. */
  13. waitUntil {!DB_Async_Active};
  14. private["_queryStmt","_queryResult","_key","_mode","_return"];
  15. _queryStmt = [_this,0,"",[""]] call BIS_fnc_param;
  16. _mode = [_this,1,1,[0]] call BIS_fnc_param;
  17. _multiarr = [_this,2,false,[false]] call BIS_fnc_param;
  18.  
  19. if(_queryStmt == "") exitWith {"_INVALID_SQL_STMT"};
  20. _return = false;
  21. DB_Async_Active = true;
  22.  
  23. _queryResult = "";
  24. _key = "extDB" callExtension format["%1:%2:%3",_mode,(call life_sql_id),_queryStmt];
  25. if(_mode == 1) exitWith {DB_Async_Active = false; true};
  26. _key = call compile format["%1",_key]; _key = _key select 1;
  27.  
  28. waitUntil{sleep (random .03); !DB_Async_ExtraLock};
  29. DB_Async_ExtraLock = true;
  30. while{true} do {
  31. _pipe = "extDB" callExtension format["5:%1",_key];
  32. if(_pipe == "") exitWith {};
  33. if(_pipe != "[3]") then {
  34. _queryResult = _queryResult + _pipe;
  35. } else {
  36. sleep 0.35;
  37. };
  38. };
  39.  
  40. DB_Async_ExtraLock = false;
  41. DB_Async_Active = false;
  42. //Get the Array of information blah blah
  43. _queryResult = call compile _queryResult;
  44.  
  45. //Make everything possible for DB_RAW_V2
  46. _queryResult = (_queryResult select 1);
  47.  
  48. if(count (_queryResult select 1) == 0) exitWith {[]};
  49. _return = (_queryResult select 1) select 0;
  50. if(_multiarr) then {
  51. _return = (_queryResult select 1);
  52. };
  53.  
  54. _return;
Add Comment
Please, Sign In to add comment