Arma 3
77 ratings
Some basic A3 Scripting for people that have absolutely no frickin' idea what the hell they're doing.
By Blitz ÂceRosin
If you're like me and have absolutely no idea just what in the hell all of the gobbledygook on the Bohemia wiki for coding init lines in this game does, even when watching tutorials, then this is for you, I'll try to explain this slowly so we won't have to pause eating our crayons to put these in.
2
3
2
3
   
Award
Favorite
Favorited
Unfavorite
Adding an arsenal to an object.
So, say you want an arsenal box. Sure, you could just go to Inventory on the object and tick the arsenal box, but, let's say for some reason that isn't there, what the hell do you do?

In the init box for your container that you want to use as an arsenal, input the following.

["AmmoboxInit",[this,true]] call BIS_fnc_arsenal;

And just like that, your object SHOULD have a pretty little arsenal when you walk up to it in play mode.
Infinite ammunition on vehicles.
Doing drills? Practicing your strafing runs? Just generally sick of running out of ammo?

No problem!

Simply add the following line to the vehicles init. This also works for soldiers, but, only their primary and secondary weapons, I believe. I can confirm it doesn't work reliably with launchers.

this addeventhandler ["fired", {(_this select 0) setvehicleammo 1}]
Markers that follow units and delete when they die.
So, this will only follow one specific soldier/vehicle, but, I feel it's useful to know for the sake of attempting to do things.

We'll start with the .sqf file, that's going to be placed in the missions' folder (Located in Documents\Arma 3 - Other Profiles\[Profile name]\missions)

Name it something like markerscript.sqf or whatever, and open it in something like Notepad++, normal notepad will also work.

Paste in the following to markerscript.sqf

_marker = _this select 0; _vehicle = _this select 1; while {alive _vehicle} do { _marker setmarkerpos getpos _vehicle; sleep 0.5; }; deletemarker _marker;

With markerscript made, you'll now have to create the marker and soldier/vehicle, in the init of the soldier/vehicle, place the following code, remembering to replace the "Marker" with the actual name of your marker, otherwise it won't work.

If you saved markerscript as something else, remember to change that, too. Otherwise it won't work and you'll just get slapped in the face with a big, fat, throbbing error message.

nul = ["Marker", this] execVM "markerscript.sqf";

Now, if you start your mission, you'll notice that your chosen object now has a marker following it that updates every half-second with the position of whatever you put it on, and deletes itself once the unit is dead, or the vehicle is destroyed.

Here's an alternative marker script that just goes in the unit's init line, it's nowhere near as nice due to not being removed on death, but, it gets the job done.
[] spawn { while {not isnull Unit} do { "Marker" setmarkerpos getpos Unit; sleep 0.5; }; };
Other, community stuff.
Descriptions of what this stuff does will act as the link to the User's profile.

Make units unable to move/Stay in place.
this disableAI "PATH";
9 Comments
Sniperturtle 16 Oct, 2021 @ 10:29am 
With all the old ArmA scripting and addon sites down new creators will have to learn all these things the hard way again.
There is no shame however in downloading older mods and scripts and see how it was done in the past.
Best example for clean (albeit mostly obsolete) code is in my opinion the Command Engine 1.2 from "The Chain of Command". They had some cracks working on their stuff back in the days, and most of their coding ethics and examples still make a great standard in ArmA 3 and beyond.
Ciloon 5 Sep, 2021 @ 12:44am 
.
Pvt. Partz 28 Aug, 2021 @ 12:56pm 
I want to have the player spawn in a crouched/weapon holstered position but having trouble. Can anyone help? Even sipping a cup of coffee would be icing on the cake.
many pre-thanks
Meda 28 Aug, 2021 @ 3:51am 
Hit 'em with a razzle dazzle. :tfhapple:

//Change weapon sway (0 = disable, 1 = default, >1 = higher sway)
player setCustomAimCoef 0;


//Change recoil (0 = disable, 1 = default, >1 = stronger recoil)
player setUnitRecoilCoefficient 0;


//Slow down time (0 = freeze, 1 = default, >1 = faster)
setAccTime 0.1;


//Speed yourself up (Does not affect ladder climbing :tfhgrr:)
this setAnimSpeedCoef 1.2;


//Fixed firerate (Ridiculously fast shooting)
player addEventHandler ["Fired",{(_this select 0) setWeaponReloadingTime [gunner (vehicle (_this select 0)), currentMuzzle (gunner (vehicle (_this select 0))), 0];}];


//Spawn and attach a goat to every projectile you create.
_spawn = [] spawn {
player addEventHandler ["Fired", {
_null = _this spawn {
_projectile = _this select 6;
_goat = "Goat_Random_F" createVehicle position _projectile;
_goat attachto [_projectile,[0,0,0]];
};
}];
};
StarForgeTrooper 26 Aug, 2021 @ 5:27am 
Can I suggest some additions?

//You can hide an object by putting this in its init:
HideObject This;

//If you want soldiers to look in a specific direction, you can hide, say a watch somewere and give it a name and use this command.

This doWatch HiddenWatch_1;

//To lock a unit in either prone, crouching or standing, you can use the following command in its init.

This setUnitPos "UP"; //"UP" for standing, "MIDDLE" for crouch and "DOWN" for lying down.
Taizan 23 Aug, 2021 @ 10:21pm 
For placed groups to stay where you put each soldier add this to the group leader's init:

{ doStop _x } foreach units group this;

Stops making them move into default formation.

Keno vs 22 Aug, 2021 @ 2:22pm 
For unit to stay in place there is an other way:
doStop this;
This way they will start moving once contact is made, but will stay on position untill that.
Blitz ÂceRosin  [author] 20 Aug, 2021 @ 10:55pm 
Thanks for the addition! The description of it in the guide should link to your profile.
Epicness 20 Aug, 2021 @ 10:52pm 
add this


Units stay in place:
this disableAI "PATH";