Jump to content

[Release] Remote vehicle locking/engine/eject [Updated for 1.0.7]


salival

Recommended Posts

Remote Vehicle is part of Epoch 1.0.7.1 now.

 

Hi,

Here's a script I wrote that does the following from right clicking your key in your toolbelt:

  • Unlock/lock vehicle.
  • Turn engine on/off.
  • Eject players not in your group.

Thanks to @Pattohfor the idea for this script.

For downloading and install instructions, see my github: https://github.com/oiad/remoteVehicle

Link to comment
Share on other sites

hey sal, what is that final variable in the config entry?

["ItemKey","Lock vehicle","spawn remoteVehicle;","true",4]
_classname,_text,_execute,_condition,_option

what exactly does _option mean? Like the numerical order it is displayed when right clicked? Thanks for your time mate!

EDIT: I think I understand after reading the remoteVehicle.sqf script. Very elegant!

Link to comment
Share on other sites

29 minutes ago, ViktorReznov said:

hey sal, what is that final variable in the config entry?


["ItemKey","Lock vehicle","spawn remoteVehicle;","true",4]
_classname,_text,_execute,_condition,_option

what exactly does _option mean? Like the numerical order it is displayed when right clicked? Thanks for your time mate!

EDIT: I think I understand after reading the remoteVehicle.sqf script. Very elegant!

Yeah, it's pretty simple, just _option tells the script what to do for each entry

Link to comment
Share on other sites

So a couple more expanded options to this, I find it to be a pain in the A$$ to find my vehicles at, esp if no nvgs or flashlights. So how nice would it be if you could turn your lights on with your remote! Sweet deal, tested and working!

 

Spoiler

insert this at the bottom of remoteVehicle.sqf


if (_option == 5) then {
	if (_vehicle getVariable ["lightOff",0] != 1) then {
		player action ["lightOn", _vehicle];
		systemChat format ["Lights on %1", _vehicleType];
	};
};

if (_option == 6) then {
	if (_vehicle getVariable ["lightOn",1] != 0) then {
		player action ["lightOff", _vehicle];
		systemChat format ["Lights off %1", _vehicleType];
	};
};

and add this into your overwrites\click_actions\config.sqf or wherever you put that!


DZE_CLICK_ACTIONS = DZE_CLICK_ACTIONS + [["ItemKey","Lights on","spawn remoteVehicle;","true",5]];
DZE_CLICK_ACTIONS = DZE_CLICK_ACTIONS + [["ItemKey","Lights off","spawn remoteVehicle;","true",6]];

 

I spent WAAAAY to long on this so please, insert a better version of this! (i thought of doing a panic button with the caralarm.ogg and have lights go on and off rapidly, just for fun but..... naaaaaa)

Link to comment
Share on other sites

Very nicely done. Clean as always. I actually wasn't aware that I could just use the base class ItemKey to detect a key in the gear to make it have right click options, this entire time in my ui_selectSlot I have been sorting classes etc.. Much more efficient. Again, well done!

Link to comment
Share on other sites

13 minutes ago, BigEgg said:

Very nicely done. Clean as always. I actually wasn't aware that I could just use the base class ItemKey to detect a key in the gear to make it have right click options, this entire time in my ui_selectSlot I have been sorting classes etc.. Much more efficient. Again, well done!

You can't use the base class which is why I'm doing this check: https://github.com/oiad/remoteVehicle/blob/master/dayz_code/compile/ui_selectSlot.sqf#L69

That could be broken by other items with "itemkey" in the name but the only one I know of is itemkeykit (but I check this on that same line)

But yeah, I try and focus my work on clean and tidy so that anyone can read it, almost to the point of unreasonable OCD tidy

Link to comment
Share on other sites

1 minute ago, salival said:

You can't use the base class which is why I'm doing this check: https://github.com/oiad/remoteVehicle/blob/master/dayz_code/compile/ui_selectSlot.sqf#L69

That could be broken by other items with "itemkey" in the name but the only one I know of is itemkey (but I check this on that same line)

But yeah, I try and focus my work on clean and tidy so that anyone can read it, almost to the point of unreasonable OCD tidy

Ahhhhhh that is still much more efficient than what I am doing now. I like clean though, smaller the file size and the simpler the code the better it runs. Eitherway, nice job :)

Link to comment
Share on other sites

23 hours ago, ViktorReznov said:

So a couple more expanded options to this, I find it to be a pain in the A$$ to find my vehicles at, esp if no nvgs or flashlights. So how nice would it be if you could turn your lights on with your remote! Sweet deal, tested and working!

 

  Reveal hidden contents

insert this at the bottom of remoteVehicle.sqf



if (_option == 5) then {
	if (_vehicle getVariable ["lightOff",0] != 1) then {
		player action ["lightOn", _vehicle];
		systemChat format ["Lights on %1", _vehicleType];
	};
};

if (_option == 6) then {
	if (_vehicle getVariable ["lightOn",1] != 0) then {
		player action ["lightOff", _vehicle];
		systemChat format ["Lights off %1", _vehicleType];
	};
};

and add this into your overwrites\click_actions\config.sqf or wherever you put that!



DZE_CLICK_ACTIONS = DZE_CLICK_ACTIONS + [["ItemKey","Lights on","spawn remoteVehicle;","true",5]];
DZE_CLICK_ACTIONS = DZE_CLICK_ACTIONS + [["ItemKey","Lights off","spawn remoteVehicle;","true",6]];

 

I spent WAAAAY to long on this so please, insert a better version of this! (i thought of doing a panic button with the caralarm.ogg and have lights go on and off rapidly, just for fun but..... naaaaaa)

I like your idea, I had completely forgotten about lights (I play on 24/7 day servers)

I'll add that in the next few days but i'll make it a toggle instead of 2 seperate ones.

Cheers for the input

Link to comment
Share on other sites

On 6/12/2017 at 8:04 AM, salival said:

I like your idea, I had completely forgotten about lights (I play on 24/7 day servers)

I'll add that in the next few days but i'll make it a toggle instead of 2 seperate ones.

Cheers for the input

I am seriously just beginning to learn the logic to coding and really did butcher getting that script to even work! but im learning a lot and I thank you for all the help and support you have already been m8! looking forward to seeing how you do it!

Alright! Got it finally, a simple toggle for lights, makes it a hell of a lot easier to find at night!

add this to the bottom of remoteVehicle.sqf

if (_option == 5) then {
	if (_vehicle getVariable["lightOff",true]) then {
		player action ["lightOn", _vehicle];
		systemChat format ["Lights on %1", _vehicleType];
		_vehicle setVariable ["lightOn",true];
		_vehicle setVariable ["lightOff",false];
	} else {
		player action ["lightOff", _vehicle];
		systemChat format ["Lights off %1", _vehicleType];
		_vehicle setVariable ["lightOn",false];
		_vehicle setVariable ["lightOff",true];
	};
};

and add this to the bottom of your click_actions\config.sqf

DZE_CLICK_ACTIONS = DZE_CLICK_ACTIONS + [["ItemKey","Toggle Lights","spawn remoteVehicle;","true",5]];

id submit a pull request @salival but i leave it to you m8!

Link to comment
Share on other sites

  • 1 month later...
5 hours ago, Runewulv said:

any chance of getting this to work with master key? As of now it seems to lock onto the last vehicle keyed.

That is unfortunately going to be a side effect of master key. I tried thinking of a way to do this when I wrote this.

The only way I could have seen to do it was to pop up a menu asking which vehicle you wanted to access, but that was a lot more work than I intended

Link to comment
Share on other sites

21 hours ago, salival said:

That is unfortunately going to be a side effect of master key. I tried thinking of a way to do this when I wrote this.

The only way I could have seen to do it was to pop up a menu asking which vehicle you wanted to access, but that was a lot more work than I intended

Would so be worth it tho... Maybe hook it into your vehicle key changer dialog anyways? Can't wait to have my comp back, month and a half later....

Link to comment
Share on other sites

It will be random since all i'm doing is a check of "vehicles" which is an array of the vehicles on the server and checking the key against that.

I have a week off work from tomorrow (unless my boss is going to be a dick) so I'll try and dedicate some time to this and see if I can get a resolution, because I agree, it is annoying.

Link to comment
Share on other sites

34 minutes ago, Runewulv said:

this is good news though salival, thanks for your hardwork. I love the ability to fire up my heli rotors while still at the trader remotely. And the lock/unlock/player kick is so great too.

The great thing I like about this script is this is the only version where vehicles will stay turned on when you turn the engine on remotely. Other versions require you to have been in it before it will stay on permanently

Link to comment
Share on other sites

  • 2 months later...

I added vehicle selection menu for masterkey, in the same way as Call car script.

Spoiler

/*
    Remote vehicle script by salival (https://github.com/oiad) modified by Schalldampfer
*/

private ["_characterID","_checkDistance","_display","_distance","_fuel","_group","_keyFound","_keyID","_keyName","_option","_time","_ownerID","_vehicle","_vehicleType","_vehicleName"];

_keyName = _this select 0;
_option = _this select 1;

_checkDistance = true; // Check to see if the player is too far away from the remote
_distance = 300; // Maximum distance the player can be away from the vehicle to be able to use the remote.

disableSerialization;

_display = findDisplay 106;
_display closeDisplay 0;

if ( !("ItemRadio" in ([player] call BIS_fnc_invString)) ) exitWith {"You don't have a radio." call dayz_rollingMessages;};

_keyID = 0;
{
    if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]) then {
        if (_x == _keyName) then {
            _keyID = getNumber(configFile >> "CfgWeapons" >> _x >> "keyid");
        };
    };
} forEach (items player);

if (_keyID == 0) exitWith {"No valid keys in your toolbelt." call dayz_rollingMessages;};

_keyFound = false;
_vehList = [];
{
    _ownerID = parseNumber (_x getVariable ["CharacterID","0"]);
    if (_keyID == _ownerID) then {
        _vehList set [count _vehList,_x];//Add vehicle to list
    };
} count vehicles;
CC_vehID = count _vehList;
_keyFound = count _vehList > 0;

if (!_keyFound) exitWith {"Unable to find any vehicle for this key." call dayz_rollingMessages;};


//Selection menu
SelectKitt = [
    [format["Remote Key %1",_keyName],true],
    ["Select car", [0], "", -2, [["expression", ""]], "1", "0"]
];
{
    SelectKitt set[count SelectKitt, [ format["%1@%2m", getText (configFile >> "CfgVehicles" >> (typeOf _x) >> "displayName"), round(player distance _x)], [0], "", -5, [ ["expression",format["CC_vehID=%1;",_forEachIndex]] ], "1", "1"] ];
} forEach _vehList;
SelectKitt set [count SelectKitt, ["Exit", [1], "", -3, [["expression", "CC_vehID = count _vehList;"]], "1", "1"] ];

if (count _vehList == 1) then {
    CC_vehID = 0;
} else {
    showCommandingMenu "#USER:SelectKitt";
    //Wait for selection
    waitUntil {(CC_vehID != count _vehList)||(commandingMenu == "")};
};

//Set selected Vehicle
_vehicle = _vehList select CC_vehID;
_vehicleName =getText (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName");

if (!alive _vehicle) exitWith {"The vehicle has been destroyed." call dayz_rollingMessages;};

if (_checkDistance && {(player distance _vehicle) >= _distance}) exitWith {format ["The %1 is out of range.",_vehicleName] call dayz_rollingMessages;};

if (_option == 1) then {
    _group = units group player;

    format ["Ejecting all players not in your group from %1",_vehicleName] call dayz_rollingMessages;

    {
        if !(_x in _group) then {
            _x action ["eject",_vehicle];
            format ["Ejecting %1, he is NOT in your group.",name _x] call dayz_rollingMessages;
        };
    } forEach (crew _vehicle);
};

if (_option == 2) then {
    format ["Toggling engine of %1",_vehicleName] call dayz_rollingMessages;
    if (isEngineOn _vehicle) then {
        if (_vehicle isKindOf "Helicopter") then { // This is needed because dayz_engineSwitch won't turn off the engine for a helicopter.
            _fuel = fuel _vehicle;
            _vehicle setFuel 0;
            player action ["engineOff",_vehicle];
            uiSleep 4; 
            _vehicle setFuel _fuel;
        } else {
            [_vehicle,false] call dayz_engineSwitch;
        };
    } else {
        [_vehicle,true] call dayz_engineSwitch;
    };
};

if (_option == 3) then {
    format ["Unlocking %1",_vehicleName] call dayz_rollingMessages;
    PVDZE_veh_Lock = [_vehicle,false];
    _time = diag_tickTime;

    if (local _vehicle) then {
        PVDZE_veh_Lock call local_lockUnlock;
    } else {
        publicVariable "PVDZE_veh_Lock";
        //Wait for lock status to update over network (can take up to a few seconds)
        waitUntil {uiSleep 0.1;(!locked _vehicle or (diag_tickTime - _time > 4))};
    };
};

if (_option == 4) then {
    format ["Locking %1",_vehicleName] call dayz_rollingMessages;
    PVDZE_veh_Lock = [_vehicle,true];
    _time = diag_tickTime;

    if (local _vehicle) then {
        PVDZE_veh_Lock call local_lockUnlock;
    } else {
        publicVariable "PVDZE_veh_Lock";
        //Wait for lock status to update over network (can take up to a few seconds)
        waitUntil {uiSleep 0.1;(locked _vehicle or (diag_tickTime - _time > 4))};
    };
};

if (_option == 5) then {
    if (_vehicle getVariable["lightOff",true]) then {
        player action ["lightOn", _vehicle];
        format ["Lights on %1",_vehicleName] call dayz_rollingMessages;
        _vehicle setVariable ["lightOn",true];
        _vehicle setVariable ["lightOff",false];
    } else {
        player action ["lightOff", _vehicle];
        format ["Lights off %1",_vehicleName] call dayz_rollingMessages;
        _vehicle setVariable ["lightOn",false];
        _vehicle setVariable ["lightOff",true];
    };
};

if (_option == 6) then {
    _locked = locked _vehicle;
    format ["%2 %1",_vehicleName,if(_locked) then {"Unlocking"} else {"Locking"}] call dayz_rollingMessages;
    PVDZE_veh_Lock = [_vehicle,!_locked];
    _time = diag_tickTime;

    if (local _vehicle) then {
        PVDZE_veh_Lock call local_lockUnlock;
    } else {
        publicVariable "PVDZE_veh_Lock";
    };
};
 

Working, (option 6 is lock&unlock depending on vehicle status.)
if you newly install or already updated to the newest one in the reply below, don't use this.  this is for old version

Link to comment
Share on other sites

Hi guys,

Just an update, I have been working on getting a menu working with this, I had it working completely just needing tidying but life/work got busy and I forgot about it

@Schalldampfer's post reminded me about it, I should hopefully have my version out in a few days/the weekend.

It's completely working, just needs tidying and localization, I basically just used the virtualgarage/vkc format dialogs, they seem to work well for vehicles.

Link to comment
Share on other sites

Hi guys,

Here's the updated version with the dialog menu which works with multiple vehicles per key, works quite well, I also added @ViktorReznov's suggestion with a toggle for the lights on/off.

I will work on getting the script working with localizations this weekend.

I tested this quite a bit, but please give it a test and see how it works and report any bugs.

Dialog update: https://github.com/oiad/remoteVehicle/commit/364582917489b51694e431c2014c52e4a789fe4d

forgotten battleye filter: https://github.com/oiad/remoteVehicle/commit/9cb398237dbeba59a654fb23965aa2c35f777b7e

Link to comment
Share on other sites

  • 1 month later...
Guest
This topic is now closed to further replies.
  • Discord

×
×
  • Create New...