Advertisement
DanielStewart

Untitled

Dec 2nd, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.03 KB | None | 0 0
  1. #include "script_macros.hpp"
  2. /*
  3. File: functions.sqf
  4. Author: Bryan "Tonic" Boardwine
  5.  
  6. Description: They are functions.
  7. */
  8.  
  9. publicVariable "TON_fnc_terrainSort";
  10.  
  11. TON_fnc_index =
  12. compileFinal "
  13. private [""_item"",""_stack""];
  14. _item = _this select 0;
  15. _stack = _this select 1;
  16. _return = -1;
  17.  
  18. {
  19. if (_item in _x) exitWith {
  20. _return = _forEachIndex;
  21. };
  22. } forEach _stack;
  23.  
  24. _return;
  25. ";
  26.  
  27. TON_fnc_player_query =
  28. compileFinal "
  29. private [""_ret""];
  30. _ret = _this select 0;
  31. if (isNull _ret) exitWith {};
  32. if (isNil ""_ret"") exitWith {};
  33.  
  34. [life_atmbank,life_cash,owner player,player,profileNameSteam,getPlayerUID player,playerSide] remoteExecCall [""life_fnc_adminInfo"",_ret];
  35. ";
  36. publicVariable "TON_fnc_player_query";
  37. publicVariable "TON_fnc_index";
  38.  
  39. TON_fnc_isNumber =
  40. compileFinal "
  41. params [
  42. ['_string','',['']]
  43. ];
  44. if (_string isEqualTo '') exitWith {false};
  45. private _array = _string splitString '';
  46. private _return = true;
  47. {
  48. if !(str(_x) in ['0','1','2','3','4','5','6','7','8','9']) exitWith {
  49. _return = false;
  50. };
  51. } forEach _array;
  52. _return;
  53. ";
  54.  
  55. publicVariable "TON_fnc_isNumber";
  56.  
  57. TON_fnc_clientGangKick =
  58. compileFinal "
  59. private [""_unit"",""_group""];
  60. _unit = _this select 0;
  61. _group = _this select 1;
  62. if (isNil ""_unit"" || isNil ""_group"") exitWith {};
  63. if (player isEqualTo _unit && (group player) == _group) then {
  64. life_my_gang = objNull;
  65. [player] joinSilent (createGroup civilian);
  66. hint localize ""STR_GNOTF_KickOutGang"";
  67. };
  68. ";
  69.  
  70. publicVariable "TON_fnc_clientGangKick";
  71.  
  72. TON_fnc_clientGetKey =
  73. compileFinal "
  74. private [""_vehicle"",""_unit"",""_giver""];
  75. _vehicle = _this select 0;
  76. _unit = _this select 1;
  77. _giver = _this select 2;
  78. if (isNil ""_unit"" || isNil ""_giver"") exitWith {};
  79. if (player isEqualTo _unit && !(_vehicle in life_vehicles)) then {
  80. _name = getText(configFile >> ""CfgVehicles"" >> (typeOf _vehicle) >> ""displayName"");
  81. hint format [localize ""STR_NOTF_gaveKeysFrom"",_giver,_name];
  82. life_vehicles pushBack _vehicle;
  83. [getPlayerUID player,playerSide,_vehicle,1] remoteExecCall [""TON_fnc_keyManagement"",2];
  84. };
  85. ";
  86.  
  87. publicVariable "TON_fnc_clientGetKey";
  88.  
  89. TON_fnc_clientGangLeader =
  90. compileFinal "
  91. private [""_unit"",""_group""];
  92. _unit = _this select 0;
  93. _group = _this select 1;
  94. if (isNil ""_unit"" || isNil ""_group"") exitWith {};
  95. if (player isEqualTo _unit && (group player) == _group) then {
  96. player setRank ""COLONEL"";
  97. _group selectLeader _unit;
  98. hint localize ""STR_GNOTF_GaveTransfer"";
  99. };
  100. ";
  101.  
  102. publicVariable "TON_fnc_clientGangLeader";
  103.  
  104. TON_fnc_clientGangLeft =
  105. compileFinal "
  106. private [""_unit"",""_group""];
  107. _unit = _this select 0;
  108. _group = _this select 1;
  109. if (isNil ""_unit"" || isNil ""_group"") exitWith {};
  110. if (player isEqualTo _unit && (group player) == _group) then {
  111. life_my_gang = objNull;
  112. [player] joinSilent (createGroup civilian);
  113. hint localize ""STR_GNOTF_LeaveGang"";
  114. };
  115. ";
  116.  
  117. publicVariable "TON_fnc_clientGangLeft";
  118.  
  119. //Cell Phone Messaging
  120. /*
  121. -fnc_cell_textmsg
  122. -fnc_cell_textcop
  123. -fnc_cell_textadmin
  124. -fnc_cell_adminmsg
  125. -fnc_cell_adminmsgall
  126. */
  127.  
  128. //To EMS
  129. TON_fnc_cell_emsrequest =
  130. compileFinal "
  131. private [""_msg"",""_to""];
  132. ctrlShow[3022,false];
  133. _msg = ctrlText 3003;
  134. _length = count (toArray(_msg));
  135. if (_length > 400) exitWith {hint localize ""STR_CELLMSG_LIMITEXCEEDED"";ctrlShow[3022,true];};
  136. _to = ""EMS Units"";
  137. if (_msg isEqualTo """") exitWith {hint localize ""STR_CELLMSG_EnterMSG"";ctrlShow[3022,true];};
  138.  
  139. [_msg,name player,5,mapGridPosition player,player] remoteExecCall [""TON_fnc_clientMessage"",independent];
  140. [] call life_fnc_cellphone;
  141. hint format [localize ""STR_CELLMSG_ToEMS"",_to,_msg];
  142. ctrlShow[3022,true];
  143. ";
  144. //To One Person
  145. TON_fnc_cell_textmsg =
  146. compileFinal "
  147. private [""_msg"",""_to""];
  148. ctrlShow[3015,false];
  149. _msg = ctrlText 3003;
  150.  
  151. _length = count (toArray(_msg));
  152. if (_length > 400) exitWith {hint localize ""STR_CELLMSG_LIMITEXCEEDED"";ctrlShow[3015,true];};
  153. if (lbCurSel 3004 isEqualTo -1) exitWith {hint localize ""STR_CELLMSG_SelectPerson""; ctrlShow[3015,true];};
  154.  
  155. _to = call compile format [""%1"",(lbData[3004,(lbCurSel 3004)])];
  156. if (isNull _to) exitWith {ctrlShow[3015,true];};
  157. if (isNil ""_to"") exitWith {ctrlShow[3015,true];};
  158. if (_msg isEqualTo """") exitWith {hint localize ""STR_CELLMSG_EnterMSG"";ctrlShow[3015,true];};
  159.  
  160. [_msg,name player,0] remoteExecCall [""TON_fnc_clientMessage"",_to];
  161. [] call life_fnc_cellphone;
  162. hint format [localize ""STR_CELLMSG_ToPerson"",name _to,_msg];
  163. ctrlShow[3015,true];
  164. ";
  165. //To All Cops
  166. TON_fnc_cell_textcop =
  167. compileFinal "
  168. private [""_msg"",""_to""];
  169. ctrlShow[3016,false];
  170. _msg = ctrlText 3003;
  171. _to = ""The Police"";
  172.  
  173. if (_msg isEqualTo """") exitWith {hint localize ""STR_CELLMSG_EnterMSG"";ctrlShow[3016,true];};
  174. _length = count (toArray(_msg));
  175. if (_length > 400) exitWith {hint localize ""STR_CELLMSG_LIMITEXCEEDED"";ctrlShow[3016,true];};
  176.  
  177. [_msg,name player,1,mapGridPosition player,player] remoteExecCall [""TON_fnc_clientMessage"",-2];
  178. [] call life_fnc_cellphone;
  179. hint format [localize ""STR_CELLMSG_ToPerson"",_to,_msg];
  180. ctrlShow[3016,true];
  181. ";
  182. //To All Admins
  183. TON_fnc_cell_textadmin =
  184. compileFinal "
  185. private [""_msg"",""_to"",""_from""];
  186. ctrlShow[3017,false];
  187. _msg = ctrlText 3003;
  188. _to = ""The Admins"";
  189.  
  190. if (_msg isEqualTo """") exitWith {hint localize ""STR_CELLMSG_EnterMSG"";ctrlShow[3017,true];};
  191. _length = count (toArray(_msg));
  192. if (_length > 400) exitWith {hint localize ""STR_CELLMSG_LIMITEXCEEDED"";ctrlShow[3017,true];};
  193.  
  194. [_msg,name player,2,mapGridPosition player,player] remoteExecCall [""TON_fnc_clientMessage"",-2];
  195. [] call life_fnc_cellphone;
  196. hint format [localize ""STR_CELLMSG_ToPerson"",_to,_msg];
  197. ctrlShow[3017,true];
  198. ";
  199. //Admin To One Person
  200. TON_fnc_cell_adminmsg =
  201. compileFinal "
  202. if (isServer) exitWith {};
  203. if ((call life_adminlevel) < 1) exitWith {hint localize ""STR_CELLMSG_NoAdmin"";};
  204. private [""_msg"",""_to""];
  205. ctrlShow[3020,false];
  206. _msg = ctrlText 3003;
  207. _to = call compile format [""%1"",(lbData[3004,(lbCurSel 3004)])];
  208. if (isNull _to) exitWith {ctrlShow[3020,true];};
  209. if (isNil ""_to"") exitWith {ctrlShow[3020,true];};
  210. if (_msg isEqualTo """") exitWith {hint localize ""STR_CELLMSG_EnterMSG"";ctrlShow[3020,true];};
  211.  
  212. [_msg,name player,3] remoteExecCall [""TON_fnc_clientMessage"",_to];
  213. [] call life_fnc_cellphone;
  214. hint format [localize ""STR_CELLMSG_AdminToPerson"",name _to,_msg];
  215. ctrlShow[3020,true];
  216. ";
  217.  
  218. TON_fnc_cell_adminmsgall =
  219. compileFinal "
  220. if (isServer) exitWith {};
  221. if ((call life_adminlevel) < 1) exitWith {hint localize ""STR_CELLMSG_NoAdmin"";};
  222. private [""_msg"",""_from""];
  223. ctrlShow[3021,false];
  224. _msg = ctrlText 3003;
  225. if (_msg isEqualTo """") exitWith {hint localize ""STR_CELLMSG_EnterMSG"";ctrlShow[3021,true];};
  226.  
  227. [_msg,name player,4] remoteExecCall [""TON_fnc_clientMessage"",-2];
  228. [] call life_fnc_cellphone;
  229. hint format [localize ""STR_CELLMSG_AdminToAll"",_msg];
  230. ctrlShow[3021,true];
  231. ";
  232.  
  233. publicVariable "TON_fnc_cell_textmsg";
  234. publicVariable "TON_fnc_cell_textcop";
  235. publicVariable "TON_fnc_cell_textadmin";
  236. publicVariable "TON_fnc_cell_adminmsg";
  237. publicVariable "TON_fnc_cell_adminmsgall";
  238. publicVariable "TON_fnc_cell_emsrequest";
  239. //Client Message
  240. /*
  241. 0 = private message
  242. 1 = police message
  243. 2 = message to admin
  244. 3 = message from admin
  245. 4 = admin message to all
  246. */
  247. TON_fnc_clientMessage =
  248. compileFinal "
  249. if (isServer) exitWith {};
  250. private [""_msg"",""_from"", ""_type""];
  251. _msg = _this select 0;
  252. _from = _this select 1;
  253. _type = _this select 2;
  254. if (_from isEqualTo """") exitWith {};
  255. switch (_type) do {
  256. case 0 : {
  257. private [""_message""];
  258. _message = format ["">>>MESSAGE FROM %1: %2"",_from,_msg];
  259. hint parseText format [""<t color='#FFCC00'><t size='2'><t align='center'>New Message<br/><br/><t color='#33CC33'><t align='left'><t size='1'>To: <t color='#ffffff'>You<br/><t color='#33CC33'>From: <t color='#ffffff'>%1<br/><br/><t color='#33CC33'>Message:<br/><t color='#ffffff'>%2"",_from,_msg];
  260.  
  261. [""TextMessage"",[format [""You Received A New Private Message From %1"",_from]]] call bis_fnc_showNotification;
  262. systemChat _message;
  263. };
  264.  
  265. case 1 : {
  266. if (side player != west) exitWith {};
  267. private [""_message"",""_loc"",""_unit""];
  268. _loc = _this select 3;
  269. _unit = _this select 4;
  270. _message = format [""--- 911 DISPATCH FROM %1: %2"",_from,_msg];
  271. if (isNil ""_loc"") then {_loc = ""Unknown"";};
  272. hint parseText format [""<t color='#316dff'><t size='2'><t align='center'>New Dispatch<br/><br/><t color='#33CC33'><t align='left'><t size='1'>To: <t color='#ffffff'>All Officers<br/><t color='#33CC33'>From: <t color='#ffffff'>%1<br/><t color='#33CC33'>Coords: <t color='#ffffff'>%2<br/><br/><t color='#33CC33'>Message:<br/><t color='#ffffff'>%3"",_from,_loc,_msg];
  273.  
  274. [""PoliceDispatch"",[format [""A New Police Report From: %1"",_from]]] call bis_fnc_showNotification;
  275. systemChat _message;
  276. };
  277.  
  278. case 2 : {
  279. if ((call life_adminlevel) < 1) exitWith {};
  280. private [""_message"",""_loc"",""_unit""];
  281. _loc = _this select 3;
  282. _unit = _this select 4;
  283. _message = format [""!!! ADMIN REQUEST FROM %1: %2"",_from,_msg];
  284. if (isNil ""_loc"") then {_loc = ""Unknown"";};
  285. hint parseText format [""<t color='#ffcefe'><t size='2'><t align='center'>Admin Request<br/><br/><t color='#33CC33'><t align='left'><t size='1'>To: <t color='#ffffff'>Admins<br/><t color='#33CC33'>From: <t color='#ffffff'>%1<br/><t color='#33CC33'>Coords: <t color='#ffffff'>%2<br/><br/><t color='#33CC33'>Message:<br/><t color='#ffffff'>%3"",_from,_loc,_msg];
  286.  
  287. [""AdminDispatch"",[format [""%1 Has Requested An Admin!"",_from]]] call bis_fnc_showNotification;
  288. systemChat _message;
  289. };
  290.  
  291. case 3 : {
  292. private [""_message""];
  293. _message = format [""!!! ADMIN MESSAGE: %1"",_msg];
  294. _admin = format [""Sent by admin: %1"", _from];
  295. hint parseText format [""<t color='#FF0000'><t size='2'><t align='center'>Admin Message<br/><br/><t color='#33CC33'><t align='left'><t size='1'>To: <t color='#ffffff'>You<br/><t color='#33CC33'>From: <t color='#ffffff'>An Admin<br/><br/><t color='#33CC33'>Message:<br/><t color='#ffffff'>%1"",_msg];
  296.  
  297. [""AdminMessage"",[""You Have Received A Message From An Admin!""]] call bis_fnc_showNotification;
  298. systemChat _message;
  299. if ((call life_adminlevel) > 0) then {systemChat _admin;};
  300. };
  301.  
  302. case 4 : {
  303. private [""_message"",""_admin""];
  304. _message = format [""!!!ADMIN MESSAGE: %1"",_msg];
  305. _admin = format [""Sent by admin: %1"", _from];
  306. hint parseText format [""<t color='#FF0000'><t size='2'><t align='center'>Admin Message<br/><br/><t color='#33CC33'><t align='left'><t size='1'>To: <t color='#ffffff'>All Players<br/><t color='#33CC33'>From: <t color='#ffffff'>The Admins<br/><br/><t color='#33CC33'>Message:<br/><t color='#ffffff'>%1"",_msg];
  307.  
  308. [""AdminMessage"",[""You Have Received A Message From An Admin!""]] call bis_fnc_showNotification;
  309. systemChat _message;
  310. if ((call life_adminlevel) > 0) then {systemChat _admin;};
  311. };
  312.  
  313. case 5: {
  314. if (side player != independent) exitWith {};
  315. private [""_message"",""_loc"",""_unit""];
  316. _loc = _this select 3;
  317. _unit = _this select 4;
  318. _message = format [""!!! EMS REQUEST: %1"",_msg];
  319. hint parseText format [""<t color='#FFCC00'><t size='2'><t align='center'>EMS Request<br/><br/><t color='#33CC33'><t align='left'><t size='1'>To: <t color='#ffffff'>You<br/><t color='#33CC33'>From: <t color='#ffffff'>%1<br/><t color='#33CC33'>Coords: <t color='#ffffff'>%2<br/><br/><t color='#33CC33'>Message:<br/><t color='#ffffff'>%3"",_from,_loc,_msg];
  320.  
  321. [""TextMessage"",[format [""EMS Request from %1"",_from]]] call bis_fnc_showNotification;
  322. };
  323. };
  324. ";
  325. publicVariable "TON_fnc_clientMessage";
  326.  
  327. TON_fnc_MapMarkersAdmin = compileFinal "
  328. life_markers_Vehicles = [];
  329. life_markers_Players = [];
  330. if (!life_markers) then {
  331. life_markers = true;
  332. hint localize ""STR_ANOTF_MEnabled"";
  333. } else {
  334. life_markers = false;
  335. hint localize ""STR_ANOTF_MDisabled"";
  336. };
  337. for ""_i"" from 0 to 1 step 0 do {
  338. if (!life_markers) exitWith {};
  339. {
  340. if ((vehicle _x isKindOf ""LandVehicle"") || (vehicle _x isKindOf ""Air"") || (vehicle _x isKindOf ""Ship"")) then {
  341. if (count(crew vehicle _x) > 0) then {
  342. {
  343. if (!(_x in life_markers_Vehicles) && (alive _x) && (getPlayerUID _x != """")) then {
  344. private [""_pos"", ""_Markers"", ""_Vehicle""];
  345. _Vehicle = vehicle _x;
  346. _pos = visiblePosition _x;
  347. _Markers = createMarkerLocal[format [""CRW%1%2"", _pos select 0, _pos select 1], [(_pos select 0) + 20, _pos select 1, 0]];
  348. _TypeVehicle = (getText(configFile >> 'CfgVehicles' >> (typeOf vehicle _x) >> 'displayName'));
  349. _Markers setMarkerTextLocal format ['%1---%2---%3m', name _x, _TypeVehicle, round(_x distance player)];
  350. _Markers setMarkerTypeLocal ""mil_dot"";
  351. if (side _x isEqualTo independent) then {
  352. _Markers setMarkerColorLocal (""ColorIndependent"");
  353. };
  354. if (side _x isEqualTo civilian) then {
  355. _Markers setMarkerColorLocal (""ColorCivilian"");
  356. };
  357. if (side _x isEqualTo west) then {
  358. _Markers setMarkerColorLocal (""ColorBLUFOR"");
  359. };
  360. _Markers setMarkerSizeLocal[1, 1];
  361. life_markers_Vehicles pushBack _x;
  362. [_x, _Markers, _Vehicle, _TypeVehicle] spawn {
  363. private [""_PlayersOrVehicles"", ""_Marker"", ""_CrewVehicle""];
  364. _PlayersOrVehicles = _this select 0;
  365. _Marker = _this select 1;
  366. _TypeVehicle = _this select 3;
  367. for ""_i"" from 0 to 1 step 0 do {
  368. if (!life_markers && !(alive _PlayersOrVehicles) && (vehicle _PlayersOrVehicles == _PlayersOrVehicles) && (getPlayerUID _PlayersOrVehicles != """")) exitWith {};
  369. _CrewVehicle = ((crew vehicle _PlayersOrVehicles) find _PlayersOrVehicles);
  370. _Marker setMarkerPosLocal([(visiblePosition _PlayersOrVehicles select 0) + 20, (visiblePosition _PlayersOrVehicles select 1) - (25 + _CrewVehicle * 20), 0]);
  371. _Marker setMarkerTextLocal format ['%1---%2---%3m', name _PlayersOrVehicles, _TypeVehicle, round(_PlayersOrVehicles distance player)];
  372. sleep 0.01;
  373. };
  374. deleteMarkerLocal _Marker;
  375. if (_PlayersOrVehicles in life_markers_Vehicles) then {
  376. life_markers_Vehicles deleteAt (life_markers_Vehicles find _PlayersOrVehicles);
  377. };
  378. true;
  379. };
  380. };
  381. } forEach crew vehicle _x;
  382. };
  383. } else {
  384. if (!(_x in life_markers_Players) && (vehicle _x == _x) && (getPlayerUID _x != """")) then {
  385. private [""_pos"", ""_Markers""];
  386. _pos = visiblePosition _x;
  387. _Markers = createMarkerLocal[format [""PLR%1%2"", _pos select 0, _pos select 1], [(_pos select 0) + 20, _pos select 1, 0]];
  388. _Markers setMarkerTypeLocal ""mil_dot"";
  389. _Markers setMarkerSizeLocal[1, 1];
  390. if (side _x isEqualTo independent) then {
  391. _Markers setMarkerColorLocal (""ColorIndependent"");
  392. };
  393. if (side _x isEqualTo civilian) then {
  394. _Markers setMarkerColorLocal (""ColorCivilian"");
  395. };
  396. if (side _x isEqualTo west) then {
  397. _Markers setMarkerColorLocal (""ColorBLUFOR"");
  398. };
  399. _Markers setMarkerTextLocal format [""%1---%2"", name _x, round(_x distance player)];
  400. if (_x == player) then {
  401. _Markers setMarkerColorLocal ""ColorGreen"";
  402. };
  403. life_markers_Players pushBack _x;
  404. [_x, _Markers] spawn {
  405. private [""_PlayersOrVehicles"", ""_Marker""];
  406. _PlayersOrVehicles = _this select 0;
  407. _Marker = _this select 1;
  408. for ""_i"" from 0 to 1 step 0 do {
  409. if (!life_markers && !(alive _PlayersOrVehicles) && (vehicle _PlayersOrVehicles != _PlayersOrVehicles) && (getPlayerUID _PlayersOrVehicles != """")) exitWith {};
  410. _Marker setMarkerPosLocal([visiblePosition _PlayersOrVehicles select 0, visiblePosition _PlayersOrVehicles select 1, 0]);
  411. _Marker setMarkerTextLocal format [""%1---%2"", name _PlayersOrVehicles, round(_PlayersOrVehicles distance player)];
  412. sleep 0.01;
  413. };
  414. deleteMarkerLocal _Marker;
  415. if (_PlayersOrVehicles in life_markers_Players) then {
  416. life_markers_Players deleteAt (life_markers_Players find _PlayersOrVehicles);
  417. };
  418. true;
  419. };
  420. };
  421. };
  422. } forEach playableUnits;
  423. sleep 0.3;
  424. };
  425. {
  426. _Markers = str _x;
  427. deleteMarkerLocal _Markers;
  428. } forEach playableUnits;
  429. ";
  430.  
  431. publicVariable "TON_fnc_MapMarkersAdmin";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement