Posted: . At: 8:44 PM. This was 8 years ago. Post ID: 9750
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.

Useful Arma 3 code samples to improve your missions.

This code will make your Arma 3 missions run much more smoothly. And provide some nice tricks to make the mission more enjoyable.

Put this into the initPlayerLocal.sqf file. This will remove stamina and make weapon sway much more realistic, i.e no Micheal J Fox mode after running.

player setCustomAimCoef 0.34;
player setUnitRecoilCoefficient 0.50;
player enablestamina false;
 
["InitializePlayer", [player]] call BIS_fnc_dynamicGroups;

Put this code into the onPlayerKilled.sqf file to save the player`s loadout when they die. And give a reassuring message too.

missionNamespace setVariable ["last_loadout",getUnitLoadout (_this select 0),false];
 
["Griffin", "2 minutes until respawn, hang in there.."] call BIS_fnc_showSubtitle;

This code in the onPlayerRespawn.sqf file will reenable the stamina settings and reload the players arsenal.

player setCustomAimCoef 0.34; 
player setUnitRecoilCoefficient 0.50;
player enablestamina false;
 
_loadout = missionNamespace getVariable "last_loadout"; if (!isNil "_loadout") then {(_this select 0) setUnitLoadout _loadout;};

Run this code in the initServer.sqf file to initialize the dynamic groups system on the server and also run the sandstorm code that will make Altis look rather arid. This sandstorm function runs locally, so it will run on all player machines and look cool.

["Initialize"] call BIS_fnc_dynamicGroups; // Initializes the Dynamic Groups framework
 
[player, -1, 0.8, true] call BIS_fnc_sandstorm;

This script when put into the init.sqf will print who killed you and with what. And you can see the name of an enemy you have killed.

KAI_fnc_killedInfo = {
	_victimName = name (_this select 0);
	_killerName = name (_this select 1);
	_weaponName = getText (configFile >> "cfgWeapons" >> currentWeapon (_this select 1) >> "displayname");
	hintSilent format ["%1 was killed by %2 with a %3", _victimName, _killerName, _weaponName];
};
 
{
    _id = _x addMPEventHandler ["MPKilled", {
		_nul = _this call KAI_fnc_killedInfo;
    }];
} foreach allUnits;

If the mission designer wants a custom uniform for the players, this is how to do it. This code in the onPlayerRespawn.sqf file will give the player a custom grey urban camo suit.

player setCustomAimCoef 0.34; 
player setUnitRecoilCoefficient 0.50;
player enablestamina false;
 
_loadout = missionNamespace getVariable "last_loadout"; if (!isNil "_loadout") then {(_this select 0) setUnitLoadout _loadout;};
 
player setObjectTextureGlobal [0, "\A3\characters_f\common\data\coveralls_urbancamo_co.paa"];

Enter this into the initPlayerLocal.sqf file to give the custom grey urban camo on player joining the server.

player setCustomAimCoef 0.34;
player setUnitRecoilCoefficient 0.50;
player enablestamina false;
 
player setObjectTextureGlobal [0, "\A3\characters_f\common\data\coveralls_urbancamo_co.paa"];

This code when placed into the init of a flat TV will make the device information from the laptop screen appear on it.

this setObjectTextureGlobal [0, "a3\structures_f_epc\items\electronics\data\electronics_screens_laptop_device_co.paa"];

To increase the camouflage value of your player character, put this into your initPlayerLocal.sqf and the onPlayerRespawn.sqf.

player setUnitTrait ["camouflageCoef",0.2];

This will make it harder for AI enemies to see you.

Leave a Comment

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