Forum Jump :

Author Message


Posts: 6
Rank:


Level: Member

Country: au
Location:
Occupation: chef
Age:
In-game name:

 
#1 Posted at 2018-02-28 07:56        
     
Hi guys,

So I m totally new with scripting and I dont understand how most ot it works but i managed to get this script to work
on activation:

Null=["MarkerName"]execVM "LootInit.sqf";

my lootInit.sqf:

if(isServer)then{

// Set probability of loot spawning 1-100%
_probability=7;

// Show loot position and type on map (Debugging)
_showLoot=false;

// Set Weapon loot: Primary weapons, secondary weapons, Sidearms.
weaponsLoot= ["classname","classname"];
// Set items: Weapon attachments, first-aid, Binoculars
itemsLoot= ["classname","classname"];
// Set Clothing: Hats, Helmets, Uniforms
clothesLoot= ["classname","classname"];
// Set Vests: Any vests
vestsLoot= ["classname"];
// Set Backpacks: Any packpacks
backpacksLoot= ["classname"];

// Exclude buildings from loot spawn. Use 'TYPEOF' to find building name
_exclusionList= ["Land_Pier_F","Land_Pier_small_F","Land_NavigLight","Land_LampHarbour_F"];

private ["_distance","_houseList"];
_mkr=(_this select 0);
_mkr setmarkerAlpha 0;
_pos=markerpos _mkr;
_mkrY= getmarkerSize _mkr select 0;
_mkrX= getmarkerSize _mkr select 1;

_distance=_mkrX;
if (_mkrY > _mkrX)
then {
_distance=_mkrY;
};

_houseList= _pos nearObjects ["House",_distance];

{
_house=_X;

if (!(typeOf _house in _exclusionList))
then {


for "_n" from 0 to 50 do {

_buildingPos=_house buildingpos _n;
if (str _buildingPos == "[0,0,0]") exitwith {};

if (_probability > random 100)
then {
null=[_buildingPos,_showLoot] execVM "spawnloot.sqf";
};
};
};
}foreach _houseList;

};//ISSERVER

and my spawnloot.sqf:

if(isServer)then{
_pos= (_this select 0);
_pos0= (_pos select 0);
_pos1= (_pos select 1);
_pos2= (_pos select 2);
_showLoot= (_this select 1);

_BARREL = createVehicle ["Land_BarrelEmpty_F",[_pos0,_pos1,_pos2+0.1], [], 0, "can_Collide"];
sleep 0.5;
_holder = createVehicle ["groundweaponholder",[_pos0,_pos1,(getposATL _BARREL select 2)], [], 0, "can_Collide"];
deletevehicle _BARREL;

_type=floor (random 5);

if (_showLoot)
then {
_id=format ["%1",_pos];
_debug=createMarker [_id,GETPOS _holder];
_debug setMarkerShape "ICON";
_debug setMarkerType "hd_dot";
_debug setMarkerColor "ColorRed";
_txt=format ["%1",_type];
_debug setMarkerText _txt;
};

// Spawn Weapon
if (_type == 0)
then {
_weapon= weaponsLoot call bis_fnc_selectRandom;

_magazines = getArray (configFile / "CfgWeapons" / _weapon / "magazines");
_magazineClass = _magazines call bis_fnc_selectRandom;

_holder addWeaponCargoGlobal [_weapon, 1];
_holder addMagazineCargoGlobal [_magazineClass, 3];
};


// Spawn Magazines
if (_type == 1)
then {
_weapon= weaponsLoot call bis_fnc_selectRandom;
_magazines = getArray (configFile / "CfgWeapons" / _weapon / "magazines");
_magazineClass = _magazines call bis_fnc_selectRandom;

_holder addMagazineCargoGlobal [_magazineClass, 2];
};


// Spawn Items
if (_type == 2)
then {
_item= itemsLoot call bis_fnc_selectRandom;
_holder addItemCargoGlobal [_item, 1];

_clothing= clothesLoot call bis_fnc_selectRandom;
_holder addItemCargoGlobal [_clothing, 1];
};


// Spawn Vests
if (_type == 3)
then {
_vest= vestsLoot call bis_fnc_selectRandom;
_holder addItemCargoGlobal [_vest, 1];
};


// Spawn Backpacks
if (_type == 4)
then {
_backpack= backpacksLoot call bis_fnc_selectRandom;
_holder addBackpackCargoGlobal [_backpack, 1];
};
};//IsServer

my question is how can I clean all the loot spawned by the script when leaving the trigger area? is There a script I can use On Deactivation to remove all the loot spawned?

I m trying to create a SP mission that feels like Dayz but spawning loot all over the trigger area then leaving it and enter another trigger area which also spawns loot slows the game down quite a lot.

thanks!

Added 17 hours 16 minutes later:

I tried many different scripts I found but none of them seems to work

This post was edited by Noober (2018-03-01 03:46, 110 days ago)


Author Message


Posts: 1513
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#2 Posted at 2018-03-01 14:44        
     
It should be quite easy,
modify the first of part of spawnloot.sqf: so it sets up a couple of arrays highlighted with // *****
//my spawnloot.sqf:
if(isServer)then{
_pos= (_this select 0);
_pos0= (_pos select 0);
_pos1= (_pos select 1);
_pos2= (_pos select 2);
_showLoot= (_this select 1);


_id="";// ******
temp_holder =[];// *****
temp_marker_name = [];// ******

_BARREL = createVehicle ["Land_BarrelEmpty_F",[_pos0,_pos1,_pos2+0.1], [], 0, "can_Collide"];
sleep 0.5;
_holder = createVehicle ["groundweaponholder",[_pos0,_pos1,(getposATL _BARREL select 2)], [], 0, "can_Collide"];
deletevehicle _BARREL;

_type=floor (random 5);

if (_showLoot)
then {
_id=format ["%1",_pos];
_debug=createMarker [_id,GETPOS _holder];
_debug setMarkerShape "ICON";
_debug setMarkerType "hd_dot";
_debug setMarkerColor "ColorRed";
_txt = format ["%1",_type];
_debug setMarkerText _txt;
};
temp_holder = temp_holder + [_holder];// ******
temp_marker_name = temp_marker_name + [_id];// ******
// Spawn Weapon


Then either call a script containing the following code or just place directly in the On Deac of the trigger
{deletevehicle _x;  } foreach temp_holder;
{deletemarker _x} foreach  temp_marker_name;


Advertisement


Author Message


Posts: 6
Rank:


Level: Member

Country: au
Location:
Occupation: chef
Age:
In-game name:

 
#3 Posted at 2018-03-02 00:17        
     
# F2kSel : It should be quite easy,
modify the first of part of spawnloot.sqf: so it sets up a couple of arrays highlighted with // *****
//my spawnloot.sqf:
if(isServer)then{
_pos= (_this select 0);
_pos0= (_pos select 0);
_pos1= (_pos select 1);
_pos2= (_pos select 2);
_showLoot= (_this select 1);


_id="";// ******
temp_holder =[];// *****
temp_marker_name = [];// ******

_BARREL = createVehicle ["Land_BarrelEmpty_F",[_pos0,_pos1,_pos2+0.1], [], 0, "can_Collide"];
sleep 0.5;
_holder = createVehicle ["groundweaponholder",[_pos0,_pos1,(getposATL _BARREL select 2)], [], 0, "can_Collide"];
deletevehicle _BARREL;

_type=floor (random 5);

if (_showLoot)
then {
_id=format ["%1",_pos];
_debug=createMarker [_id,GETPOS _holder];
_debug setMarkerShape "ICON";
_debug setMarkerType "hd_dot";
_debug setMarkerColor "ColorRed";
_txt = format ["%1",_type];
_debug setMarkerText _txt;
};
temp_holder = temp_holder + [_holder];// ******
temp_marker_name = temp_marker_name + [_id];// ******
// Spawn Weapon


Then either call a script containing the following code or just place directly in the On Deac of the trigger
{deletevehicle _x;  } foreach temp_holder;
{deletemarker _x} foreach  temp_marker_name;

Thanks for your answer!
do I need to fill the arrays you highlighted with something or I can just copy and paste your code?
If I need to fill them up, can you please give me a short example? ...Apologies for my complete lack of knowledge regarding coding.

Cheers


Author Message


Posts: 1513
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#4 Posted at 2018-03-02 00:26        
     
Just copy and paste those marked lines into the correct places in the script.


Author Message


Posts: 6
Rank:


Level: Member

Country: au
Location:
Occupation: chef
Age:
In-game name:

 
#5 Posted at 2018-03-02 08:27        
     
# F2kSel : Just copy and paste those marked lines into the correct places in the script.

Hi mate, so i tried your code, it works...but all it seems to do is to delete the marker area but not the loot spawned by the activation, am I doing something wrong?


Author Message


Posts: 1513
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#6 Posted at 2018-03-02 21:00        
     
I think the issue is the script you posted throws up an error or two, I got a round this by just preventing certain lines form running.

When I allow the errors it does as you say it just removes the markers.

I don't know how to run the original script and not get these Errors.


Author Message


Posts: 6
Rank:


Level: Member

Country: au
Location:
Occupation: chef
Age:
In-game name:

 
#7 Posted at 2018-03-02 23:12        
     
thats weird, I got that script from this page @http://www.armaholic.com/page.php?id=25668 but I never had any error occuring...
which lines did you remove to get it to work??


Author Message


Posts: 1513
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#8 Posted at 2018-03-03 01:22        
     
Basically all the spawns apart from the backpack give me an error.

Do you have showscripterrors enabled in A3 launcher?

I'll try it tomorrow using the original script and see what happens.


Author Message


Posts: 6
Rank:


Level: Member

Country: au
Location:
Occupation: chef
Age:
In-game name:

 
#9 Posted at 2018-03-03 02:56        
     
ok thanks, let us know
cheers man


Author Message


Posts: 1513
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#10 Posted at 2018-03-03 13:44        
     
OK I think I got it now, it was working but for just one item, I had some of the code in the wrong script.

Here's a working example
https://www.sendspace.com/file/o0iomv

There are two triggers one in front of the player and one behind the player.
Each trigger spawns loot in a different area marker and removes it when leaving the trigger.

You can check each area by switching to another unit.


Author Message


Posts: 6
Rank:


Level: Member

Country: au
Location:
Occupation: chef
Age:
In-game name:

 
#11 Posted at 2018-03-06 01:42        
     
WORKS GREAT!
thanks heaps man!