Jump to content
Sign in to follow this  
Darihon

Ammo Box not Accesible

Recommended Posts

Hello,

I'm working on a small script which picks a position from an array and places stuff there, but whenever the Ammo Box spawns, the gear is not accesible. I contacted some other scripters about it and they weren't able to find the error.

//////////////////////////////////////////////////////////////////
private ["_HQ","_unitGroup","_pos","_box1","_squad1","_squad2"]; 
sleep 1;
/////////////////////////////////////////////////////////////////
[nil,nil,rTitleText,"The Skalisty Island chest has been spawned.", "PLAIN",10] call RE;
//don't edit this, unless you know what you are doing!
_HQ = createCenter east;
_unitGroup = createGroup east;
EAST setfriend [WEST,0];
west setfriend [civilian,0];
//end -- dont edit -- 

staticcoords = [ 
[4896.16,10016.5,0]
];

_pos = staticcoords call BIS_fnc_selectRandom;



//PUTS OBJECTS DOWN

//creates the box
_box1 = createVehicle ["GERBasicWeapons_EP1",[0,0,0],[],0,"CAN_COLLIDE"];
_box1 setpos _pos;

//clears the loot that was inside already.
clearmagazineCargoGlobal _box1;
clearweaponCargoGlobal _box1; 

_box1 addWeaponCargoGlobal ["M240",2];
_box1 addWeaponCargoGlobal ["M249",1];
_box1 addMagazineCargoGlobal ["ItemBriefcase50oz",1];
_box1 addMagazineCargoGlobal ["ItemGoldBar",5];

//Spawn Unit
//_squad1 = _unitGroup createUnit ["Bandit1_DZ", [(getpos _box1 select 0)+2,(getpos _box1 select 1)-6], [], 10, "FORM"];
//_squad2 = _unitGroup createUnit ["Bandit1_DZ", [(getpos _box1 select 0)-2,(getpos _box1 select 1)+6], [], 10, "FORM"];

//set them to hostile 
[_squad1] joinSilent _unitGroup;
[_squad2] joinSilent _unitGroup;

//Add the behaviourS1
_squad1 enableAI "TARGET";
_squad1 enableAI "AUTOTARGET";
_squad1 enableAI "MOVE";
_squad1 enableAI "ANIM";
_squad1 enableAI "FSM";
_squad1 setCombatMode "RED";
_squad1 setBehaviour "COMBAT";

//Gives AI Weapons
_squad1 addWeapon "M240";
_squad1 addMagazine "100Rnd_762x51_M240";
_squad1 addMagazine "100Rnd_762x51_M240";
_squad2 addWeapon "M136";
_squad2 addMagazine "M136";

The "Bandit1_DZ" is a custom classname. Can anyone give me a solution to this problem?

Thanks in advance,

Darryl

Edited by Darihon

Share this post


Link to post
Share on other sites

t's not really a script error, it's a side issue.

Ammo boxes are civilian so when you make them an enemy you won't be able to open the ammo box.

Remove this line west setfriend [civilian,0]; or change the player to Civ and the box will open.

You could add an action to the ammobox then you can force it open.

place after the createvehicle line

_box1 addaction ["Open Gear","ammobox.sqf",[], 6, true, true, "", "(_this distance (_target))<3 and !(player in _target)"];

then save this script as ammobox.sqf

_ammobox = _this select 0;
_Player = _this select 1;
_Player action ["Gear", _ammobox];

It will take about 30 seconds for the addaction to register in the game then it will be fine.

The same problem also applies to editor placed objects or spawned vehicles you can't access the ammo/weapon boxes when enemy to Civs.

So you will also need to add an action for those as well.

Share this post


Link to post
Share on other sites

Thanks F2K Sel, it solved it! Thank you very, very much! You owe me something.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×