Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.34 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3. File: fn_areaCapture.sqf
  4. Author: Fuel RebornRoleplay.com
  5.  
  6. Description:
  7. checks the area for gangs or police before allowing you to capture an area
  8. */
  9. private["_gangNum","_gName","_group","_area","_nil","_pos","_xname","_text","_action","_cpRate","_cP","_nearUnits","_areaContested","_progressBar","_title","_titleText","_ui"];
  10.  
  11. _area = getpos player nearestObject "Flag_Red_F"; //finds the flag
  12. _group = _area getVariable ["gangOwner",grpNull]; //gets the owner of the flag
  13. _xname = ""; //setup for popo name
  14. _nearUnits = _area nearEntities ["Man",25]; //searches area for players
  15. _areaContested = false; //sets the area to not contested
  16. if ((player distance _area) > 10) exitWith { hint "You must be closer to the flag to capture this area!"; }; //too far away
  17.  
  18. /*
  19. #########################################
  20. # The Police Capture System #
  21. #########################################
  22. */
  23.  
  24. if (playerside isEqualTo west) exitWith {
  25.  
  26. //inform the server the police are trying to capture it.
  27. [[0,1],"STR_GNOTF_CaptureAreaAttemptPopo",true,[name player]] remoteExecCall ["life_fnc_broadcast",RCLIENT];
  28.  
  29. //set the cp rate
  30. if (!isNull _group) then {
  31. _cpRate = 0.0545;
  32. } else {
  33. _cpRate = 0.0575;
  34. };
  35.  
  36. //Police officer checks
  37. {
  38.  
  39. //check for other members of same side
  40. if ((isPlayer _x) && (_x != player) && (side _x == west)) then {
  41. _areaContested = false;
  42. };
  43.  
  44. //checks for rebels
  45. if ((isPlayer _x) && (_x != player) && (side _x == civilian)) then {
  46. _areaContested = true;
  47. _xname = "Rebels";
  48. };
  49.  
  50. //closes the capture
  51. if (_areaContested && _xname isEqualTo "Rebels") then {
  52. hint "Rebels are nearby!\nGet rid of them first!";
  53. };
  54.  
  55. } forEach _nearUnits;
  56.  
  57. //exit if contested
  58. if (_areaContested) exitWith {};
  59.  
  60. //Setup our progress bar.
  61. disableSerialization;
  62. _title = localize "STR_GNOTF_CapturingArea";
  63. 5 cutRsc ["life_progress","PLAIN"];
  64. _ui = uiNamespace getVariable "life_progress";
  65. _progressBar = _ui displayCtrl 38201;
  66. _titleText = _ui displayCtrl 38202;
  67. _titleText ctrlSetText format["%2 (1%1)...","%",_title];
  68. _progressBar progressSetPosition 0.01;
  69. _cP = 0.01;
  70.  
  71. if (!(_areaContested)) then {
  72. for "_i" from 0 to 1 step 0 do {
  73. sleep 3; //police capture time * 100
  74. _cP = _cP + _cpRate;
  75. _progressBar progressSetPosition _cP;
  76. _titleText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_title];
  77.  
  78. //sets the area to incapture
  79. _area setVariable ["inCapture",true,true];
  80.  
  81. //interuption checks
  82. if (_cP >= 1 || !alive player) exitWith {_area setVariable ["inCapture",false,true];};
  83. if (player distance _area > 30) exitWith {_area setVariable ["inCapture",false,true];}; //how far they can go from the hideout while capturing
  84. if (_areaContested) exitWith {hint "Area Contested";}; //Future testing
  85. if (life_istazed) exitWith {_area setVariable ["inCapture",false,true];}; //Tazed
  86. if (life_isknocked) exitWith {_area setVariable ["inCapture",false,true];}; //Knocked
  87. if (life_interrupted) exitWith {_area setVariable ["inCapture",false,true];}; //interupted
  88. };
  89. if (player distance _area > 30) exitWith {_area setVariable ["inCapture",false,true];}; //how far they can go from the hideout while capturing
  90. };
  91.  
  92. //Kill the UI display and check for various states
  93. 5 cutText ["","PLAIN"];
  94. if (player distance _area > 30) exitWith {_area setVariable ["inCapture",false,true];}; //how far they can go from the hideout while capturing
  95. if (!alive player || life_istazed || life_isknocked) exitWith {life_action_inUse = false;_area setVariable ["inCapture",false,true];}; //knocked out or tazed revert state
  96. if (player getVariable["restrained",false]) exitWith {life_action_inUse = false;_area setVariable ["inCapture",false,true];}; //restrained revert state
  97. if (life_interrupted) exitWith {life_interrupted = false; titleText[localize "STR_GNOTF_CaptureCancel","PLAIN"]; life_action_inUse = false;_area setVariable ["inCapture",false,true];}; //interupted revert state
  98. life_action_inUse = false;
  99. titleText[localize "STR_GNOTF_CapturedArea","PLAIN"];
  100.  
  101. //marker system
  102. _gangNum = _area getVariable ["gangNum", ""];
  103.  
  104. _gName = group player getVariable "gang_name";
  105. _pText = format["Neutralized Area"];
  106.  
  107. if (_gangNum == "Gang_Area_1") then {
  108. "gang_cap_1" setMarkerText _pText;
  109. };
  110.  
  111. if (_gangNum == "Gang_Area_2") then {
  112. "gang_cap_2" setMarkerText _pText;
  113. };
  114.  
  115. if (_gangNum == "Gang_Area_3") then {
  116. "gang_cap_3" setMarkerText _pText;
  117. };
  118.  
  119. if (_gangNum == "Gang_Area_4") then {
  120. "gang_cap_4" setMarkerText _pText;
  121. };
  122.  
  123. if (_gangNum == "Gang_Area_5") then {
  124. "gang_cap_5" setMarkerText _pText;
  125. };
  126.  
  127. if (_gangNum == "Gang_Area_6") then {
  128. "gang_cap_6" setMarkerText _pText;
  129. };
  130.  
  131. if (_gangNum == "Gang_Area_7") then {
  132. "gang_cap_7" setMarkerText _pText;
  133. };
  134.  
  135. if (_gangNum == "Gang_Area_8") then {
  136. "gang_cap_8" setMarkerText _pText;
  137. };
  138.  
  139. if (_gangNum == "Gang_Area_9") then {
  140. "gang_cap_9" setMarkerText _pText;
  141. };
  142.  
  143. _area setVariable ["inCapture",false,true];
  144. _area setVariable ["gangOwner",group player,true];
  145.  
  146. };
  147.  
  148. /*
  149. #############################################
  150. # End Of Police Capture System #
  151. #############################################
  152. */
  153.  
  154. /*
  155. #########################################
  156. # The Rebel Capture System #
  157. #########################################
  158. */
  159.  
  160. _area = getpos player nearestObject "Flag_Red_F"; //finds the flag
  161. _group = _area getVariable ["gangOwner",grpNull]; //gets the ownerr of the flag
  162. _xname = ""; //setup for popo name
  163. _nearUnits = _area nearEntities ["Man",25]; //searches area for players
  164. if (isNil {group player getVariable "gang_name"}) exitWith { hint "You must be in a gang to capture a gang area!"; }; //not in a gang
  165. if (_group isEqualTo group player) exitWith { hint "Your gang already has control over this area!"; }; //already own it
  166. if ((_area getVariable ["inCapture",FALSE])) exitWith {hint "Only one person shall capture at once!"; }; //stops 2 people capturing at the same time
  167.  
  168. [[0,1],"STR_GNOTF_CaptureAreaAttempt",true,[name player,(group player) getVariable "gang_name"]] remoteExecCall ["life_fnc_broadcast",RCLIENT]; //tells the server someone is trying to capture the outpost
  169.  
  170. if (!isNull _group) then {
  171.  
  172. _gangName = _group getVariable ["gang_name",""]; //gets the gang name
  173.  
  174. //check if they want to capture someones elses area
  175. _action = [
  176. format[localize "STR_GNOTF_AlreadygangControlled",_gangName],
  177. localize "STR_Gang_captuerr",
  178. localize "STR_Global_Yes",
  179. localize "STR_Global_No"
  180. ] call BIS_fnc_guiMessage;
  181.  
  182. _cpRate = 0.0545;
  183. } else {
  184. _cpRate = 0.0575;
  185. };
  186.  
  187. //check if area is contested
  188. {
  189.  
  190. //check for other members of same gang
  191. if ((isPlayer _x) && (_x != player) && (side _x == civilian) && (group _x == group player)) then {
  192. _areaContested = false;
  193. };
  194.  
  195. //check for other rebels
  196. if ((isPlayer _x) && (_x != player) && (side _x == civilian) && (!(group _x == group player))) then {
  197. _areaContested = true;
  198. };
  199.  
  200. //checks for cops
  201. if ((isPlayer _x) && (_x != player) && (side _x == west)) then {
  202. _areaContested = true;
  203. _xname = "Police Force";
  204. };
  205.  
  206. //closes the capture
  207. if (_areaContested) exitWith {
  208. if (_xname isEqualTo "Police Force") then {
  209. hint "The Police Force are nearby!\nGet rid of them first!";
  210. } else {
  211. hint "Other rebels are nearby!\nGet rid of them first!";
  212. };
  213. };
  214.  
  215. } forEach _nearUnits;
  216.  
  217. //exit if contested
  218. if (_areaContested) exitWith {};
  219.  
  220. //Setup our progress bar.
  221. disableSerialization;
  222. _title = localize "STR_GNOTF_CapturingArea";
  223. 5 cutRsc ["life_progress","PLAIN"];
  224. _ui = uiNamespace getVariable "life_progress";
  225. _progressBar = _ui displayCtrl 38201;
  226. _titleText = _ui displayCtrl 38202;
  227. _titleText ctrlSetText format["%2 (1%1)...","%",_title];
  228. _progressBar progressSetPosition 0.01;
  229. _cP = 0.01;
  230.  
  231. if (!(_areaContested)) then {
  232. for "_i" from 0 to 1 step 0 do {
  233. sleep 3; //rebel capture time * 50
  234. _cP = _cP + _cpRate;
  235. _progressBar progressSetPosition _cP;
  236. _titleText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_title];
  237.  
  238. //sets the area to incapture
  239. _area setVariable ["inCapture",true,true];
  240.  
  241. //interuption checks
  242. if (_cP >= 1 || !alive player) exitWith {_area setVariable ["inCapture",false,true];};
  243. if (player distance _area > 30) exitWith {_area setVariable ["inCapture",false,true];}; //how far they can go from the hideout while capturing
  244. if (_areaContested) exitWith {hint "Area Contested";};
  245. if (life_istazed) exitWith {_area setVariable ["inCapture",false,true];}; //Tazed
  246. if (life_isknocked) exitWith {_area setVariable ["inCapture",false,true];}; //Knocked
  247. if (life_interrupted) exitWith {_area setVariable ["inCapture",false,true];}; //interupted
  248. };
  249. if (player distance _area > 30) exitWith {_area setVariable ["inCapture",false,true];}; //how far they can go from the hideout while capturing
  250. };
  251.  
  252. //Kill the UI display and check for various states
  253. 5 cutText ["","PLAIN"];
  254. if (player distance _area > 30) exitWith {_area setVariable ["inCapture",false,true];}; //how far they can go from the hideout while capturing
  255. if (!alive player || life_istazed || life_isknocked) exitWith {life_action_inUse = false;_area setVariable ["inCapture",false,true];}; //knocked out or tazed revert state
  256. if (player getVariable["restrained",false]) exitWith {life_action_inUse = false;_area setVariable ["inCapture",false,true];}; //restrained revert state
  257. if (life_interrupted) exitWith {life_interrupted = false; titleText[localize "STR_GNOTF_CaptureCancel","PLAIN"]; life_action_inUse = false;_area setVariable ["inCapture",false,true];}; //interupted revert state
  258. life_action_inUse = false;
  259.  
  260. titleText[localize "STR_GNOTF_CapturedArea","PLAIN"];
  261.  
  262. //marker system
  263. _gangNum = _area getVariable ["gangNum", ""];
  264.  
  265. _gName = group player getVariable "gang_name";
  266. _Text = format["Area Controlled By %1",_gName];
  267.  
  268. if (_gangNum == "Gang_Area_1") then {
  269. "gang_cap_1" setMarkerText _text;
  270. };
  271.  
  272. if (_gangNum == "Gang_Area_2") then {
  273. "gang_cap_2" setMarkerText _text;
  274. };
  275.  
  276. if (_gangNum == "Gang_Area_3") then {
  277. "gang_cap_3" setMarkerText _text;
  278. };
  279.  
  280. if (_gangNum == "Gang_Area_4") then {
  281. "gang_cap_4" setMarkerText _text;
  282. };
  283.  
  284. if (_gangNum == "Gang_Area_5") then {
  285. "gang_cap_5" setMarkerText _text;
  286. };
  287.  
  288. if (_gangNum == "Gang_Area_6") then {
  289. "gang_cap_6" setMarkerText _text;
  290. };
  291.  
  292. if (_gangNum == "Gang_Area_7") then {
  293. "gang_cap_7" setMarkerText _text;
  294. };
  295.  
  296. if (_gangNum == "Gang_Area_8") then {
  297. "gang_cap_8" setMarkerText _text;
  298. };
  299.  
  300. if (_gangNum == "Gang_Area_9") then {
  301. "gang_cap_9" setMarkerText _text;
  302. };
  303.  
  304. //Tell the world
  305. [[0,1],"STR_GNOTF_CaptureAreaSuccess",true,[name player,(group player) getVariable "gang_name"]] remoteExecCall ["life_fnc_broadcast",RCLIENT];
  306.  
  307. _area setVariable ["inCapture",false,true];
  308. _area setVariable ["gangOwner",group player,true];
  309.  
  310. /*
  311. #############################################
  312. # End Of The Rebel Capture System #
  313. #############################################
  314. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement