Using the 'locked' variable in other scriptst - HELP

JayWood

New Member
I'll be honest, I've not quite been able to grasp the Arma scripting language so to speak. Yet I'm not totally ignorant either. I have 4 years background in PHP, JavaScript, and even a little Java itself, so I tend to pick up pretty quickly and with a little advice from here to there. I also know Lua (Minecraft/CC) and LSL for those Second Life guys/gals out there.

Enough about me, on to the situation. I've been trying to decipher R3F's towing system for abit now, and I have it nailed down, did I mention I don't speak French... I've noticed the remoquer_selection.sqf is what handles the initial towing of the object.

I've also found out that the lock_veh.sqf in dayz_code/actions is what handles the locking of the vehicle. So the geek in me said 'Hey what if I can use the locked variable in a != statement to prevent...' you get the point. From what I gather the dayzLockVehicle is a public variable, but I'm not too sure what this means:

Code:
dayzLockVehicle spawn local_lockUnlock

Which comes from this:
Code:
if(player distance _vehicle < 10) then {
if (local _vehicle) then {
dayzLockVehicle spawn local_lockUnlock
} else {
publicVariable "dayzLockVehicle";
};
};

I assume the first snippet is stored as an array, similar to the code above:
Code:
dayzLockVehicle = [_vehicle,true];

Rather the variable is actually stored publicly, meaning it's accessible within any other script, I do not know. I really just want to use a custom conditional like so:

Code:
if(_isLocked == true){
...
}

If someone would be willing to explain the logic behind the lock_veh.sqf to me I believe I can figure out the rest, I just don't know how to access the locked variable.
 
well i had my research on that topic but i lack the skills ... they key to the lock vehicles feature is inside the @EPOCH mod , im no programmer and i almost made it... the only problem was the mission.pbo... would be heavy so i failed
you can make some stuff server side and some client side or if you are really good merge the lock feature from @EPOCH with R3F....( not easy)
 
Let me elaborate abit here then. Looking in the fn_selfActions.sqf you see this:
Code:
// Allow Owner to lock and unlock vehicle  
if(_player_lockUnlock_crtl) then {
if (s_player_lockUnlock_crtl < 0) then {
_hasKey = _ownerID in _temp_keys;
_oldOwner = (_ownerID == dayz_playerUID);
if(locked _cursorTarget) then {
if(_hasKey or _oldOwner) then {
_Unlock = player addAction [format["Unlock %1",_text], "\z\addons\dayz_code\actions\unlock_veh.sqf",_cursorTarget, 2, true, true, "", ""];
s_player_lockunlock set [count s_player_lockunlock,_Unlock];
s_player_lockUnlock_crtl = 1;
} else {
_Unlock = player addAction ["<t color='#ff0000'>Vehicle Locked</t>", "",_cursorTarget, 2, true, true, "", ""];
s_player_lockunlock set [count s_player_lockunlock,_Unlock];
s_player_lockUnlock_crtl = 1;
};
} else {
if(_hasKey or _oldOwner) then {
_lock = player addAction [format["Lock %1",_text], "\z\addons\dayz_code\actions\lock_veh.sqf",_cursorTarget, 1, true, true, "", ""];
s_player_lockunlock set [count s_player_lockunlock,_lock];
s_player_lockUnlock_crtl = 1;
};
};
};
 
} else {
{player removeAction _x} forEach s_player_lockunlock;s_player_lockunlock = [];
s_player_lockUnlock_crtl = -1;
};

What interests me is this:
Code:
if(locked _cursorTarget) then { ...

Looking at BI's references here referring to cursorTarget you'll note that it's return value is an Object. I assume 'locked' is a state, similar to 'alive' from the BI reference. So following that basic idea, I found this in the remorquer_selection.sqf:
Code:
if (!(isNull _objet) && (alive _objet) && !(_objet getVariable "R3F_LOG_disabled")) then
...

Changed it to this:
Code:
if (!(isNull _objet) && (alive _objet) && !(_objet getVariable "R3F_LOG_disabled") && !(locked _objet)) then
...

Notice the addition of && !(locked _objet)

However, after doing so, it completely broke the towing of vehicles. I assume the syntax is correct, I mean according to the R3F file, and my basic scripting knowledge of conditional statements, this should work as _objet (not misspelled mind you, remember R3F is in french) is obviously an Object considering the 'alive_objet' statement in the original code.
 
I just noticed something reading through the BI documentation. Maybe using (not locked _objet) is more appropriate? Am I wrong?
 
Back
Top