Guest User

Untitled

a guest
Aug 14th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.23 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. private [""_valid"",""_array""];
  42. _valid = [""0"",""1"",""2"",""3"",""4"",""5"",""6"",""7"",""8"",""9""];
  43. _array = [_this select 0] call KRON_StrToArray;
  44. _return = true;
  45.  
  46. {
  47. if (!(_x in _valid)) exitWith {
  48. _return = false;
  49. };
  50. } forEach _array;
  51. _return;
  52. ";
  53.  
  54. publicVariable "TON_fnc_isnumber";
  55.  
  56. TON_fnc_clientGangKick =
  57. compileFinal "
  58. private [""_unit"",""_group""];
  59. _unit = _this select 0;
  60. _group = _this select 1;
  61. if (isNil ""_unit"" || isNil ""_group"") exitWith {};
  62. if (player isEqualTo _unit && (group player) == _group) then {
  63. life_my_gang = objNull;
  64. [player] joinSilent (createGroup civilian);
  65. hint localize ""STR_GNOTF_KickOutGang"";
  66. };
  67. ";
  68.  
  69. publicVariable "TON_fnc_clientGangKick";
  70.  
  71. TON_fnc_clientGetKey =
  72. compileFinal "
  73. private [""_vehicle"",""_unit"",""_giver""];
  74. _vehicle = _this select 0;
  75. _unit = _this select 1;
  76. _giver = _this select 2;
  77. if (isNil ""_unit"" || isNil ""_giver"") exitWith {};
  78. if (player isEqualTo _unit && !(_vehicle in life_vehicles)) then {
  79. _name = getText(configFile >> ""CfgVehicles"" >> (typeOf _vehicle) >> ""displayName"");
  80. hint format [localize ""STR_NOTF_gaveKeysFrom"",_giver,_name];
  81. life_vehicles pushBack _vehicle;
  82. [getPlayerUID player,playerSide,_vehicle,1] remoteExecCall [""TON_fnc_keyManagement"",2];
  83. };
  84. ";
  85.  
  86. publicVariable "TON_fnc_clientGetKey";
  87.  
  88. TON_fnc_clientGangLeader =
  89. compileFinal "
  90. private [""_unit"",""_group""];
  91. _unit = _this select 0;
  92. _group = _this select 1;
  93. if (isNil ""_unit"" || isNil ""_group"") exitWith {};
  94. if (player isEqualTo _unit && (group player) == _group) then {
  95. player setRank ""COLONEL"";
  96. _group selectLeader _unit;
  97. hint localize ""STR_GNOTF_GaveTransfer"";
  98. };
  99. ";
  100.  
  101. publicVariable "TON_fnc_clientGangLeader";
  102.  
  103. TON_fnc_clientGangLeft =
  104. compileFinal "
  105. private [""_unit"",""_group""];
  106. _unit = _this select 0;
  107. _group = _this select 1;
  108. if (isNil ""_unit"" || isNil ""_group"") exitWith {};
  109. if (player isEqualTo _unit && (group player) == _group) then {
  110. life_my_gang = objNull;
  111. [player] joinSilent (createGroup civilian);
  112. hint localize ""STR_GNOTF_LeaveGang"";
  113. };
  114. ";
  115.  
  116. publicVariable "TON_fnc_clientGangLeft";
  117.  
  118. //Cell Phone Messaging
  119. /*
  120. -fnc_cell_textmsg
  121. -fnc_cell_textcop
  122. -fnc_cell_textadmin
  123. -fnc_cell_adminmsg
  124. -fnc_cell_adminmsgall
  125. */
  126.  
  127. //To EMS
  128. TON_fnc_cell_emsrequest =
  129. compileFinal "
  130. private [""_msg"",""_to""];
  131. ctrlShow[3022,false];
  132. _msg = ctrlText 3003;
  133. _to = ""EMS Units"";
  134.  
  135. if (_msg isEqualTo """") exitWith {hint localize ""STR_CELLMSG_EnterMSG"";ctrlShow[3022,true];};
  136. _length = count (toArray(_msg));
  137. if (_length > 400) exitWith {hint localize ""STR_CELLMSG_LIMITEXCEEDED"";ctrlShow[3022,true];};
  138.  
  139. [_msg,name player,5,mapGridPosition player,player] remoteExecCall [""TON_fnc_clientMessage"",-2];
  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. playSound ""sms"";
  264. };
  265.  
  266. case 1 : {
  267. if (side player != west) exitWith {};
  268. private [""_message"",""_loc"",""_unit""];
  269. _loc = _this select 3;
  270. _unit = _this select 4;
  271. _message = format [""--- 911 DISPATCH FROM %1: %2"",_from,_msg];
  272. if (isNil ""_loc"") then {_loc = ""Unknown"";};
  273. 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];
  274.  
  275. [""PoliceDispatch"",[format [""A New Police Report From: %1"",_from]]] call bis_fnc_showNotification;
  276. systemChat _message;
  277. playSound ""sms"";
  278. };
  279.  
  280. case 2 : {
  281. if ((call life_adminlevel) < 1) exitWith {};
  282. private [""_message"",""_loc"",""_unit""];
  283. _loc = _this select 3;
  284. _unit = _this select 4;
  285. _message = format [""!!! ADMIN REQUEST FROM %1: %2"",_from,_msg];
  286. if (isNil ""_loc"") then {_loc = ""Unknown"";};
  287. 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];
  288.  
  289. [""AdminDispatch"",[format [""%1 Has Requested An Admin!"",_from]]] call bis_fnc_showNotification;
  290. systemChat _message;
  291. playSound ""sms"";
  292. };
  293.  
  294. case 3 : {
  295. private [""_message""];
  296. _message = format [""!!! ADMIN MESSAGE: %1"",_msg];
  297. _admin = format [""Sent by admin: %1"", _from];
  298. 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];
  299.  
  300. [""AdminMessage"",[""You Have Received A Message From An Admin!""]] call bis_fnc_showNotification;
  301. systemChat _message;
  302. if ((call life_adminlevel) > 0) then {systemChat _admin;};
  303. playSound ""sms"";
  304. };
  305.  
  306. case 4 : {
  307. private [""_message"",""_admin""];
  308. _message = format [""!!!ADMIN MESSAGE: %1"",_msg];
  309. _admin = format [""Sent by admin: %1"", _from];
  310. 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];
  311.  
  312. [""AdminMessage"",[""You Have Received A Message From An Admin!""]] call bis_fnc_showNotification;
  313. systemChat _message;
  314. if ((call life_adminlevel) > 0) then {systemChat _admin;};
  315. playSound ""sms"";
  316. };
  317.  
  318. case 5: {
  319. if (side player != independent) exitWith {};
  320. private [""_message"",""_loc"",""_unit""];
  321. _loc = _this select 3;
  322. _unit = _this select 4;
  323. _message = format [""!!! EMS REQUEST FROM %1: %2"",_from, _msg];
  324. if (isNil ""_loc"") then {_loc = ""Unknown"";};
  325. 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];
  326.  
  327. [""TextMessage"",[format [""EMS Request from %1"",_from]]] call bis_fnc_showNotification;
  328. playSound ""sms"";
  329. };
  330. };
  331. ";
  332. publicVariable "TON_fnc_clientMessage";
  333.  
  334. TON_fnc_MapMarkersAdmin = compileFinal "
  335. life_markers_Vehicles = [];
  336. life_markers_Players = [];
  337. if (!life_markers) then {
  338. life_markers = true;
  339. hint localize ""STR_ANOTF_MEnabled"";
  340. } else {
  341. life_markers = false;
  342. hint localize ""STR_ANOTF_MDisabled"";
  343. };
  344. for ""_i"" from 0 to 1 step 0 do {
  345. if (!life_markers) exitWith {};
  346. {
  347. if ((vehicle _x isKindOf ""LandVehicle"") || (vehicle _x isKindOf ""Air"") || (vehicle _x isKindOf ""Ship"")) then {
  348. if (count(crew vehicle _x) > 0) then {
  349. {
  350. if (!(_x in life_markers_Vehicles) && (alive _x) && (getPlayerUID _x != """")) then {
  351. private [""_pos"", ""_Markers"", ""_Vehicle""];
  352. _Vehicle = vehicle _x;
  353. _pos = visiblePosition _x;
  354. _Markers = createMarkerLocal[format [""CRW%1%2"", _pos select 0, _pos select 1], [(_pos select 0) + 20, _pos select 1, 0]];
  355. _TypeVehicle = (getText(configFile >> 'CfgVehicles' >> (typeOf vehicle _x) >> 'displayName'));
  356. _Markers setMarkerTextLocal format ['%1---%2---%3m', name _x, _TypeVehicle, round(_x distance player)];
  357. _Markers setMarkerTypeLocal ""mil_dot"";
  358. if (side _x isEqualTo independent) then {
  359. _Markers setMarkerColorLocal (""ColorIndependent"");
  360. };
  361. if (side _x isEqualTo civilian) then {
  362. _Markers setMarkerColorLocal (""ColorCivilian"");
  363. };
  364. if (side _x isEqualTo west) then {
  365. _Markers setMarkerColorLocal (""ColorBLUFOR"");
  366. };
  367. _Markers setMarkerSizeLocal[1, 1];
  368. life_markers_Vehicles pushBack _x;
  369. [_x, _Markers, _Vehicle, _TypeVehicle] spawn {
  370. private [""_PlayersOrVehicles"", ""_Marker"", ""_CrewVehicle""];
  371. _PlayersOrVehicles = _this select 0;
  372. _Marker = _this select 1;
  373. _TypeVehicle = _this select 3;
  374. for ""_i"" from 0 to 1 step 0 do {
  375. if (!life_markers && !(alive _PlayersOrVehicles) && (vehicle _PlayersOrVehicles == _PlayersOrVehicles) && (getPlayerUID _PlayersOrVehicles != """")) exitWith {};
  376. _CrewVehicle = ((crew vehicle _PlayersOrVehicles) find _PlayersOrVehicles);
  377. _Marker setMarkerPosLocal([(visiblePosition _PlayersOrVehicles select 0) + 20, (visiblePosition _PlayersOrVehicles select 1) - (25 + _CrewVehicle * 20), 0]);
  378. _Marker setMarkerTextLocal format ['%1---%2---%3m', name _PlayersOrVehicles, _TypeVehicle, round(_PlayersOrVehicles distance player)];
  379. sleep 0.01;
  380. };
  381. deleteMarkerLocal _Marker;
  382. if (_PlayersOrVehicles in life_markers_Vehicles) then {
  383. life_markers_Vehicles deleteAt (life_markers_Vehicles find _PlayersOrVehicles);
  384. };
  385. true;
  386. };
  387. };
  388. } forEach crew vehicle _x;
  389. };
  390. } else {
  391. if (!(_x in life_markers_Players) && (vehicle _x == _x) && (getPlayerUID _x != """")) then {
  392. private [""_pos"", ""_Markers""];
  393. _pos = visiblePosition _x;
  394. _Markers = createMarkerLocal[format [""PLR%1%2"", _pos select 0, _pos select 1], [(_pos select 0) + 20, _pos select 1, 0]];
  395. _Markers setMarkerTypeLocal ""mil_dot"";
  396. _Markers setMarkerSizeLocal[1, 1];
  397. if (side _x isEqualTo independent) then {
  398. _Markers setMarkerColorLocal (""ColorIndependent"");
  399. };
  400. if (side _x isEqualTo civilian) then {
  401. _Markers setMarkerColorLocal (""ColorCivilian"");
  402. };
  403. if (side _x isEqualTo west) then {
  404. _Markers setMarkerColorLocal (""ColorBLUFOR"");
  405. };
  406. _Markers setMarkerTextLocal format [""%1---%2"", name _x, round(_x distance player)];
  407. if (_x == player) then {
  408. _Markers setMarkerColorLocal ""ColorGreen"";
  409. };
  410. life_markers_Players pushBack _x;
  411. [_x, _Markers] spawn {
  412. private [""_PlayersOrVehicles"", ""_Marker""];
  413. _PlayersOrVehicles = _this select 0;
  414. _Marker = _this select 1;
  415. for ""_i"" from 0 to 1 step 0 do {
  416. if (!life_markers && !(alive _PlayersOrVehicles) && (vehicle _PlayersOrVehicles != _PlayersOrVehicles) && (getPlayerUID _PlayersOrVehicles != """")) exitWith {};
  417. _Marker setMarkerPosLocal([visiblePosition _PlayersOrVehicles select 0, visiblePosition _PlayersOrVehicles select 1, 0]);
  418. _Marker setMarkerTextLocal format [""%1---%2"", name _PlayersOrVehicles, round(_PlayersOrVehicles distance player)];
  419. sleep 0.01;
  420. };
  421. deleteMarkerLocal _Marker;
  422. if (_PlayersOrVehicles in life_markers_Players) then {
  423. life_markers_Players deleteAt (life_markers_Players find _PlayersOrVehicles);
  424. };
  425. true;
  426. };
  427. };
  428. };
  429. } forEach playableUnits;
  430. sleep 0.3;
  431. };
  432. {
  433. _Markers = str _x;
  434. deleteMarkerLocal _Markers;
  435. } forEach playableUnits;
  436. ";
  437.  
  438. publicVariable "TON_fnc_MapMarkersAdmin";
Advertisement
Add Comment
Please, Sign In to add comment