Jump to content
Sign in to follow this  
CharlieSp

Addaction door lock/unlock how to limit to a certain unit type?

Recommended Posts

UPDATED POST BELOW THIS ONE

Hey, just started learning the more file based scripting for Arma 2 and I'm completely stuck on how to limit a vehicle lock/unlock script to a certain type of unit, who'll be the Instructor's for my clan training mission. Heres the basic crap I put together:

In the vehicle's init: unlock = this addAction["<t color="#F6FF00"">" +"Unlock","unlockTransport.sqf];veh = [this] execVM "vehicle.sqf"

Unlocking the vehicles (They start out as LOCKED in the editor :P)

_obj = _this select 0;

_obj setvehiclelock "unlocked";
_obj removeaction unlock;
lock = _obj addaction ["<t color=""#F6FF00"">" +"Lock", "lockTransport.sqf"];

exit;

And then locking the vehicles

_obj = _this select 0;

_obj setvehiclelock "locked";
_obj removeaction lock;
unlock = _obj addaction ["<t color=""#F6FF00"">" +"Unlock", "unlockTransport.sqf"];

exit;

the units are Russian officers/RU_Soldier_Officer (Named i1, i2 and i3)

Edited by CharlieSp

Share this post


Link to post
Share on other sites

Ok so I tested the script with a mate and quickly realised local variables just arent gonna work for this script, so my question: How do i structure a public variable correctly with this following script?

lockTransport.sqf

_obj = _this select 0;
_unit = _this select 1;

if((typeOf _unit) == "US_Soldier_TL_EP1") then
{
_obj setvehiclelock "locked";
_obj removeaction lock;
unlock = _obj addaction ["<t color=""#F6FF00"">" +"Unlock", "unlockTransport.sqf"];

exit;
};

unlockTransport.sqf

_obj = _this select 0;
_unit = _this select 1;

if((typeOf _unit) == "US_Soldier_TL_EP1") then
{
_obj setvehiclelock "unlocked";
_obj removeaction unlock;
lock = _obj addaction ["<t color=""#F6FF00"">" +"Lock", "lockTransport.sqf"];

exit;
};

I tried the following code but it doesnt work:

obj2 = _this select 0;
unit2 = _this select 1;
publicVariable "obj2";
publicVariable "unit2";

[-2,
{ 
if((typeOf unit2) == "US_Soldier_TL_EP1") then
{
obj2 setvehiclelock "unlocked";
obj2 removeaction unlock;
lock = obj2 addaction ["<t color=""#F6FF00"">" +"Lock", "lockTransport.sqf"];

exit;
}
}] call CBA_fnc_globalExecute;

Edited by CharlieSp

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  

×