Advertisement
aeroson

My Arma 3 scripting cheat sheet, code snippets i use alot.

Sep 19th, 2015
2,394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.72 KB | None | 0 0
  1.  
  2. destroy_radius = 100;
  3. {
  4. _x setDamage 1;
  5. } forEach ((getPos this) nearObjects ["static", destroy_radius]);
  6.  
  7.  
  8.  
  9.  
  10. #adminLogged
  11. unpacked missions saved thru editor are in %appdata%\..\..\Documents\Arma 3 - Other Profiles\aeroson%20[AM%202ST]\mpmissions
  12.  
  13. all mission you play are downloaded in pbo in %appdata%\..\Local\Arma 3\MPMissionsCache
  14. pbo missions are loaded from your steam/Arma 3/mpmissions
  15.  
  16.  
  17. radios,
  18. smokes, grenades,
  19. end game conditions,
  20. max time, what happens to end it faster
  21.  
  22.  
  23. check list,
  24. coms, whisper normal yell,
  25. map, gps, toolkit, defusal
  26.  
  27. friendlies on map,
  28. death messages,
  29. teleport,
  30. deploy squad
  31. vote to disable 1s person
  32.  
  33.  
  34.  
  35. "join group in specified side"; _grp = createGroup east; [player] joinSilent _grp;
  36. _SideHQ = createCenter east;
  37.  
  38. "player set ACE3 medic"; player setVariable ["ace_medical_medicClass", 100]; ["clearConditionCaches", []] call ace_common_fnc_localEvent;
  39.  
  40.  
  41. "put this at the bottom of init.sqf to remove player's silencers on primary weapon and handgun";
  42. [] spawn {
  43. while{hasInterface} do {
  44. _silencer = (primaryWeaponItems player) select 0;
  45. if(_silencer != "") then { player removePrimaryWeaponItem _silencer; };
  46. _silencer = (handgunItems player) select 0;
  47. if(_silencer != "") then { player removeHandgunItem _silencer; };
  48. sleep 1;
  49. };
  50. };
  51.  
  52.  
  53. "init line of logic to destroy every static building in radius";
  54. if(isServer) then {
  55. destroy_radius = 100;
  56. {
  57. _x setDamage 1;
  58. } forEach ((getPos this) nearObjects ["static", destroy_radius]);
  59. };
  60.  
  61. "set side relationships";
  62. [{
  63.  
  64. west setFriend [east, 0];
  65. east setFriend [west, 0];
  66.  
  67. west setFriend [independent, 0];
  68. independent setFriend [west, 0];
  69.  
  70. east setFriend [independent, 1];
  71. independent setFriend [east, 1];
  72.  
  73. },"BIS_fnc_spawn",true] call BIS_fnc_MP;
  74.  
  75.  
  76.  
  77. "set different elevation on respawn, so players can actually respawn on ships";
  78. "put this at the bottom of init.sqf";
  79. if(hasInterface) then {
  80. player addEventHandler ["Respawn", {
  81. private ["_pos"];
  82. _pos = getPosASL player;
  83. _pos set[2, 9.2]; // here the second number means how much m above sea level, use console to watch "getPosASL player" and copy paste the last number if you want to be accurate
  84. player setPosASL _pos;
  85. }];
  86. };
  87.  
  88.  
  89.  
  90.  
  91. "set ace settings to essentials TAW uses";
  92. [{
  93. _data = [
  94. "ace_respawn_SavePreDeathGear", true,
  95. "ace_respawn_RemoveDeadBodiesDisconnected", true,
  96. "ace_medical_medicSetting", 1,
  97. "ace_medical_playerDamageThreshold ", 4,
  98. "ace_medical_AIDamageThreshold", 1,
  99. "ace_medical_enableUnconsciousnessAI", 0,
  100. "ace_medical_preventInstaDeath", true,
  101. "ace_medical_bleedingCoefficient", 1,
  102. "ace_medical_painCoefficient", 1,
  103. "ace_medical_keepLocalSettingsSynced", true
  104. ];
  105. _i = 0;
  106. while{_i < count(_data)} do {
  107. _name = _data select _i;
  108. _val = _data select (_i + 1);
  109. systemChat format["%1 = %2;", _name, _val];
  110. parsingNamespace setVariable [_name, _val];
  111. missionNamespace setVariable [_name, _val];
  112. uiNamespace setVariable [_name, _val];
  113. _i = _i + 2;
  114. };
  115. },"BIS_fnc_spawn",true] call BIS_fnc_MP;
  116.  
  117.  
  118.  
  119.  
  120. "set ace settings to essentials TAW uses";
  121. [{
  122.  
  123. },"BIS_fnc_spawn",true] call BIS_fnc_MP;
  124.  
  125.  
  126.  
  127. "test server profileNamespace";
  128. [{
  129. profileNamespace setVariable ["TEST","yes it works"];
  130. saveProfileNamespace;
  131. },"BIS_fnc_spawn",false] call BIS_fnc_MP;
  132.  
  133. [
  134. [
  135. [player],
  136. {
  137. _test = profileNamespace getVariable ["TEST","it does not work"];
  138. [
  139. [
  140. [_test],
  141. {
  142. hint format["%1", (_this select 0)];
  143. }
  144. ]
  145. ,"BIS_fnc_spawn", (_this select 0)] call BIS_fnc_MP;
  146. }
  147. ]
  148. ,"BIS_fnc_spawn",false] call BIS_fnc_MP;
  149.  
  150.  
  151.  
  152. [
  153. [
  154. {
  155. ace_medical_preventInstaDeath = true;
  156. }
  157. ]
  158. ,"BIS_fnc_spawn", true] call BIS_fnc_MP;
  159.  
  160.  
  161.  
  162.  
  163.  
  164. "get all cfg first child names"; _c = (configFile >> "CfgWorlds" >> worldName); _res=[]; _count = count _c; while{_count>=0} do { _res pushBack (configName(_c select _count)); _count=_count-1; }; _res
  165.  
  166. "allow AGM medic"; player setVariable ["AGM_Medical_AllowNonMedics", true, true];
  167.  
  168. "add all stuff to zeus"; { _x addCuratorEditableObjects [allMissionObjects "all", true]; } count allCurators;
  169.  
  170. "get classnames of litter for garbage collect"; A=[]; { if(!isPlayer _x && !((typeof _x) in A)) then { A pushBack (typeof _x); }; } forEach (allMissionObjects "all" - allMissionObjects "building" ); A;
  171.  
  172. "get classnames of everything in mission"; A=[]; { if(!isPlayer _x && !((typeof _x) in A)) then { A pushBack (typeof _x); }; } forEach (allMissionObjects ""); A;
  173.  
  174. "classname of"; _t="man"; _a=[]; _r=100; { if(!((typeof _x) in _a)) then { _a pushBack (typeof _x); }; } forEach ((getpos player) nearObjects [_t, _r]); _a;
  175.  
  176. "kill all men in 1000m"; { if(!(isPlayer _x)) then { _x setDamage 1; }; } forEach nearestObjects [player, ["vehicle","man"], 1000];
  177.  
  178. "constant rearm and health"; [] spawn { while{true} do { vehicle player setVehicleAmmo 1; vehicle player setDamage 0; }; };
  179.  
  180. "get mission objects with classname"; C="AGM_FastRoping_Helper"; A=[]; { if(_x isKindOf C) then { A pushBack _x; }; } forEach (allMissionObjects ""); A;
  181.  
  182. [{
  183. [] spawn { while{true} do { aero_player_markers_run = false; sleep 10; }; };
  184. },"BIS_fnc_spawn", true, true] call BIS_fnc_MP;
  185.  
  186.  
  187. [{
  188. allowHaloJump_players = 60;
  189. },"BIS_fnc_spawn",cursorTarget] call BIS_fnc_MP;
  190.  
  191.  
  192.  
  193. "mark stuff index"; _m="aa%1"; { _pos = getpos _x; _text = format["%1", _forEachIndex]; _id = format[_m, _forEachIndex]; createMarkerLocal [_id, _pos]; _id setMarkerColorLocal "Default"; _id setMarkerTypeLocal "mil_triangle"; _id setMarkerTextLocal _text; _id setMarkerSizeLocal [1,1]; } forEach
  194.  
  195. "mark stuff name_type_index"; _m="aa%1"; { _pos = getpos _x; _text = format["%1 %2 %2", _x, typeof _x, _forEachIndex]; _id = format[_m, _forEachIndex]; createMarkerLocal [_id, _pos]; _id setMarkerColorLocal "Default"; _id setMarkerTypeLocal "mil_triangle"; _id setMarkerTextLocal _text; _id setMarkerSizeLocal [1,1]; } forEach
  196.  
  197. "mark allMissionObjects'all'"; _m="aa%1"; { _pos = getpos _x; _text = format["%1", typeof _x]; _id = format[_m, _forEachIndex]; createMarkerLocal [_id, _pos]; _id setMarkerColorLocal "Default"; _id setMarkerTypeLocal "mil_triangle"; _id setMarkerTextLocal _text; _id setMarkerSizeLocal [1,1]; } forEach allMissionObjects "all"
  198.  
  199. "mark all caches"; _m="aa%1"; { _pos = getpos _x; _text = format["%1 %2", _forEachIndex, _pos]; _id = format[_m, _forEachIndex]; createMarkerLocal [_id, _pos]; _id setMarkerColorLocal "ColorRed"; _id setMarkerColorLocal "colorRed"; _id setMarkerTypeLocal "mil_triangle"; _id setMarkerTextLocal _text; _id setMarkerSizeLocal [1,1]; } forEach (nearestObjects [getpos player, ["B_supplyCrate_F"], 20000]);
  200.  
  201. "clean up mark stuff"; _m="aa%1"; _num = 0; _marker = format[_m, _num]; while {(getMarkerType _marker) != ""} do { deleteMarkerLocal _marker; _num = _num + 1; _marker = format[_m, _num]; };
  202.  
  203.  
  204. _num = 0;
  205. _marker = format[_m, _num];
  206. while {(getMarkerType _marker) != ""} do {
  207. deleteMarkerLocal _marker;
  208. _num = _num + 1;
  209. _marker = format[_m, _num];
  210. };
  211.  
  212.  
  213. // if doesnt have interface exit, if has interface wait until its ready
  214. if(!hasInterface) exitWith {};
  215. waitUntil{!isNull findDisplay 46};
  216.  
  217. // if has interface wait unitl interface is ready
  218. if(hasInterface) then {
  219. waitUntil{!isNull findDisplay 46};
  220. };
  221.  
  222.  
  223. // put this at the bottom of init.sqf to disable the ability to turn on night vision
  224. if(hasInterface) then {
  225. waitUntil{!isNull findDisplay 46};
  226. (findDisplay 46) displayAddEventHandler ["keyDown", "_this call nightVisionDisable_keyDown"];
  227. nightVisionDisable_keyDown = {
  228. if((_this select 1) in actionKeys "NightVision") exitWith {
  229. true;
  230. };
  231. false;
  232. };
  233. };
  234.  
  235. // tfar mute
  236. _unit setVariable ["tf_globalVolume", 0.4];
  237. _unit setVariable ["tf_voiceVolume", 0, True];
  238. _unit setVariable ["tf_unable_to_use_radio", True, True];
  239.  
  240. // tfar unmute
  241. _unit setVariable ["tf_globalVolume", 1];
  242. _unit setVariable ["tf_voiceVolume", 1, True];
  243. _unit setVariable ["tf_unable_to_use_radio", False, True];
  244.  
  245.  
  246. {
  247. _pos = getpos _x;
  248. _text = format["%1", _x];
  249. _id = format["%1_%2", _text, time];
  250. createMarkerLocal [_id, _pos];
  251. _id setMarkerColorLocal "Default";
  252. _id setMarkerTypeLocal "mil_triangle";
  253. _id setMarkerTextLocal _text;
  254. _id setMarkerSizeLocal [1,1];
  255. } forEach
  256.  
  257. nearestObjects [getpos player, ["RHS_UH60M"], 2000]
  258.  
  259. {
  260. _pos = getpos _x;
  261. _text = format["%1", _forEachIndex];
  262. _id = format["%1_%2", _text, time];
  263. createMarkerLocal [_id, _pos];
  264. _id setMarkerColorLocal "Default";
  265. _id setMarkerTypeLocal "mil_triangle";
  266. _id setMarkerTextLocal _text;
  267. _id setMarkerSizeLocal [1,1];
  268. } forEach (getpos player nearObjects ["B_supplyCrate_F", 10000])
  269.  
  270.  
  271. [{
  272. west setFriend [resistance, 0];
  273. },"BIS_fnc_spawn",true,true] call BIS_fnc_MP;
  274.  
  275. [{
  276. player addRating 10000;
  277. },"BIS_fnc_spawn",true] call BIS_fnc_MP;
  278.  
  279. [{
  280. ["Blue team wins", 0, -0.3, 5] spawn BIS_fnc_dynamicText
  281. },"BIS_fnc_spawn",true] call BIS_fnc_MP;
  282.  
  283.  
  284. "skip time"; [{ _howManyHours = 5; skipTime _howManyHours; },"BIS_fnc_spawn",true] call BIS_fnc_MP;
  285.  
  286.  
  287. // spectate
  288. // https://community.bistudio.com/wiki/Spectator_Mode
  289. waitUntil {!(isNull (findDisplay 46))};
  290.  
  291. RscSpectator_allowFreeCam = true;
  292. spectator_layer = "BIS_fnc_respawnSpectator" call bis_fnc_rscLayer;
  293. spectator_layer cutrsc ["RscSpectator","plain"];
  294.  
  295. spectator_layer cuttext ["","plain"];
  296.  
  297.  
  298.  
  299. "tp all group units to me"; { _x setpos getpos player; } forEach units group player;
  300.  
  301.  
  302. [{hint "Everyone";},"BIS_fnc_spawn",true] call BIS_fnc_MP;
  303.  
  304.  
  305.  
  306. netID cursorTarget
  307.  
  308. [{
  309. (objectFromNetId "0") addAction["<t color='#ffff77'>Virtual Arsenal</t>", { ["Open",true] call BIS_fnc_arsenal; }, [], 1000];
  310. },"BIS_fnc_spawn",true,true] call BIS_fnc_MP;
  311.  
  312.  
  313.  
  314. // zeus on the fly
  315. // http://forums.bistudio.com/showthread.php?186003-Zeus-only-for-admins-need-help&p=2826872&viewfull=1#post2826872
  316. _cur = "curator" createVehicle [0,0,0];
  317. _cur addCuratorAddons activatedAddons;
  318. player assignCurator _cur;
  319.  
  320.  
  321.  
  322. this addaction ["<t color='#ffff00'>Open Virtual Arsenal</t>",{["Open",true] call BIS_fnc_arsenal}];
  323. this addaction ["Arsenal",{["Open",true] call BIS_fnc_arsenal}];
  324.  
  325.  
  326.  
  327. player addaction ["<t color='#ffff77'>Add Arsenal to cursor target</t>",{
  328. [
  329. [
  330. [netID cursorTarget],
  331. {
  332. _netId = _this select 0;
  333. (objectFromNetId _netId) addAction["<t color='#ffff77'>Virtual Arsenal</t>", { ["Open",true] call BIS_fnc_arsenal; }, [], 1000];
  334. }
  335. ],
  336. "BIS_fnc_spawn",true,true] call BIS_fnc_MP;
  337. }];
  338.  
  339.  
  340. player addaction ["Deploy your group to map click location",{
  341.  
  342. }];
  343.  
  344.  
  345. player addaction ["Teleport to map click location",{
  346.  
  347. }];
  348.  
  349. player addaction ["Turn on splendid cam",{
  350.  
  351. }];
  352.  
  353.  
  354. ["someId", "onEachFrame", {
  355. player switchCamera "Internal";
  356. }] call BIS_fnc_addStackedEventHandler;
  357.  
  358.  
  359. ["someId", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
  360.  
  361.  
  362. profileNamespace setVariable ["aero_console_allow", true];
  363.  
  364. 22:29 - aeroson: profileNamespace setVariable ["aero_console_allow", true];
  365. 22:29 - aeroson: to allow it to run anywhere
  366. 22:29 - aeroson: once you figure it out tell me please \o
  367. 22:29 - aeroson: might be worth unpacking arma content
  368. 22:29 - Shishketti: im not having any luck, where do i type that thing in
  369. 22:29 - aeroson: and looking into the zeus modules
  370. 22:30 - aeroson: open first in editor,
  371. 22:30 - aeroson: and execute it
  372. 22:30 - aeroson: then you can use it anywhere
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382. deleteVehicle cursorTarget
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389. call compile format[" [{ _target = objectFromNetId '%1'; _target hideObject true; _target allowDamage false; },'BIS_fnc_spawn',true] call BIS_fnc_MP; ", netID player ];
  390.  
  391.  
  392. [{
  393. (objectFromNetId "0") addAction["<t color='#00ff00'>Repair Vehicle</t>", { (_this select 0) setDamage 0 }, [], 1000];
  394. },"BIS_fnc_spawn",true,true] call BIS_fnc_MP;
  395.  
  396.  
  397.  
  398.  
  399.  
  400. [{
  401. ["Open",true] call BIS_fnc_arsenal;
  402. },"BIS_fnc_spawn",true] call BIS_fnc_MP;
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410. [{
  411. player addAction["Add Titan AA Misille", { player addItem "Titan_AA" }, [], 1000];
  412. },"BIS_fnc_spawn",true,true] call BIS_fnc_MP;
  413.  
  414.  
  415.  
  416.  
  417. [{
  418. player addAction["Add Titan AT Misille", { player addItem "Titan_AA" }, [], 1000];
  419. },"BIS_fnc_spawn",true,true] call BIS_fnc_MP;
  420.  
  421.  
  422.  
  423. [{
  424. enableCamShake false;
  425. },"BIS_fnc_spawn",true,true] call BIS_fnc_MP;
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432. Tasks to learn Arma scripting:
  433. blow up a vehicle
  434. teleport vehicle 10m into air
  435. set vehicle flying up the air
  436. give your self a sniper rifle
  437.  
  438.  
  439.  
  440. PVPscene_POV = {
  441. // Limit 3rd person view to vehicles only
  442. [(_this select 0)] spawn {
  443. while {alive (_this select 0)} do {
  444. if (cameraView == "External") then
  445. {
  446. if (player isEqualTo vehicle player) then {player switchCamera "Internal";};
  447. };
  448. sleep 0.1;
  449. };
  450. };
  451. };
  452.  
  453.  
  454. found out setVariable does not work on these clases (might be more)
  455.  
  456. _class = ["IEDUrbanBig_Remote_Ammo","IEDLandBig_Remote_Ammo","IEDUrbanSmall_Remote_Ammo","IEDLandSmall_Remote_Ammo"] call BIS_fnc_selectRandom;
  457. _vehicle = _class createVehicle (getpos player);
  458. _vehicle setVariable ["test", "works"];
  459. systemChat (_vehicle getVariable ["test","does not work"]);
  460.  
  461. but it for sure works on players, units, triggers, vehicles
  462.  
  463.  
  464.  
  465.  
  466. ACE3 ideas
  467. ace_weather fast time multiplier, day length, night length
  468. ace_IED sync module with trigger or marker to place random ieds in it
  469. ace_civs / ace_enemies = enemy/civil ocupation system
  470. keys that switch weapons do switch positions in vehicles as well
  471. static lmg reload
  472. empty mags appear on ground as litter
  473.  
  474.  
  475.  
  476.  
  477. 16:59 - aeroson: you can use this code to create vehice
  478. 16:59 - aeroson: "2S6M_Tunguska" createVehicle position player;
  479. 16:59 - aeroson: 2S6M_Tunguska is class name of the vehicle
  480. 16:59 - aeroson: you need to know the class name first
  481. 17:00 - aeroson: you can get classname of the thing you are looking at by watching this?
  482. 17:00 - aeroson: typeOf cursorTarget
  483.  
  484.  
  485.  
  486. 17:08 - aeroson: run this
  487. 17:08 - aeroson: to select target vehicle
  488. 17:08 - aeroson: battleBusTargetVehicle = cursorTarget;
  489. 17:09 - aeroson: then this to save all objects around it within 100m and save them into code, which will spawn them and attach them to the target vehicle
  490. 17:09 - aeroson: _radius = 100;
  491. _mainVehicle = battleBusTargetVehicle;
  492. _mainVehiclePos = getPosATL _mainVehicle;
  493.  
  494.  
  495. battleBusCreateCode = "";
  496.  
  497. addLine = {
  498. battleBusCreateCode = format["%1
  499. %2", battleBusCreateCode, _this];
  500. };
  501.  
  502.  
  503.  
  504. format['_mainVehicle = createVehicle ["%1", getPosATL player, [], 0, "CAN_COLIDE"];', typeof _mainVehicle] call addLine;
  505. format['_mainVehicle setVectorDirAndUp [%1, %2];', vectorDir _mainVehicle, vectorUp _mainVehicle] call addLine;
  506. format['_mainVehiclePos = getPosATL _mainVehicle;'] call addLine;
  507.  
  508. '' call addLine;
  509.  
  510.  
  511. {
  512. _vehicle = _x;
  513. if(!(isPlayer _vehicle) && _vehicle!=_mainVehicle) then {
  514.  
  515. format['_vehicle = createVehicle ["%1", [-100-random 100, -100-random 100, 0], [], 0, "CAN_COLIDE"];', typeof _vehicle] call addLine;
  516. format['_vehicle setPosATL (%1 vectorAdd _mainVehiclePos);', (getPosATL _vehicle) vectorDiff _mainVehiclePos] call addLine;
  517. format['_vehicle attachTo [_mainVehicle];'] call addLine;
  518. format['_vehicle setVectorDirAndUp [%1, %2];', vectorDir _vehicle, vectorUp _vehicle] call addLine;
  519.  
  520. '' call addLine;
  521.  
  522. };
  523.  
  524. } forEach (nearestObjects [getPosATL _mainVehicle, ["all"], _radius]);
  525. 17:12 - aeroson: 17:09 - aeroson: resulting battle bus creation code should be in variable battleBusCreateCode
  526. 17:09 - aeroson: so watch that variable and copy paste it to save you battle bus, or execute it to create you battle bus
  527.  
  528.  
  529. 17:21 - aeroson: exec line executes code once you click exec
  530. 17:22 - aeroson: watch line executes code every second and shows you the result
  531.  
  532.  
  533. 17:23 - aeroson: it has simulation enabled
  534. 17:23 - aeroson: look at it and execute
  535. 17:24 - aeroson: cursorTarget enableSimulation false
  536. 17:24 - aeroson: so it's physics will not be simulated and you can stack vehicles inside each other then
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement