Arma 3
94 ratings
Small scripts for playing as Zeus or just for fun!
By SirFlavalot
This is a collection of small scripts I use when playing a mission as Zeus, or just to have fun. Some I made from scratch, others I found online and tweaked. Probably the coolest script shoots RPG rounds with your bullets!
   
Award
Favorite
Favorited
Unfavorite
Intro
I usually just run these scripts in the console when I'm playing as Zeus (i.e. game master) during a multiplayer mission. Things to remember when pasting code into the console:
  • In multiplayer, clicking the LOCAL EXEC button only runs the code for your player character - use GLOBAL EXEC to run for ALL players. E.g. if you paste "player allowDamage false" into the console text box and click LOCAL EXEC, you'll be invulnerable; click GLOBAL EXEC and ALL players will be invulnerable

Event handlers "stack", so to prevent multiples when re-running a script that creates handlers, you'll often see a removeEventHandler, then a createEventHandler.
RPG bullets!
This script shoots a RPG-7 missile in the same direction and at the same speed as the bullet exiting your weapon. With a high enough fire rate and big enough explosion YOU CAN FLY!
player removeeventhandler["fired", FEH_missile]; FEH_missile = player addeventhandler ["fired", { _bullet = nearestObject [_this select 0,_this select 4]; _bulletpos = getPosASL _bullet; _o = "R_PG7_F" createVehicle _bulletpos; _weapdir = player weaponDirection currentWeapon player; _dist = 11; _o setPosASL [ (_bulletpos select 0) + (_weapdir select 0)*_dist, (_bulletpos select 1) + (_weapdir select 1)*_dist, (_bulletpos select 2) + (_weapdir select 2)*_dist ]; _up = vectorUp _bullet; _o setVectorDirAndUp[_weapdir,_up]; _o setVelocity velocity _bullet; }];

Here are some of the different missile / bomb types you can spawn.
"R_PG7_F", "M_NLAW_AT_F", "R_PG32V_F", "R_TBG32V_F", "M_TITAN_AT", "M_TITAN_AP", "Bo_GBU12_LGB", "BombCluster_01_Ammo_F"

Add this for Infininte ammo (you must have at least one additional clip for it to work).
player removeeventhandler["fired", FEH_playerAmmo]; FEH_playerAmmo = player addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];

Handgun only (put as first line of event handler code).
if (currentWeapon player != handgunWeapon player) exitWith {};

Bullet bombs are dangerous! Make player invulnerable.
player allowDamage false;
Any gun -> Shotgun! (Vehicle version too)
This script turns a player's gun into a shotgun! You can tweak the number of extra bullets fired, the spread, etc. Works for any type of gun, also grenades & rockets.

if ( !(isNil "FEH_shotgunPlayer") ) then { player removeeventhandler["fired", FEH_shotgunPlayer];}; FEH_shotgunPlayer = player addeventhandler ["fired", { _numBullets = 6; // # bullets added to each bullet fired _spread = 1; // bullets spread angle _rndAngle = 0.5; // max random angle added to spread _startRadius = 0.0; // distance sideways bullets appear from original _distanceOut = 0.75; // distance forward bullets appear from original _bulletsPerCircle = 6; // # bullets per each revolution of spiral _degreeStep = 360/_bulletsPerCircle; // populate offsets array _bulletInfo = []; _angle = 0; while {_angle < _degreeStep * _numBullets} do { _radius = _startRadius + (_angle * 0.0003); _offsetX = _radius * ( cos _angle ); _offsetZ = _radius * ( sin _angle ); _offset = [_offsetX, _distanceOut, _offsetZ]; _angleRadius = _angle / 360; _angleX = _spread * (cos _angle) * _angleRadius; _rndAngleX = _rndAngle/2 - random(_rndAngle); _angleZ = _spread * (sin _angle) * _angleRadius; _rndAngleZ = _rndAngle/2 - random(_rndAngle); _angles = [_angleX + _rndAngleX, _angleZ + _rndAngleZ]; _bulletInfo pushBack [_offset, _angles]; _angle = _angle + _degreeStep; }; // get bullet info _bullet = nearestObject [_this select 0,_this select 4]; _bulletType = typeOf _bullet; _bulletpos = getPos _bullet; _weapdir = player weaponDirection currentWeapon player; _up = vectorUp _bullet; _bulletPitchBank = _bullet call BIS_fnc_getPitchBank; _bulletPitch = _bulletPitchBank select 0; _bulletBank = _bulletPitchBank select 1; _bulletDir = getDir _bullet; // spawn bullets { _o = createVehicle [_bulletType, [0,0,0], [], 0, "CAN_COLLIDE"]; _o setVectorDirAndUp[_weapdir,_up]; _offset = _x select 0; _vecToAdd = (_o modelToWorld _offset); _bulletPos2 = _bulletPos vectorAdd _vecToAdd; _o setPos _bulletPos2; _angles = _x select 1; _dir = _angles select 0; _pitch = _angles select 1; _o setDir _bulletDir + _dir; [_o, _bulletPitch + _pitch, _bulletBank] call BIS_fnc_setPitchBank; _o setVelocityModelSpace [0, vectorMagnitude (velocity _bullet), 0]; } forEach _bulletInfo; }];

This script will add the shotgun effect to any VEHICLE the player is in.
veh = objectParent player; if (!isNull veh) then { _FEH_shotgunVehicle = veh getvariable "FEH_shotgunVehicle"; if ( !isNil "_FEH_shotgunVehicle" ) then { veh removeeventhandler["fired", _FEH_shotgunVehicle]; veh setVariable ["FEH_shotgunVehicle", nil]; }; _FEH_shotgunVehicle = veh addeventhandler ["fired", { _numBullets = 6; // # bullets added to each bullet fired _spread = 1; // bullets spread angle _rndAngle = 0.5; // max random angle added to spread _startRadius = 0.0; // distance sideways bullets appear from original _distanceOut = 3; // distance forward bullets appear from original _bulletsPerCircle = 6; // # bullets per each revolution of spiral _degreeStep = 360/_bulletsPerCircle; // populate offsets array _bulletInfo = []; _angle = 0; while {_angle < _degreeStep * _numBullets} do { _radius = _startRadius + (_angle * 0.0003); _offsetX = _radius * ( cos _angle ); _offsetZ = _radius * ( sin _angle ); _offset = [_offsetX, _distanceOut, _offsetZ]; _angleRadius = _angle / 360; _angleX = _spread * (cos _angle) * _angleRadius; _rndAngleX = _rndAngle/2 - random(_rndAngle); _angleZ = _spread * (sin _angle) * _angleRadius; _rndAngleZ = _rndAngle/2 - random(_rndAngle); _angles = [_angleX + _rndAngleX, _angleZ + _rndAngleZ]; _bulletInfo pushBack [_offset, _angles]; _angle = _angle + _degreeStep; }; // get bullet info _bullet = nearestObject [_this select 0,_this select 4]; _bulletType = typeOf _bullet; _bulletpos = getPos _bullet; _weapdir = veh weaponDirection currentWeapon veh; _up = vectorUp _bullet; _bulletPitchBank = _bullet call BIS_fnc_getPitchBank; _bulletPitch = _bulletPitchBank select 0; _bulletBank = _bulletPitchBank select 1; _bulletDir = getDir _bullet; // spawn bullets { _o = createVehicle [_bulletType, [0,0,0], [], 0, "CAN_COLLIDE"]; _o setVectorDirAndUp[_weapdir,_up]; _offset = _x select 0; _vecToAdd = (_o modelToWorld _offset); _bulletPos2 = _bulletPos vectorAdd _vecToAdd; _o setPos _bulletPos2; _angles = _x select 1; _dir = _angles select 0; _pitch = _angles select 1; _o setDir _bulletDir + _dir; [_o, _bulletPitch + _pitch, _bulletBank] call BIS_fnc_setPitchBank; _o setVelocityModelSpace [0, vectorMagnitude (velocity _bullet), 0]; } forEach _bulletInfo; }]; veh setVariable ["FEH_shotgunVehicle", _FEH_shotgunVehicle]; };
Here, doggie!
Spawn pet doggie who follows you. Can create other animals as well (see calls at end)!
SF_petFollow = { params["_src", "_animalType"]; private["_animalClassname"]; if ( _animalType == "Dog" ) then { _animalClassname = "Fin_random_F"; }; if ( _animalType == "Sheep" ) then { _animalClassname = "Sheep_random_F"; }; if ( _animalType == "Goat" ) then { _animalClassname = "Goat_random_F"; }; if ( _animalType == "Rabbit" ) then { _animalClassname = "Rabbit_F"; }; if ( _animalType == "Hen" ) then { _animalClassname = "Hen_random_F"; }; if ( _animalType == "Snake" ) then { _animalClassname = "Snake_random_F"; }; _animal = createAgent [_animalClassname, getPos _src, [], 5, "CAN_COLLIDE"]; _animal setVariable ["BIS_fnc_animalBehaviour_disable", true]; nul = [_src, _animal, _animalType] spawn { params["_src", "_animal", "_animalType"]; _animalGoMove = _animalType + "_Run"; _animalIdleMove = _animalType + "_Idle_Stop"; if ( _animalType == "Dog" ) then { _animalGoMove = "Dog_Sprint"; }; if ( _animalType == "Rabbit" ) then { _animalGoMove = "Rabbit_Hop"; }; if ( _animalType == "Hen" ) then { _animalGoMove = "Hen_Walk"; }; if ( _animalType == "Snake" ) then { _animalGoMove = "Snakes_Move"; }; _animalMoving = true; _moveDist = 5; while {alive _animal} do { if (_animal distance _src > _moveDist) then { if ( !_animalMoving ) then { _animal playMove _animalGoMove; _animalMoving = true; }; } else { if ( _animalMoving ) then { _animal playMove _animalIdleMove; _animalMoving = false; }; }; if ( _animalMoving ) then { _animal moveTo getPos _src; }; sleep 0.5; }; }; }; [player, "Dog"] call SF_petFollow; [player, "Sheep"] call SF_petFollow; [player, "Goat"] call SF_petFollow; [player, "Rabbit"] call SF_petFollow; [player, "Hen"] call SF_petFollow; [player, "Snake"] call SF_petFollow;
Vehicle turbo
Makes you go faster and faster while you hold down Shift key. This is mostly code from http://www.armaholic.com/page.php?id=24049 (thanks ProGamer!), with a few tweaks of my own.

fn_Turbo = { _veh = vehicle player; _speed = speed _veh; _velXM = velocityModelSpace _veh select 0; _velYM = velocityModelSpace _veh select 1; if(_speed <= 1 || _speed >= 180 || _velXM > _velYM) exitWith {}; _speedBoost = 0.1; _curVMS = velocityModelSpace _veh; _newVMS = _curVMS vectorAdd [0, _speedBoost, 0]; _veh setVelocityModelSpace _newVMS; }; dokeyDown={ private ["_handled","_key_delay"] ; _key_delay = 0.01; _handled = false ; if (player getvariable["key",true] and (_this select 1) == 46) exitwith { player setvariable["key",false]; [_key_delay] spawn {sleep (_this select 0);player setvariable["key",true]; }; _handled }; if ((_this select 1) == 42 and speed player >1) then { if(vehicle player != player && vehicle player isKindOf "LandVehicle" && isTouchingGround vehicle player && driver vehicle player == player) then { call fn_Turbo; _handled=true; }; }; _handled; }; waituntil {!(IsNull (findDisplay 46))}; if ( !(isNil "_keydownEventHandler") ) then { (findDisplay 46) displayRemoveEventHandler ["KeyDown", _keydownEventHandler]; }; _keydownEventHandler = (FindDisplay 46) displayAddEventHandler ["keydown","_this call dokeyDown"];
Healing yourself, others, vehicles etc.
Often I'll be sneaky and play the mission like normal, but be logged in as admin so I can run console scripts. This will play the "healing" animation so it looks like you're doing a normal heal, but you can add all kinds of stuff right after.

Here's the whole collection of commands I use this way; I usually don't run all of them, just the first few sections. I'll break the pieces down after.
player playActionNow "Medic"; player setdamage 0.0; src = player; {_x setDamage 0;} forEach (src nearEntities ["Man", 25]); obj = (nearestObjects [src, ["LandVehicle", "tank", "helicopter", "ship", "plane"], 10]) select 0; obj setdamage 0.0; obj setVehicleAmmo 1; obj allowDamage false; obj removeeventhandler["fired", FEH_vehicleAmmo]; FEH_vehicleAmmo = obj addeventhandler ["fired", {(_this select 0) setvehicleammo 1}]; player allowDamage false; player removeeventhandler["fired", FEH_playerAmmo]; FEH_playerAmmo = player addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];

Plays the "healing" animation, it must come first.
player playActionNow "Medic";

Heal yourself and others within 25 meters of you.
player setdamage 0.0; src = player; {_x setDamage 0;} forEach (src nearEntities ["Man", 25]);

The "src" variable allows you to do these things using the position of other objects instead of the player. I use it mainly to affect things near the position of Zeus' camera.
src = curatorCamera;

This gets the nearest land/water/air craft within 10 meters, repairs and rearms it (for the rearm to work you must be in the gunner seat).
obj = (nearestObjects [src, ["LandVehicle", "tank", "helicopter", "ship", "plane"], 10]) select 0; obj setdamage 0.0; obj setVehicleAmmo 1;

Make craft invulnerable and give it infinite ammo.
obj allowDamage false; obj removeeventhandler["fired", FEH_vehicleAmmo]; FEH_vehicleAmmo = obj addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];

Make player invulnerable and give them infinite ammo.
player allowDamage false; player removeeventhandler["fired", FEH_playerAmmo]; FEH_playerAmmo = player addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];
Enemy & corpse indicators
This code puts a colored indicator under enemies (in this case anything other than west or civilian), going from an opaque yellow circle to a dark red oval the closer they are.
["oef1", "onEachFrame"] call BIS_fnc_removeStackedEventHandler; ["oef1", "onEachFrame", { _men = player nearEntities ["Man", 300]; { if (side _x != WEST && side _x != CIVILIAN) then { _vis = ([objNull, "VIEW"] checkVisibility [eyePos player, eyepos _x]); if (_vis > 0) then { _pos = getPosVisual _x; _pos2 = [_pos select 0, _pos select 1, (_pos select 2) - 0.5]; _dist = (player distance _x); _distRatio100 = 100 / (_dist + 1); _width = _distRatio100 min 1; _height = 0.5 min (_dist * 0.5) / 100 max 0.15; _alpha = (50/_dist) + 0.1 min 0.5; _green = (_dist - 100) / 100 min 1 max 0; _icon = "\A3\ui_f\data\map\markers\military\dot_CA.paa"; _mult = 1.5; drawIcon3D [_icon, [1,_green,0,_alpha], _pos2, _width*_mult, _height*_mult, 0]; } }; } forEach _men; }] call BIS_fnc_addStackedEventHandler;

This puts a white oval under nearby corpses.
["oef2", "onEachFrame"] call BIS_fnc_removeStackedEventHandler; ["oef2", "onEachFrame", { _range = 48; _nearMen = position player nearObjects["Man", _range]; { if !(alive _x) then { _vis = ([objNull, "VIEW"] checkVisibility [eyePos player, eyepos _x]); if (_vis > 0 || true) then { _pos = getPosVisual _x; _pos2 = [_pos select 0, _pos select 1, (_pos select 2) - 0.5]; _dist = (player distance _x); _distRatio = _range / (_dist + 1); _width = _distRatio min 1; _height = 0.5 min (_dist * 0.5) / _range max 0; _alpha = ((_range - _dist) / _range) min 0.5 max 0; _icon = "\A3\ui_f\data\map\markers\military\dot_CA.paa"; _mult = 1.5; drawIcon3D [_icon, [1,1,1,_alpha], _pos2, _width*_mult, _height*_mult, 0]; }; }; } forEach _nearMen; }] call BIS_fnc_addStackedEventHandler;
Swim & run uphill fast, add all objects to Zeus
This script does a number of things on a timer:
  • If you're under water you swim MUCH faster
  • If you're going uphill > 30 degrees run MUCH faster
  • If there's a Zeus, make all objects available to him
SwimFastScriptHandle = [] spawn { while {true} do { if (underwater player) then { player setAnimSpeedCoef 5; } else { overLand = !(position player isFlatEmpty [-1, -1, -1, -1, 0, false] isEqualTo []); gradAngle = [getPos player, getDir player] call BIS_fnc_terrainGradAngle; if (overLand && gradAngle >= 30) then { player setAnimSpeedCoef 3; } else { player setAnimSpeedCoef 1; }; if ( !isNull(findDisplay 312) ) then { { {_x addCuratorEditableObjects [allUnits,true];_x addCuratorEditableObjects [vehicles,true]; } forEach allCurators; } remoteExec ["bis_fnc_call", 2]; }; }; sleep 0.25; }; };
Loop script on all clients, change AI side
If you've run some scripts for people in-game then someone joins, re-running it globally for everyone so the new person gets it becomes a pain. Here's how you run a script on all clients on a timer, which in this case makes players and their craft invulnerable, with infinite ammo. To stop the loop, set SF_clientLoop to false.
SF_clientLoop = true; nul = [] spawn { while {SF_clientLoop} do { { player setdamage 0.0; player allowDamage false; src = player; obj = (nearestObjects [src, ["LandVehicle", "tank", "helicopter", "ship", "plane"], 10]) select 0; obj setdamage 0.0; obj allowDamage false; obj setVehicleAmmo 1; } remoteExec ["bis_fnc_call", -2]; sleep 1; }; };

This changes any ai unit within 50 meters of Zeus' camera to east.
_allUnits = []; _aiUnits = []; { if (curatorCamera distance _x < 55) then { _allUnits pushBack _x; if ( !isPlayer(_x) ) then { _aiUnits pushBack _x; }; }; } forEach allUnits; if ( count _aiUnits > 0 ) then { _newGroup = createGroup [east, true]; _aiUnits joinSilent grpNull; _aiUnits joinSilent _newGroup; }
23 Comments
XpeditionXD8 21 Dec, 2018 @ 3:36pm 
okay, I'll try this, Thanks!
SirFlavalot  [author] 21 Dec, 2018 @ 12:59pm 
Arma uses the side of the CREW to determine if you can connect to the drone or not. So you just need to change the crew side to your faction and you can connect.

Here's a handy function I wrote that will change the side of the crew of a craft.

setCrewSide = {
params["_craft", "_side"];

if (side _craft == _side) exitWith {};

_aiUnits = units _craft;
_newGroup = createGroup [_side, true];

_aiUnits joinSilent grpNull;
_aiUnits joinSilent _newGroup;
};


So if you have a drone with the variable name uav, here's how you'd call the function to set the crew to WEST:

[uav, WEST] call setCrewSide;
XpeditionXD8 20 Dec, 2018 @ 3:33pm 
Do you know any scripts that can let players have access to every UAV in the game no matter which faction the player is in? They can have their faction of terminal (EX: Blufor players use NATO terminal), but they can access any faction of uav (NATO player can connect to CSAT or AAF Faction drones/UAV's)?
Garrussian 26 Oct, 2018 @ 12:20pm 
@DJHonore try some combination with (vehicle player) instead of player.
DJHonore 9 Mar, 2018 @ 6:27pm 
Any way to make the rpg bullets script work with vehicle weapons?
DJHonore 14 Feb, 2018 @ 3:54pm 
Cool stuff
Gnarlycuga 22 Jan, 2018 @ 5:42pm 
Wow what a coincidence I have found you falva (this is charlie)
SirFlavalot  [author] 2 Jan, 2018 @ 5:40am 
Govrin - this works I use it all the time. Again, you need at least 1 clip of ammo in your inventory the same type as the one you're shooting. Paste this into your console:

player removeeventhandler["fired", FEH_playerAmmo];
FEH_playerAmmo = player addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];
Govrin. 30 Dec, 2017 @ 10:36am 
the infinte ammo dosnt work even if i have one more clip
SirFlavalot  [author] 19 Dec, 2017 @ 12:52pm 
Player shotgun script updated, and added a version for vehicles.