Ammo box script work in progress

I tried adding the following line.....
Code:
_this setVariable ["permaLoot",true,true];

to the following code in my mission.sqm like so.....
Code:
class Item17
        {
            position[]={2011.46, 244.919, 11796};
            id=17;
            side="EMPTY";
            vehicle="USVehicleBox";
            skill=0.60000002;
            init="null0 = this execVM ""supplies.sqf""";
            _this setVariable ["permaLoot",true,true];
        };

And I get stuck at wait for host with following error....

9:22:54 Error context etVariable ["permaLoot",true,true];
ErrorMessage: File mpmissions\__cur_mp.chernarus\mission.sqm, line 1404: '/Mission/Vehicles/Item17._this': 's' encountered instead of '='
 
Doh!

You can't add that line in your Mission.sqm like that. That's the syntax for a totally different method. For adding it to your mission.sqm you have two ways to go about it. In the box that pops up for the USVehicleBox inside the 2d/3d editor which you are using to place it there is a entry field called "init". It's the exact same place you placed

Code:
null0 = this execVM "supplies.sqf"

You just need to add another line in that box like this

Code:
null0 = this execVM "supplies.sqf"; this setVariable ["permaLoot",true,true]

But, I high recommend trying a different method for placing your objects within the map.

I am way to tired to do another write atm so I am going to post a Quote from Rossymond to help you find the other (and best) method of placing stuff in your map.

Right, time for a little how-to.

Adding buildings =easiest thing in the world if you follow this.

Firstly, the guy using MAP_EU, this requires a clientdownload, so unless everyone uses the MAP_EU mod alongside DayZ, you wont be able to join, also your Server will have to run this mod alongside dayz.

Secondly, forget adding buildins via the Database, it's annoying and in my opinion, just plain tedious.

The following is the method I use, and works 100% of the time.

Step 1:

Create your edits in 3D editor, I recommend the John Editor update for this, giving you access to most buildings.

This can be downloaded here http://www.armaholic.com/page.php?id=5932

Step 2 :

Save your "mission" as a User Mission and exit the editor. For this example we call it "New Buildings"

Step 3 :

Open your "Arma 2 Other Profiles" Folder and open the "New Buildings" folder.

Step 4 :

Open the "mission.SQF" file with Notepad ++

Step 5 :

Edit the file and REMOVE all Units you have added in the editor, they will prevent the script running due to DayZ restrictions.

Each "Vehicle" is defined as below...

Code:
_vehicle_18 = objNull;
if (true) then
{
  _this = createVehicle ["Land_Misc_Cargo2E", [10318.463, 1844.6021, 4.196167e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_18 = _this;
  _this setDir 88.687256;
  _this setPos [10318.463, 1844.6021, 4.196167e-005];
};

Add this statement to the file:

Code:
if (isServer) then {
 
 
};

MAKE SURE you close the statement with }; at the end of the file.

Foe example, this file will spawn just a single building

Code:
if (isServer) then {
 
_vehicle_18 = objNull;
if (true) then
{
  _this = createVehicle ["Land_Misc_Cargo2E", [10318.463, 1844.6021, 4.196167e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_18 = _this;
  _this setDir 88.687256;
  _this setPos [10318.463, 1844.6021, 4.196167e-005];
};
};

This file can then be saved the your mission file, under a "buildings" folder to keep things tidy, call it "Elektro.sqf" for example.

Step 6 :

Add the following line to your init.sqf file, repack your mission file and upload.

Code:
[] ExecVM "buildings\elektro.sqf";

Step 7 :

Repakc your Mission PBO file, upload to server and check out your new buildings. Be sure to disable your john editor addon before joining server, some people say it makes no difference, some cant join the server, I just turn it off to make sure.

That shoud be it.

Hopefully that helps...

And btw, It is in there that you would find the spot to place the original line you attempted.. I highly recommend reading a few more tutorials. I know everyone wants to add their box with their boom booms in it, but there's a ton more things that you can learn to do here with a little reading. Happy creating man....;)
 
I have a short Question: If i insert the Ammo-Boxes this way. Do they Save the Loot i put in them? I want these Boxes as Tents for my Players.
If its possible can someone of you guys give me some hinds how i can do this?
 
To further expand for you I'll give you my example

This is the code in my mission pbo to add in my gear box

Code:
_vehicle_20 = objNull;
if (true) then
{
  _this = createVehicle ["LocalBasicAmmunitionBox", [2932.281, 12821.079, -9.1552734e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_20 = _this;
  _this setDir 13.635636;
  _this setVehicleInit "null0 = this execVM ""addons\camps\docgearbox.sqf""";
  _this setPos [2932.281, 12821.079, -9.1552734e-005];
  _this setVariable ["permaLoot",true,true];
};

Which you can also see executes another sqf called docgearbox.sqf with this

Code:
while {alive _this} do
{
 
 
clearweaponcargo _this;
clearmagazinecargo _this;
 
 
_this addWeaponCargo ["RH_p90sdeot",1];
_this addWeaponCargo ["R3F_Famas_F1_J4_M203_SD",1];
_this addWeaponCargo ["Binocular",1];
_this addWeaponCargo ["Binocular_Vector",1];
_this addWeaponCargo ["ItemGPS",1];
 
_this addmagazineCargo ["FoodMRE",30];
_this addmagazineCargo ["ItemSodaLemonade",30];
_this addmagazineCargo ["ItemAntibiotic",10];
_this addmagazineCargo ["ItemBloodbag",10];
_this addmagazineCargo ["ItemMorphine",10];
_this addmagazineCargo ["ItemBandage",10];
_this addmagazineCargo ["ItemPainkiller",10];
_this addmagazineCargo ["ItemHeatPack",10];
_this addmagazineCargo ["RH_57x28mm_50RND_SD_Mag",50];
_this addmagazineCargo ["30Rnd_556x45_StanagSD",50];
 
 
sleep 3600;
};

inside of it.

The

Code:
clearweaponcargo _this;
clearmagazinecargo _this;

Empties out anything "predefined" in the box you want to use

And the

Code:
_this addWeaponCargo ["",1];
_this addmagazineCargo ["",30];

Adds the content you wish to have put into your now empty box.

And this line

Code:
_this setVariable ["permaLoot",true,true];

Keeps this bit of code in the server_cleanup.fsm

Code:
init = /*%FSM<STATEINIT""">*/"//_missionObjs = allMissionObjects ""WeaponHolder"" + allMissionObjects ""WeaponHolderBase"" ;" \n
      "_missionObjs = allMissionObjects ""ReammoBox"";" \n
      "_qty = count _missionObjs;" \n
      "" \n
      "diag_log (""CLEANUP:TOTAL "" + str(_qty) + "" LOOT BAGS"");" \n
      "" \n
      "_delQty = 0;" \n
      "" \n
      "{" \n
      "    _keep = _x getVariable [""permaLoot"",false];" \n
      "    _nearby = {isPlayer _x} count (_x nearEntities [[""CAManBase""], 250]);" \n
      "" \n
      "    _created = (_x getVariable [""created"",-0.1]);" \n
      "" \n
      "    if (_created == -0.1) then {" \n
      "        _x setVariable [""created"",(DateToNumber date)];" \n
      "    };" \n
      "" \n
      "    _age = ((DateToNumber date) - _created) * 525948;" \n
      "" \n
      "//diag_log format [""Pile : %1, Created: %2, Age: %3"", _x,  _created, _age];" \n
      "" \n
      "    if ( (!_keep) && (_nearby==0) && (_age > 300) then {" \n
      "        deleteVehicle _x;" \n
      "        _delQty = _delQty + 1;" \n
      "    };" \n
      "" \n
      "} forEach _missionObjs;" \n

From deleting it....


Hope this helps....

I follow this but the crates still with the default ammo, Itry diferents things and still the same, any ideas?
 
Back
Top