Posted: . At: 9:45 AM. This was 6 years ago. Post ID: 12212
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


Very useful Arma 3 code for mods and missions.


A code sample that creates a weapon box with some ammo. Just change the class names to add a weapon of your choice to this box.

class cfgVehicles
{
	class Thing;
	class ThingX;
	class ReammoBox;
	class Strategic;
	class EAST_Box_Base;
	class NATO_Box_Base;
	class Railgun_Transport_Box: EAST_Box_Base
	{
		scope = 2;
		vehicleClass = "Ammo";
		displayName = "Railgun Box";
		editorPreview = "\A3\EditorPreviews_F\Data\CfgVehicles\Box_East_Wps_F.jpg";
		model = "\A3\weapons_F\AmmoBoxes\WpnsBox_F";
		hiddenSelections[] = {"Camo_Signs","Camo"};
		hiddenSelectionsTextures[] = {"A3\Weapons_F\Ammoboxes\data\AmmoBox_signs_OPFOR_CA.paa","A3\Weapons_F\Ammoboxes\data\AmmoBox_OPFOR_CO.paa"};
		icon = "iconCrateWpns";
		transportMaxWeapons = 4;
		transportMaxMagazines = 48;
		class TransportMagazines
		{
			class _xx_10Rnd_Railgun_Mag
			{
				magazine = "10Rnd_Railgun_Mag";
				count = 24;
			};
		};
		class TransportWeapons
		{
			class _xx_srifle_DMR_02_F
			{
				weapon = "srifle_DMR_02_F";
				count = 4;
			};
		};
	};
};

This code when put in the init of an object 500m up will light up an entire base. Very good for dark night-time missions, if you wish the base to be visible.

light = "#lightpoint" createVehicle getPos this;
light setLightBrightness 26.0;
light setLightAmbient [3.0, 2.0, 3.0];
light setLightColor [0.0, 1.0, 0.0];
light lightAttachObject [this, [0,0,0]];

Play some music when a player joins the server, then greet them with some information. Put this code into the initPlayerLocal.sqf file.

3 fademusic 0.5;
//--- Play random music
_track = ["AmbientTrack01a_F_Tacops","AmbientTrack01b_F_Tacops","AmbientTrack02a_F_Tacops","AmbientTrack02b_F_Tacops","AmbientTrack03a_F_Tacops","AmbientTrack03b_F_Tacops","AmbientTrack04a_F_Tacops","AmbientTrack04b_F_Tacops","EventTrack01a_F_Tacops","Wasteland","Fallout","Defcon","MAD","SkyNet","Track08_Night_ambient","Track07_ActionDark","EventTrack01_F_Orange","ambienttrack01_f_exp","ambienttrack01a_f_exp","ambienttrack01b_f_exp","ambienttrack02_f_exp","ambienttrack02a_f_exp","ambienttrack02b_f_exp","ambienttrack02c_f_exp","ambienttrack02d_f_exp","leadtrack01_f_exp","leadtrack01a_f_exp","leadtrack01b_f_exp","leadtrack01c_f_exp","leadtrack02_f_exp","leadtrack03_f_exp","leadtrack04_f_exp"] call BIS_fnc_selectRandom;
 
//--- Play memory music
playmusic _track;
 
addmusiceventhandler [
	"MusicStop", {
		[player call BIS_fnc_locationDescription, str(date select 1) + "." + str(date select 2) + "." + str(date select 0), str(groupId (group player))] spawn BIS_fnc_infoText;
 
		[WEST,"HQ"] sideChat format ["Hello %1, welcome to the server. You are in group: %2. You are playing: %3 on %4.", name player, str(groupId (group player)),str productVersion, str(worldName)];
	}
];

How to disable the load and save buttons on the arsenal. Put this code into the initPlayerLocal.sqf file.

[ missionNamespace, "arsenalOpened", {
    disableSerialization;
    _display = _this select 0;
    {
        ( _display displayCtrl _x ) ctrlSetText "Disabled";
        ( _display displayCtrl _x ) ctrlSetTextColor [ 1, 0, 0, 0.5 ];
        ( _display displayCtrl _x ) ctrlRemoveAllEventHandlers "buttonclick";
    }forEach [ 44146, 44147 ];
} ] call BIS_fnc_addScriptedEventHandler;

Spawn an interesting decoration in your base.

_posnew10 = getpos can9;
_sol4 = createSimpleObject ["a3\air_f_beta\Heli_Transport_02\Main_Rotor_center_F.p3d", _posnew10];
_sol4 setPos [_posnew10 select 0, _posnew10 select 1, 0.4];

Spawn a Mohawk helicopter wreck.

//spawn AW101 Merlin wreck.
_posnew4 = getpos junk9;
_sol5 = createSimpleObject ["a3\air_f_beta\Heli_Transport_02\Heli_Transport_02_wreck_F.p3d", _posnew4];
_sol5 setPos [_posnew4 select 0, _posnew4 select 1, 0.9];

Some nice code to greet the player when they join the server. This code prints information about the player`s weapon when they join the server. As well as other stuff. This is quite nice.

// Prepare variables.
 
private ["_pname","_picture","_color"];
 
// Customize hint colors.
_color = "#FFCC33";
_pname = name player;
 
// Grab image of players primary weapon. 
_picture = getText (configFile >> "cfgWeapons" >> primaryWeapon player >> "picture");
_gun = getText (configFile >> "cfgWeapons" >> primaryWeapon player >> "displayName");
_gunInfo = getText (configFile >> "cfgWeapons" >> primaryWeapon player >> "descriptionShort");
 
hint parseText format["
	Welcome soldier! <br/> <t size='1.0' color='#668CFF'>%1</t> <br/>
	Operation Silent Spring.<br/>
	Your fight has begun.<br/>
	Get your gear ready and get into battle.!<br/>
	You currently have a: %2.<br/>
	%5.<br/>
	<t color='%4'><img size='4' image='%3'/></t>",
	_pname, _gun, _picture, _color, _gunInfo
];

This code placed in the initServer.sqf file will create a custom location in your base.

_location = createLocation [ "NameLocal" , [28305.7,25753.9,0.000669479], 100, 100];
_location setText "CSAT FOB.";

Very useful to personalize the base. This allows CSAT FOB to be a respawn location.

Spawn a machine gun and one guy to man it.

// Spawning a MG guy near tower.
 
_randPos3 = [_randPos2, 1, 60, 3, 0, 20, 0] call BIS_fnc_findSafePos;
 
_mg = createVehicle ["O_HMG_01_high_F", _randPos3, [], 0, "CAN_COLLIDE"];
 
_mgguy = [_randPos3, EAST, ["O_Soldier_F"],[],[],[],[],[],232] call BIS_fnc_spawnGroup;
 
((units _mgguy) select 0) moveInGunner _mg;

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.