Jump to content

Help Creating a custom loot box at a static location


Nazdock

Recommended Posts

I'm trying to setup a custom loot box at a static location, Is there a way to edit USlaunchers box? I've tried to edit the mission.pbo file and the custom map file. I cannot not get them to work.

 

Mission.pbo


class Item14
        {
            position[]={13725.856,46.825798,2936.4185};
            id=104;
            side="EMPTY";
            vehicle="USSpecialWeapons_EP1";
            skill=0.60000002;
            init="clearMagazineCargo this; clearWeaponCargo this; {this addWeaponCargoGlobal [_x, 2];} forEach    ['M24','M4A1_AIM_SD_camo','M249','m16a4_acg','M9SD']; {this addmagazineCargoGlobal [_x, 12];} forEach ['5Rnd_762x51_M24','15Rnd_9x19_M9SD','30Rnd_556x45_Stanag','30Rnd_556x45_StanagSD','200Rnd_556x45_M249'];";
        };

 

 

// Second way i tried in custom map file

 

_vehicle_721 = objNull;
{


if (true) then
{
  _this = createVehicle ["USLaunchersBox", [13704.164, 2947.2451, 1.1444092e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_721 = _this;
  _this setPos [13704.164, 2947.2451, 1.1444092e-005];
  _this setVariable ["permaLoot",true];
  _init="clearMagazineCargo this; clearWeaponCargo this; {this addWeaponCargoGlobal [_x, 2];} forEach    ['M24','M4A1_AIM_SD_camo','M249','m16a4_acg','M9SD']; {this addmagazineCargoGlobal [_x, 12];} forEach ['5Rnd_762x51_M24','15Rnd_9x19_M9SD','30Rnd_556x45_Stanag','30Rnd_556x45_StanagSD','200Rnd_556x45_M249'];";
};

Link to comment
Share on other sites

Here is an example of how I did it. This one is custom .

 

Make a Seprate SQF File ...  " What everynameyouwant.SQF" and put that either in a custom folder or just put it in your mission.pbo 

 

In you INIT.sqf in Mission.PBO

 

But this on bottom of page 

 

[] execVM "\What aeveryname youwant.SQF";

 

Repack and upload.

 

 

Here is one of my Custom crates. 

 

 

 

if (isServer) then {

 
_vehicle_99 = objNull;
 
if (true) then
{
 _this = createVehicle ["SpecialWeaponsBox", [9875.6211, 14061.259, 0.00051879883], [], 0, "CAN_COLLIDE"];
 _vehicle_99 = _this;
 _this setDir 20;
          _this setVariable ["permaLoot",true];
 
 clearWeaponCargoGlobal _this;
 clearMagazineCargoGlobal _this;
 
 
 _this addMagazineCargoGlobal ["ItemBriefcase100oz",10];
 _this addMagazineCargoGlobal ["ItemVault",10];
 _this addMagazineCargoGlobal ["Skin_Graves_Light_DZ",2];
 _this addMagazineCargoGlobal ["PipeBomb",10];
 _this addWeaponCargoGlobal ["ItemGPS",10];
 _this addWeaponCargoGlobal ["Binocular_Vector",10];
 _this addMagazineCargoGlobal ["Skin_CZ_Special_Forces_GL_DES_EP1_DZ",4];
 
};
};
Link to comment
Share on other sites

  • 1 year later...

is there any way to make this crate spawn within a certain radius of a set area? also does this scrip spawn the box at restart of at random intervals, if at restart is it possible to do it at random intervals? trying to create a reason to draw players to a pvp island, but i dont want them to know exactly were the box is on the island or when its spawning, but want it to spawn at random throught the six hour restart intervals.

 

Link to comment
Share on other sites

You can use this piece of code for spawning the crate in random places, you'll need to add your own coords, loot and stuff like that obviously

	private ["_Boxes","_positionarray","_Position","_BoxModel","_Box","_QA"];

	_Boxes = ["BoxClassname1","BoxClassname2","BoxClassname3"] call BIS_fnc_selectRandom; // Item crate classnames

	_positionarray = [[1860.21,2170.51,0],[1061.13,2383.86,0],[3591.74,2200.85,0],[4686.19,2501.68,0],[7759.07,3550.56,0],[13181.6,6785.23,0],[11990.1,3537.64,0],[10179,1976.52,0]]; // All possible lootbox positions you want
	_Position = _positionarray call BIS_fnc_selectRandom; //This takes one random set of coords and uses them to spawn the box

	_QA = [1,2,3,4,5,6] call BIS_fnc_selectRandom; //Random quantity of Items spawned in the box, to spawn select number of items just use that number instead of _QA

	_BoxModel = _Boxes;

	_Box = createVehicle [_BoxModel,_Position,[], 0, "CAN_COLLIDE"];
	_Box setDir 0.0;
	_Box setPos _Position;

	_Box setVariable ["permaLoot",true];

	clearMagazineCargoGlobal _Box;
	clearWeaponCargoGlobal _Box;
	
	if(_Box == "BoxClassname1") then  {

		{_Box addWeaponCargoGlobal [_x, 1];} forEach //Spawns one of each weapon in your array one line below
		['WeaponClassname1','WeaponClassname2'];

		{_Box addMagazineCargoGlobal [_x, _QA];} forEach //Spawns random quantity of magazines in your array one line below
		['ItemClassname1','ItemClassname2'];

		{_Box addBackpackCargoGlobal [_x, 3];} forEach //Spawns 3 backpacks you've added to your array
		['BackpackClassname'];
	};
	
	if(_Box == "BoxClassname2") then  {

		{_Box addWeaponCargoGlobal [_x, 1];} forEach
		['Weapon Classname 1','Weapon Classname 2'];

		{_Box addMagazineCargoGlobal [_x, _QA];} forEach
		['Item Classname 1','Item Classname 2'];

		{_Box addBackpackCargoGlobal [_x, 3];} forEach
		['Backpack Classname'];
	};
	
	if(_Box == "BoxClassname3") then  {

		{_Box addWeaponCargoGlobal [_x, 1];} forEach
		['Weapon Classname 1','Weapon Classname 2'];

		{_Box addMagazineCargoGlobal [_x, _QA];} forEach
		['Item Classname 1','Item Classname 2'];

		{_Box addBackpackCargoGlobal [_x, 3];} forEach
		['Backpack Classname'];
	};

 

Edited by Antichrist
Link to comment
Share on other sites

Well i run that thing i posted from mission file so in your copy/paste case get rid of that old one and edit the new one

 

Just add this line in your init.sqf, within if (isServer) then { section

execVM "custom\ammocrate\box.sqf";

So it looks like

if (isServer) then {

execVM "custom\treasure\ammobox.sqf";

 

Link to comment
Share on other sites

if (isServer) then
    {
        if (isNil "Ultima_Diag_Level") then
            {Ultima_Diag_Level    =    3;};
        if (Ultima_Diag_Level > 0) then
            {diag_log("[#Ultima]: [Ящики с лутом]: Создание ящиков с лутом.");};
        private ["_Data","_aSpawnItems","_worldname","_mapcenter","_Map_Radius"];
        _worldname  =    toLower format ["%1", worldName];
        _mapcenter  = (getMarkerPos "center");
        _Map_Radius = (_mapcenter select 0);
 
        if (Ultima_Diag_Level > 1) then
            {
                diag_log format["[#Ultima]: [Ящики с лутом]: Карта определена как %1.", _worldname];
                diag_log format["[#Ultima]: [Ящики с лутом]: Установлен центр координат: %1.", _mapcenter];
                diag_log format["[#Ultima]: [Ящики с лутом]: Установлен радиус карты: %1.", _Map_Radius];                
            };
        _aSpawnItems =    
            [
                [
                    ["ItemPole",4,90]
                    ,["ItemTankTrap",4,80]
                    ,["ItemGenerator",2,40]
                    ,["ItemWire",2,30]
                    ,["ItemTent",1,30]
                    ,["CinderBlocks",6,50]
                ]
                ,[
                    ["8Rnd_9x18_Makarov",10,90]
                    ,["8Rnd_9x18_MakarovSD",4,20]
                    ,["30Rnd_545x39_AK",8,70]
                    ,["30Rnd_762x39_AK47",6,60]
                ]
                ,[
                    ["ItemBandage",8,80]
                    ,["ItemPainkiller",4,70]
                    ,["ItemMorphine",2,30]
                ]
            ];
        _Data =
            [
                [12968, 3551, 9, 59, 300, 50, (_aSpawnItems select 0),"USVehicleBox", 0, false, false, _mapcenter, _Map_Radius, true]
                ,[13153, 3662, 9, 59, 300, 50, (_aSpawnItems select 1),"TKVehicleBox_EP1", 0, false, false, _mapcenter, _Map_Radius, true]
                ,[13120, 3616, 9, 59, 300, 50, (_aSpawnItems select 2),"USVehicleBox", 0, false, false, _mapcenter, _Map_Radius, true]
                ,[13099, 3615, 9, 59, 300, 50, (_aSpawnItems select 0),"USVehicleBox", 0, false, false, _mapcenter, _Map_Radius, true]
                ,[13032, 3562, 9, 59, 300, 50, (_aSpawnItems select 2),"USVehicleBox", 0, false, false, _mapcenter, _Map_Radius, true]
                ,[12978, 3539, 9, 59, 300, 50, (_aSpawnItems select 1),"RUVehicleBox", 0, false, false, _mapcenter, _Map_Radius, true]
                ,[12994, 3547, 9, 59, 300, 50, (_aSpawnItems select 0),"USVehicleBox", 0, false, false, _mapcenter, _Map_Radius, true]
            ];
        {
            [_x] spawn
                {
                    private ["_Map_Radius","_random_count","_mapcenter","_Data","_aSpawnItems","_TimerSpawn","_SpawnItems","_SpawnDelay","_randomPos","_SpawnOneTime","_Box","_BoxID","_nearPlayers","_Item","_Count","_Percent","_Random","_Model"];
                    _Data         =    (_this select 0);
                    _Angle        =    (_data select 3);
                    _TimerSpawn   =    (_data select 4);
                    _Radius       =    (_data select 5);
                    _boxID        =    str(round(random 999999));
                    _box          =    objNull;
                    _SpawnItems   =    true;                    
                    _aSpawnItems  =    (_data select 6);
                    _Model        =    (_data select 7);
                    _SpawnDelay   =    (_data select 8);
                    _randomPos    =    (_data select 9);
                    _SpawnOneTime =    (_data select 10);
                    _mapcenter    =    (_data select 11);
                    _Map_Radius   =    (_data select 12);
                    _random_count =    (_data select 13);
                    _Coords       =    [(_data select 0), (_data select 1), (_data select 2)];
                    if (_randomPos) then
                        {_Coords    =    [_mapcenter, 100, _Map_Radius, 20, 0, 20, 0] call BIS_fnc_findSafePos;};
                    sleep _SpawnDelay;
                    if (Ultima_Diag_Level > 1) then
                        {diag_log(format["[#Ultima]: [Ящики с лутом]: Создание ящика в координатах: %1", _Coords]);};
                    _box = createVehicle [_Model, _Coords, [], 0, "CAN_COLLIDE"];
                    _box setDir _Angle;
                    _box setPos _Coords;
                    _box setVariable ["ObjectID", _boxID, true];
                    _box setVariable ["ObjectUID", _boxID, true];
                    _box setVariable ["permaLoot",true];
                    PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor, _box];        
                    while {true} do
                        {
                            if (_SpawnItems) then
                                {
                                    clearWeaponCargoGlobal _box;
                                    clearMagazineCargoGlobal _box;
                                    clearBackpackCargoGlobal _box;
                                    {
                                        _Percent    =    _x select 2;
                                        _Random     =    random(100);
                                        if (_Random < _Percent) then
                                            {
                                                if (_random_count) then
                                                    {_Count        =    round(random(_x select 1));}
                                                else
                                                    {_Count        =    (_x select 1);};
                                                if (_Count > 0) then
                                                    {
                                                        _Item        =    (_x select 0);
                                                        if (getText (configFile >> "CfgMagazines" >> _item >> "displayName")    !=    "") then
                                                            {_box addMagazineCargoGlobal [_Item, _Count];}
                                                        else
                                                            {
                                                                if (getText (configFile >> "CfgWeapons" >> _item >> "displayName")    !=    "") then
                                                                    {_box addWeaponCargoGlobal [_Item, _Count];}
                                                                else
                                                                    {
                                                                        if (getText (configFile >> "CfgVehicles" >> _item >> "displayName")    !=    "") then
                                                                            {_box addBackpackCargoGlobal [_Item, _Count];};
                                                                    };
                                                            };
                                                    };
                                            };
                                    } forEach _aSpawnItems;
                                    if (_SpawnOneTime) ExitWith {};
                                    _SpawnItems    =    false;
                                    sleep _TimerSpawn;
                                };
                            if (_SpawnOneTime) ExitWith {};
                            while {!_SpawnItems} do
                                {
                                    sleep 10;
                                    _nearPlayers    =    nearestObjects [_Coords, ["CAManBase"], _Radius];
                                    if (count(_nearPlayers) <= 0) then
                                        {_SpawnItems    =    true;};
                                };
                        };
                };
        } forEach _Data;
        if (Ultima_Diag_Level > 0) then
            {diag_log("[#Ultima]: [Ящики с лутом]: Создание ящиков с лутом завершено.");};
    };

Original:

http://rnrportal.ru/forum/index.php?/topic/8-ящики-со-своим-лутом-со-всеми-необходимыми-наст/

Solution:

*sry for my eng

/*
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
in init.sqf, add variable:

Ultima_Diag_Level = 0; // diag lvl 0 to 3.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
_aSpawnItems - items arrays for respawn in box.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1 - item ID.
2 - Max count items (for 0, to xxx). if you need static count, goto p.13-box spawn
3 - Percent respawn - for 1 to 100.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
box spawn:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0 - X
1 - Y
2 - Z
3 - Angle
4 - Time for respawn
5 - Radius for box, - items not respawn while player in radius box.
6 - number array for spawn - _aSpawnItems
7 - box ID
8 - delay for box spawn
9 - random or static coords for spawn(false - static coord, true - random coord).
10 - respawn items?(false - respawn. true - spawn items only one - box spawn)
11 - dont touch.
12 - dont touch.
13 - random items count? true - random(from 0 to max count - _aSpawnItems), false - static spawn - (max count items - _aSpawnItems)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
*/
Edited by NoNameUltima
Link to comment
Share on other sites

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
  • Advertisement
  • Discord

×
×
  • Create New...