-
Notifications
You must be signed in to change notification settings - Fork 309
Expand file tree
/
Copy pathfn_asyncCall.sqf
More file actions
executable file
·56 lines (47 loc) · 1.69 KB
/
fn_asyncCall.sqf
File metadata and controls
executable file
·56 lines (47 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "\life_server\script_macros.hpp"
/*
File: fn_asyncCall.sqf
Author: Bryan "Tonic" Boardwine
Description:
Commits an asynchronous call to ExtDB
Parameters:
0: STRING (Query to be ran).
1: INTEGER (1 = ASYNC + not return for update/insert, 2 = ASYNC + return for query's).
3: BOOL (True to return a single array, false to return multiple entries mainly for garage).
*/
params [
["_queryStmt", "", [""]],
["_mode", 1, [0]],
["_multiarr", false, [true]]
];
private _key = EXTDB format ["%1:%2:%3",_mode,FETCH_CONST(life_sql_id),_queryStmt];
if (_mode isEqualTo 1) exitWith {true};
_key = call compile format ["%1",_key];
_key = _key select 1;
private _queryResult = EXTDB format ["4:%1", _key];
//Make sure the data is received
if (_queryResult isEqualTo "[3]") then {
for "_i" from 0 to 1 step 0 do {
if (!(_queryResult isEqualTo "[3]")) exitWith {};
_queryResult = EXTDB format ["4:%1", _key];
};
};
if (_queryResult isEqualTo "[5]") then {
private _loop = true;
for "_i" from 0 to 1 step 0 do { // extDB3 returned that result is Multi-Part Message
_queryResult = "";
for "_i" from 0 to 1 step 0 do {
_pipe = EXTDB format ["5:%1", _key];
if (_pipe isEqualTo "") exitWith {_loop = false};
_queryResult = _queryResult + _pipe;
};
if (!_loop) exitWith {};
};
};
_queryResult = parseSimpleArray _queryResult;
if ((_queryResult select 0) isEqualTo 0) exitWith {diag_log format ["extDB3: Protocol Error: %1", _queryResult]; []};
private _return = (_queryResult select 1);
if (!_multiarr && {!(_return isEqualTo [])}) then {
_return = _return select 0;
};
_return;