Advertisement
Guest User

Untitled

a guest
Apr 15th, 2019
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. /*
  2. File: init.sqf
  3. Author:
  4. Description:
  5. Initializes extDB, loads Protocol + options if any + Locks extDB
  6. Parameters:
  7. 0: STRING Database name as in extdb3-conf.ini
  8. 1: STRING Protocol to enable
  9. 2: STRING Optional Protocol Options i.e db_conf name for DB_CUSTOM
  10. */
  11.  
  12. private["_database","_protocol","_protocol_options","_return","_result","_random_number","_extDB_SQL_CUSTOM_ID"];
  13.  
  14. _database = [_this,0,"",[""]] call BIS_fnc_param;
  15. _protocol = [_this,1,"",[""]] call BIS_fnc_param;
  16. _protocol_options = [_this,2,"",[""]] call BIS_fnc_param;
  17.  
  18.  
  19. _return = false;
  20.  
  21. if ( isNil {uiNamespace getVariable "extDB_SQL_CUSTOM_ID"}) then
  22. {
  23. // extDB Version
  24. _result = "extDB3" callExtension "9:VERSION";
  25.  
  26. diag_log format ["extDB3: Version: %1", _result];
  27. if(_result == "") exitWith {diag_log "extDB3: Failed to Load"; false};
  28. //if ((parseNumber _result) < 20) exitWith {diag_log "Error: extDB version 20 or Higher Required";};
  29.  
  30. // extDB Connect to Database
  31. _result = call compile ("extDB3" callExtension format["9:ADD_DATABASE:%1", _database]);
  32. if (_result select 0 isEqualTo 0) exitWith {diag_log format ["extDB3: Error Database: %1", _result]; false};
  33. diag_log "extDB3: Connected to Database";
  34.  
  35. // Generate Randomized Protocol Name
  36. _random_number = round(random(999999));
  37. _extDB_SQL_CUSTOM_ID = str(_random_number);
  38. extDB_SQL_CUSTOM_ID = compileFinal _extDB_SQL_CUSTOM_ID;
  39.  
  40. // extDB Load Protocol
  41. _result = call compile ("extDB3" callExtension format["9:ADD_DATABASE_PROTOCOL", _database, _protocol, _extDB_SQL_CUSTOM_ID, _protocol_options]);
  42. if ((_result select 0) isEqualTo 0) exitWith {diag_log format ["extDB3: Error Database Setup: %1", _result]; false};
  43.  
  44. diag_log format ["extDB3: Initalized %1 Protocol", _protocol];
  45.  
  46. // extDB3 Lock
  47. "extDB3" callExtension "9:LOCK";
  48. diag_log "extDB3: Locked";
  49.  
  50. // Save Randomized ID
  51. uiNamespace setVariable ["extDB_SQL_CUSTOM_ID", _extDB_SQL_CUSTOM_ID];
  52. _return = true;
  53. }
  54. else
  55. {
  56. extDB_SQL_CUSTOM_ID = compileFinal str(uiNamespace getVariable "extDB_SQL_CUSTOM_ID");
  57. diag_log "extDB3: Already Setup";
  58. _return = true;
  59. };
  60.  
  61. _return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement