Posted: . At: 8:50 AM. This was 2 years ago. Post ID: 15760
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.


Some more very useful Arma 3 scripting commands.


There are many very useful scripting commands for Arma 3 that are less known. The one below will return the number of days the player has played Arma 3 in total.

_daysplayed = getStatValue "GamePlayedDays";

Use this code to determine if a player has finished the Bootcamp campaign before jumping into multiplayer.

_bootme = getStatValue "BCFirstDeployment";
 
if (_bootme != 1) then {
        _message = _message + "Please finish the Bootcamp campaign before playing.<br /><br />";
        _message = _message + "<t align='right' size='8' shadow='1'><img image='\a3\Missions_F_Bootcamp\data\img\Boot_m02_overview_CA.paa' /></t><br /><br />";
} else {
        _message = _message + "Welcome to Afghanistan Zeus ops.<br /><br />";
};

This works and is very useful I think.

The code below will apply a certain procedural texture to a couple of objects named “zone1” and “zone2”.

{
	_x setObjectTextureGlobal [0, "#(ai,64,64,1)fresnelGlass()"];
} forEach [zone1,zone2];

Run this code in the initPlayerLocal.sqf and this will save the player`s loadout when they exit the Arsenal.

[missionnamespace,"arsenalClosed", {
	[player, [missionNamespace, "inventory_var"]] call BIS_fnc_saveInventory;
	titletext ["Arsenal loadout saved.", "PLAIN DOWN"];
}] call bis_fnc_addScriptedEventhandler;

A very useful code snippet.

Set a random time for the mission to start. Run this in the initServer.sqf.

private _date = missionStart select [0, 5];
 
private _times = [_date] call BIS_fnc_sunriseSunsetTime;
private _startTime = (_times select 0) + (random ((_times select 1) - (_times select 0) - 1));
private _startHour = floor _startTime;
private _startMinute = (_startTime - _startHour) * 60;
 
_date set [3, _startHour];
_date set [4, _startMinute];
 
setDate _date;

Put this code below in the init.sqf. This allows a player to fully heal when they use a First Aid Kit.

player addEventHandler ["HandleHeal", {
	_this spawn {
		params ["_injured","_healer"];
		missionNamespace setVariable ['Health', damage _injured,FALSE];
		_damage = Health;
		if (_injured == _healer) then {
			waitUntil { damage _injured != _damage };
			if (damage _injured < _damage) then {
				cutText ["You used Bandages and Morphine.", "PLAIN DOWN", 8];
				_injured setDamage 0;
			};
		};
	};
}];

These code samples should be most helpful when coding a mission.


Leave a Comment

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