Ballistic's Altis Sandbox
Ballistic  [developer] Sep 12, 2013 @ 8:09pm
Scripts Used in the Sandbox.
Here are the scripts that are currently being used in the Altis Sandbox.

Use them for your own purposes. Most of them are quite basic which reflects my level of expertise but that hopefully means they will be a good stepping stone for people to learn from and create there own missions. These are .sqf files that you place in your mission directory. Feel free to un-.pbo the mission as well if that helps your understanding.

NEW Save Loadout Script

The updates new save loadout script that can repeatedly save over and then will restore the last saved loadout upon the player's respawn through the use of the respawn Event Handler.
_host = _this select 0;
_caller = _this select 1;
_id = _this select 2;

_uniform = uniform _caller;
_vest = vest _caller;

_backpack = backpack _caller;

_headgear = headgear _caller;
_goggles = goggles _caller;

_mags = magazines _caller;
_items = items _caller;
_assitems = assignedItems _caller;

_priweapon = primaryWeapon _caller;
_priattach = primaryWeaponItems _caller;
_primag = primaryWeaponMagazine _caller;
_secweapon = secondaryWeapon _caller;
_secmag = secondaryWeaponMagazine _caller;
_handgun = handgunWeapon _caller;
_hgunattach = handgunItems _caller;
_hgunmag = handgunMagazine _caller;

hint "Saving Loadout:";
sleep 1;

if (_uniform != "") then {hint "Uniform Saved"; sleep 1};
if (_vest != "") then {hint "Vest Saved"; sleep 1};

if (_backpack != "") then {hint "Backpack Saved"; sleep 1};

if (_headgear != "") then {hint "Headgear Saved"; sleep 1};
if (_goggles != "") then {hint "Goggles Saved"; sleep 1};

if (_priweapon != "") then {hint "Primary Weapon Saved"; sleep 1};
if (_secweapon != "") then {hint "Secondary Weapon Saved"; sleep 1};
if (_handgun != "") then {hint "Handgun Saved"; sleep 1};

hint "Loadout Saved!";
playMusic "Restore";
sleep 2;
hint "";

savedloadout = [_uniform, _vest, _backpack, _headgear, _goggles, _mags, _items, _assitems, _priweapon, _priattach, _primag, _secweapon, _secmag, _handgun, _hgunattach, _hgunmag];

_caller addEventHandler ["Respawn", {_this execVM "scripts\loadouts\respawn.sqf"}];

The only difference between the old and the new is instead of adding an action that will restore your loadout when used, this adds and Event Handler for when the _caller respawns it executes a modified restore loadout script that replaces the users gear with the desired saved loadout.

Teleports

This is a really basic script spruced up with some nice titleCuts. Again through an addAction command. This excerpt is for the teleportation back to the Spawn Area.
_host = _this select 0;
_caller = _this select 1;
_id = _this select 2;

titleCut ["", "BLACK OUT", 1];

sleep 1;

titleCut ["Spawn Area", "BLACK FADED"];

_caller setPos [(getPos Whiteboard_Spawn select 0), (getPos Whiteboard_Spawn select 1) -10, 0];

sleep 2.5;

titleCut ["", "BLACK IN", 3];

Weapon Containers

Another simple one, but again if you are starting out it's good to have resources like this. This script is executed through the init.sqf.
nul = [] execVM "scripts\weapons.sqf";
This excerpt is for the container holding the supplies. I got the classnames from the SIX Config Browser[browser.six-projects.net], hopefully it gets updated to include the stuff from full release.
clearWeaponCargo Supply_Box;
clearMagazineCargo Supply_Box;
clearItemCargo Supply_Box;
clearBackpackCargo Supply_Box;

Supply_Box addItemCargo ["FirstAidKit", 1000];

Supply_Box addWeaponCargo ["Binocular", 50];
Supply_Box addWeaponCargo ["Rangefinder", 50];

Supply_Box addItemCargo ["ItemGPS", 50];
Supply_Box addItemCargo ["B_UAVTerminal", 50];
Supply_Box addItemCargo ["NVGoggles", 50];

Supply_Box addItemCargo ["Medikit", 30];
Supply_Box addItemCargo ["MineDetector", 30];

Vehicle Clearing Script

Called through a trigger activated on Radio channels Alpha through to Echo, this script clears all vehicles of a certain type within a triggers area. The script is activated using the line
null = [spawnclearing] execVM "scripts\cleanup\clearspawn.sqf";
This is the .sqf for the Spawn Area clearing, note that it clears entities that fall under AllVehicles (Land, Ship and Air) as well as Autonomous, for all those pesky Hover Bikes that are left over.
_spawnclearing = _this select 0;
_vehicles = [];
_vehicles = entities "AllVehicles";
{
if ( _x isKindOf "AllVehicles" or _x isKindOf "Autonomous" and count crew _x == 0) then {
sleep 0.5;
if ( [_spawnclearing, getpos _x] call BIS_fnc_inTrigger) then {deleteVehicle _x};
};
} foreach _vehicles;

OLD Save Loadout Script

This is used with
addAction ["Save Loadout", "scripts\loadouts\save1.sqf"];
This was used in the older build of the sandbox which required save and then a restore from one of three seperate loadout panels.
_host = _this select 0;
_caller = _this select 1;
_id = _this select 2;

_host removeAction _id;

_uniform = uniform _caller;
_vest = vest _caller;

_backpack = backpack _caller;

_headgear = headgear _caller;
_goggles = goggles _caller;

_mags = magazines _caller;
_items = items _caller;

_priweapon = primaryWeapon _caller;
_priattach = primaryWeaponItems _caller;
_primag = primaryWeaponMagazine _caller;
_secweapon = secondaryWeapon _caller;
_secmag = secondaryWeaponMagazine _caller;
_handgun = handgunWeapon _caller;
_hgunattach = handgunItems _caller;
_hgunmag = handgunMagazine _caller;

hint "Saving Loadout 1:";
sleep 1;

if (_uniform != "") then {hint "Uniform Saved"; sleep 1};
if (_vest != "") then {hint "Vest Saved"; sleep 1};

if (_backpack != "") then {hint "Backpack Saved"; sleep 1};

if (_headgear != "") then {hint "Headgear Saved"; sleep 1};
if (_goggles != "") then {hint "Goggles Saved"; sleep 1};

if (_priweapon != "") then {hint "Primary Weapon Saved"; sleep 1};
if (_secweapon != "") then {hint "Secondary Weapon Saved"; sleep 1};
if (_handgun != "") then {hint "Handgun Saved"; sleep 1};

hint "Attachments Saved";
sleep 1;
hint "Magazines Saved";
sleep 1;
hint "Items Saved";
sleep 1;

hint "Loadout 1 Saved!";
playMusic "Save";
sleep 2;
hint "";

_host addAction ["<t color='#C0C0C0'>Restore Loadout 1</t>", "scripts\loadouts\restore1.sqf"];

savedloadout1 = [_uniform,_vest,_headgear,_goggles,_backpack,_mags,_items,_priweapon,_priattach,_primag,_secweapon,_secmag,_handgun,_hgunattach,_hgunmag];

OLD Restore Loadout

You can see in the above script that this script is called after a loadout is saved.
_host = _this select 0;
_caller = _this select 1;
_id = _this select 2;

_host removeAction _id;

_uniform = savedloadout1 select 0;
_vest = savedloadout1 select 1;

_backpack = savedloadout1 select 4;

_headgear = savedloadout1 select 2;
_goggles = savedloadout1 select 3;

_mags = savedloadout1 select 5;
_items = savedloadout1 select 6;

_priweapon = savedloadout1 select 7;
_priattach = savedloadout1 select 8;
_primag = savedloadout1 select 9;
_secweapon = savedloadout1 select 10;
_secmag = savedloadout1 select 11;
_handgun = savedloadout1 select 12;
_hgunattach = savedloadout1 select 13;
_hgunmag = savedloadout1 select 14;

_caller addUniform _uniform;
_caller addVest _vest;

_caller addBackpack _backpack;

_caller addHeadgear _headgear;
_caller addGoggles _goggles;

{_caller addMagazine _x} forEach _mags;
{_caller addItem _x} forEach _items;

_caller addWeapon _priweapon;
{_caller addPrimaryWeaponItem _x} forEach _priattach;
{_caller addMagazine _x} forEach _primag;
_caller addWeapon _secweapon;
{_caller addMagazine _x} forEach _secmag;
_caller addWeapon _handgun;
{_caller addHandgunItem _x} forEach _hgunattach;
{_caller addMagazine _x} forEach _hgunmag;

hint "Restoring Loadout 1:";
sleep 1;

if (_uniform != "") then {hint "Uniform Restored";sleep 1};
if (_vest != "") then {hint "Vest Restored"; sleep 1};

if (_backpack != "") then {hint "Backpack Restored"; sleep 1};

if (_headgear != "") then {hint "Headgear Restored"; sleep 1};
if (_goggles != "") then {hint "Goggles Restored"; sleep 1};

if (_priweapon != "") then {hint "Primary Weapon Restored"; sleep 1};
if (_secweapon != "") then {hint "Sccondary Weapon Restored"; sleep 1};
if (_handgun != "") then {hint "Handgun Restored"; sleep 1};

hint "Attachments Restored";
sleep 1;
hint "Magazines Restored";
sleep 1;
hint "Items Restored";
sleep 1;

hint "Loadout 1 Restored!";
playMusic "Restore";
sleep 3;
hint "";

_host addAction ["<t color='#C0C0C0'>Save Loadout 1</t>", "scripts\loadouts\save1.sqf"];

Nitro Boost

This is activated by a repeatable trigger set to BLUFOR and Present. Yes in my mission there is a folder called fun.

The Conditions:
((vehicle player) in thisList);
OnActivation:
nul = [] execVM "scripts\fun\nitroboost.sqf";
if ((vehicle player) == player) then {
hint "You need a Vehicle to add Nitro";
sleep 2;
hint "";
} else {
hint "Nitro Available";
sleep 2;
hint "";
(vehicle player) addAction ["Nitro Boost", { _vehicle = vehicle player; _vel = velocity _vehicle; _dir = direction _vehicle; _speed = 50; _vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2)]; hint "Nitro Activated!"; sleep 2; hint "";}];}; [/code] I will update this as I add more sc
_vehicle = vehicle player;
_vel = velocity _vehicle;
_dir = direction _vehicle;
_speed = 50;
_vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2)];
hint "Nitro Activated!";
sleep 2;
hint "";}];};

I will update this as I add more scripts. If you see any places that my coding or mission could be improved please reply. But bear in mind I have learnt everything above since the release of Altis on the Dev Build.

Cheers,
Ballistic




Last edited by Ballistic; Apr 29 @ 7:13pm
Showing 1-1 of 1 comments
< >
FluroTech - Accepting Free Games Sep 27, 2013 @ 8:49pm 
dude looks easy :P
Last edited by FluroTech - Accepting Free Games; Sep 27, 2013 @ 8:50pm
Showing 1-1 of 1 comments
< >
Per page: 15 30 50