Advertisement
Guest User

fn_requestReceived.sqf

a guest
Mar 11th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.97 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3. File: fn_requestReceived.sqf
  4. Author: Bryan "Tonic" Boardwine
  5.  
  6. Description:
  7. Called by the server saying that we have a response so let's
  8. sort through the information, validate it and if all valid
  9. set the client up.
  10. */
  11. private _count = count _this;
  12. life_session_tries = life_session_tries + 1;
  13. if (life_session_completed) exitWith {}; //Why did this get executed when the client already initialized? Fucking arma...
  14. if (life_session_tries > 3) exitWith {cutText[localize "STR_Session_Error","BLACK FADED"]; 0 cutFadeOut 999999999;};
  15.  
  16. 0 cutText [localize "STR_Session_Received","BLACK FADED"];
  17. 0 cutFadeOut 9999999;
  18.  
  19. //Error handling and junk..
  20. if (isNil "_this") exitWith {[] call SOCK_fnc_insertPlayerInfo;};
  21. if (_this isEqualType "") exitWith {[] call SOCK_fnc_insertPlayerInfo;};
  22. if (count _this isEqualTo 0) exitWith {[] call SOCK_fnc_insertPlayerInfo;};
  23. if ((_this select 0) isEqualTo "Error") exitWith {[] call SOCK_fnc_insertPlayerInfo;};
  24. if (!(getPlayerUID player isEqualTo (_this select 0))) exitWith {[] call SOCK_fnc_dataQuery;};
  25.  
  26. //Lets make sure some vars are not set before hand.. If they are get rid of them, hopefully the engine purges past variables but meh who cares.
  27. if (!isServer && (!isNil "life_adminlevel" || !isNil "life_coplevel" || !isNil "life_donorlevel")) exitWith {
  28. [profileName,getPlayerUID player,"VariablesAlreadySet"] remoteExecCall ["SPY_fnc_cookieJar",RSERV];
  29. [profileName,format ["Variables set before client initialization...\nlife_adminlevel: %1\nlife_coplevel: %2\nlife_donorlevel: %3",life_adminlevel,life_coplevel,life_donorlevel]] remoteExecCall ["SPY_fnc_notifyAdmins",RCLIENT];
  30. sleep 0.9;
  31. failMission "SpyGlass";
  32. };
  33.  
  34. //Parse basic player information.
  35. CASH = parseNumber (_this select 2);
  36. BANK = parseNumber (_this select 3);
  37. life_bankingpin = parseNumber (_this select 16);
  38. CONST(life_adminlevel,(_this select 4));
  39. if (LIFE_SETTINGS(getNumber,"donor_level") isEqualTo 1) then {
  40. CONST(life_donorlevel,(_this select 5));
  41. } else {
  42. CONST(life_donorlevel,0);
  43. };
  44.  
  45. //Loop through licenses
  46. if (count (_this select 6) > 0) then {
  47. {missionNamespace setVariable [(_x select 0),(_x select 1)];} forEach (_this select 6);
  48. };
  49.  
  50. //Parse side specific information.
  51. switch (playerSide) do {
  52. case west: {
  53. CONST(life_coplevel,(_this select 7));
  54. CONST(life_medicLevel,0);
  55. life_blacklisted = _this select 9;
  56. if (LIFE_SETTINGS(getNumber,"save_playerStats") isEqualTo 1) then {
  57. life_hunger = ((_this select 10) select 0);
  58. life_thirst = ((_this select 10) select 1);
  59. player setDamage ((_this select 10) select 2);
  60. };
  61. };
  62.  
  63. case east: {
  64. CONST(life_adacLevel,(_this select 7));
  65. CONST(life_coplevel,0);
  66. if (LIFE_SETTINGS(getNumber,"save_playerStats") isEqualTo 1) then {
  67. life_hunger = ((_this select 9) select 0);
  68. life_thirst = ((_this select 9) select 1);
  69. };
  70. };
  71.  
  72. case civilian: {
  73. life_is_arrested = _this select 7;
  74. CONST(life_coplevel, 0);
  75. CONST(life_medicLevel, 0);
  76. life_houses = _this select (_count - 3);
  77. if (LIFE_SETTINGS(getNumber,"save_playerStats") isEqualTo 1) then {
  78. life_hunger = ((_this select 9) select 0);
  79. life_thirst = ((_this select 9) select 1);
  80. player setDamage ((_this select 9) select 2);
  81. };
  82.  
  83. //Position
  84. if (LIFE_SETTINGS(getNumber,"save_civilian_position") isEqualTo 1) then {
  85. life_is_alive = _this select 10;
  86. life_civ_position = _this select 11;
  87. if (life_is_alive) then {
  88. if !(count life_civ_position isEqualTo 3) then {diag_log format ["[requestReceived] Bad position received. Data: %1",life_civ_position];life_is_alive =false;};
  89. if (life_civ_position distance (getMarkerPos "respawn_civilian") < 300) then {life_is_alive = false;};
  90. };
  91. };
  92.  
  93. {
  94. _house = nearestObject [(call compile format ["%1",(_x select 0)]), "House"];
  95. life_vehicles pushBack _house;
  96. } forEach life_houses;
  97.  
  98. life_gangData = _this select (_count - 2);
  99. if !(count life_gangData isEqualTo 0) then {
  100. [] spawn life_fnc_initGang;
  101. };
  102. [] spawn life_fnc_initHouses;
  103. };
  104.  
  105. case independent: {
  106. CONST(life_medicLevel,(_this select 7));
  107. CONST(life_coplevel,0);
  108. if (LIFE_SETTINGS(getNumber,"save_playerStats") isEqualTo 1) then {
  109. life_hunger = ((_this select 9) select 0);
  110. life_thirst = ((_this select 9) select 1);
  111. player setDamage ((_this select 9) select 2);
  112. };
  113. };
  114. };
  115.  
  116. life_gear = _this select 8;
  117. [true] call life_fnc_loadGear;
  118.  
  119. if (count (_this select (_count - 1)) > 0) then {
  120. {life_vehicles pushBack _x;} forEach (_this select (_count - 1));
  121. };
  122.  
  123. life_session_completed = true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement