humpabry

adding custom ammo boxes

18 posts in this topic

if (isServer) then {
 
_vehicle_99 = objNull;
 
if (true) then
{
 _this = createVehicle ["B_CargoNet_01_ammo_F", [22506.4,20058.8,0], [], 0, "CAN_COLLIDE"];
 _vehicle_99 = _this;
 _this setDir 20;
          _this setVariable ["permaLoot",true];
 
 clearWeaponCargoGlobal _this;
 clearMagazineCargoGlobal _this;
 
 
 _this addItemCargoGlobal [""];
 _this addItemCargoGlobal [""];
 
};
};

 

this code ofc with the _this addItemCargoGlobal [""]; filled in with right items dont seem to spawn me any box. can someone pls tell me what should be changed or let me know how to spawn boxes..wanting to add loot boxes to ai city.

 

ty

Share this post


Link to post
Share on other sites
Advertisement

I want to make them for shops, to buy, for a bigger storage room in the base 

1 person likes this

Share this post


Link to post
Share on other sites

i added this to the existing vehicle classes in the mission.sqm and i get the box boot no loot

class Item101
                {
                    position[]={23834.248,5.23,16089.85};
                    azimut=-36.197243;
                    id=101;
                    side="EMPTY";
                    vehicle="Exile_Container_Safe";
                    skill=0.60000002;
                    init="this addmagazinecargo [""20Rnd_762x51_Mag"",5];  this addmagazinecargo [""5Rnd_127x108_APDS_Mag"",5];  this addmagazinecargo [""7Rnd_408_Mag"",5];  this addmagazinecargo [""10Rnd_338_Mag"",5];  this addmagazinecargo [""10Rnd_127x54_Mag"",5];  this addmagazinecargo [""10Rnd_93x64_DMR_05_Mag"",5];    this additemcargo [""SatchelCharge_Remote_Mag"",1];";
                };

even tried addmagazineCargoGlobal.

Share this post


Link to post
Share on other sites

you need a clearItemCargoGlobal as well.

And how do you run the script?

1 person likes this

Share this post


Link to post
Share on other sites

tried these to no avail

1st adding this to the vehicle classes already in the mission.sqm


        class Item100
        {
            position[]={14559.784,17.91,16761.285};
            id=100;
            side="EMPTY";
            vehicle="Exile_Container_Safe";
            skill=0.60000002;
            init="clearWeaponCargoGlobal this;  clearMagazineCargoGlobal this;  clearItemCargoGlobal this; this addmagazinecargo     [""20Rnd_762x51_Mag"",5];";
        };
    };

safe appears but no loot

2nd i added this to a crate.sqf in the mission.pbo added by @humpabry

if (isServer) then {
 
_vehicle_99 = objNull;
 
if (true) then
{
 _this = createVehicle ["B_CargoNet_01_ammo_F", [22506.4,20058.8,0], [], 0, "CAN_COLLIDE"];
 _vehicle_99 = _this;
 _this setDir 20;
          _this setVariable ["permaLoot",true];
 
 clearWeaponCargoGlobal _this;
 clearMagazineCargoGlobal _this;
 
 
 _this addItemCargoGlobal [""];
 _this addItemCargoGlobal [""];
 
};
};

and ran it from init.sqf like this

[] execVM "crate.sqf";  again safe appears but no loot

 

and 3rd added a crate.sqf to mission pbo with this (found on armaholics)

if (isServer) exitWith {};
_position = _this select 0;
_radius = _this select 1;
_amount = _this select 2;
_refreshTime = _this select 3;
_crates = [];
while {true} do {
    for "_a" from 1 to _amount do {
        _crate = createVehicle ["Exile_Container_Safe", _position, [], _radius, "NONE"];
        _crates pushBack _crate;
    };
    {
        clearWeaponCargoGlobal _x;
        clearMagazineCargoGlobal _x;
        clearItemCargoGlobal _x;
        clearBackPackCargoGlobal _x;
        //Start modifying here
        _x addWeaponCargoGlobal ["arifle_MX_F", 5];
        _x addWeaponCargoGlobal ["arifle_MXM_F", 5];
        _x addMagazineCargoGlobal ["30Rnd_65x39_caseless_mag", 40];
        _x addItemCargoGlobal ["ItemRadio", 5];
        _x addItemCargoGlobal ["ItemMap", 5];
        //Stop modifying here
    } forEach _crates;
    sleep (_refreshTime - 30);
    hint "The crates will be refreshed in 30 seconds!";
    sleep 30;
    {deleteVehicle _x} forEach _crates;
};

and ran it from init.sqf like this

[<Position>, <Radius>, <Amount>, <Refresh time>] execVM "crate.sqf";

example : [14569.606,16751.447,17.91, 2, 1, 300] execVM "crate.sqf";

and with this no safe but crate refresh message shows up : The crates will be refreshed in 30 seconds!

and error log shows this

Bad conversion: array
10:05:16 Error in expression <or "_a" from 1 to _amount do {
_crate = createVehicle ["Exile_Container_Safe", _>
10:05:16   Error position: <createVehicle ["Exile_Container_Safe", _>
10:05:16   Error 0 elements provided, 3 expected
10:05:16 File mpmissions\__CUR_MP.Altis\crate.sqf, line 9

if anyone knows how to get it right or knows a way of spawning custom loot boxes i would be grateful, Thanks.

Share this post


Link to post
Share on other sites

What I did was make a file in a new folder where I add my static objects and crates and call that file from init.sqf.

First a crate file example.

Crate1.sqf in exile.Altis\addons:

if (isServer) then
{
_box0 = objNull;

		if (true) then
		{
		  _this = createVehicle ["Box_IND_WpsSpecial_F", [16093.6,16919.8,0.0], [], 0, "CAN_COLLIDE"];
		  _box0 = _this;
		  _this setDir -2.0;
		  _this setVariable ["permaLoot",true];

		  clearweaponcargoGlobal _this;
		  clearmagazinecargoGlobal _this;
		  clearItemCargoGlobal _this;

		  _this addItemCargoGlobal ["Exile_Item_MetalBoard", 5];
                    _this addWeaponCargoGlobal ["srifle_DMR_04_F",2];
		  _this addMagazineCargoGlobal ["Exile_Magazine_Battery",5];
};
};

 

Then a file to call the crate/static objects from.

custom.sqf also in addons:

call compileFinal preprocessFileLineNumbers "addons\crate1.sqf";

Then include that file in init.sqf like this:

[] execVM "addons\custom.sqf"; 

Nothing fancy but it works for me and all I have to do when updating the server is copy the files over.

Edited by r0fus
Error...
2 people like this

Share this post


Link to post
Share on other sites

What I did was make a file in a new folder where I add my static objects and crates and call that file from init.sqf.

First a crate file example.

Crate1.sqf in exile.Altis\addons:

_box0 = objNull;

		if (true) then
		{
		  _this = createVehicle ["Box_IND_WpsSpecial_F", [16093.6,16919.8, [], 0, "CAN_COLLIDE"];
		  _box0 = _this;
		  _this setDir -2.0;
		  _this setVariable ["permaLoot",true];

		  clearweaponcargoGlobal _this;
		  clearmagazinecargoGlobal _this;
		  clearItemCargoGlobal _this;

		  _this addItemCargoGlobal ["Exile_Item_MetalBoard", 5];
          _this addWeaponCargoGlobal ["srifle_DMR_04_F",2];
		  _this addMagazineCargoGlobal ["Exile_Magazine_Battery",5];
		};

Then a file to call the crate/static objects from.

custom.sqf also in addons:

call compileFinal preprocessFileLineNumbers "addons\crate1.sqf";

Then include that file in init.sqf like this:

[] execVM "addons\custom.sqf"; 

Nothing fancy but it works for me and all I have to do when updating the server is copy the files over.

where do you put the spawn coords? 

 

[16093.6,16919.8]

It has only X and Y? 

 

 

1 person likes this

Share this post


Link to post
Share on other sites

Ah yes. Managed to mess that one up while editing. Should be [X,Y,Z] in the createVehicle line. Tho if you are placing the crate on the ground you dont need the Z coordinate.

Edited by r0fus
Typo
1 person likes this

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.