Jump to content
salival

[Release] Remote vehicle locking/engine/eject script.

Recommended Posts

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.

This uses @mudzereliclick actions mod as a dependency (https://github.com/mudzereli/DayZEpochDeployableBike/tree/master/overwrites/click_actions) because it's awesome.

Thanks to @Pattohfor the idea for this script.

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

Share this post


Link to post
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!

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
Just now, salival said:

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

would have been clearer if I just would have read the script itself first. I checked the git for differences in ui_select slot instead. Great scripts!

Share this post


Link to post
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)

Share this post


Link to post
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!

Share this post


Link to post
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

Share this post


Link to post
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 :)

Share this post


Link to post
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

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
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....

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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["%[email protected]%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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
		<Key ID="STR_RV_TITLE">
			<English>Remote Vehicle - Vehicles for %1</English>
			<German>Fahrzeugfernsteuerung - Fahrzeuge für %1</German>
		</Key>

Where can I see this message?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Similar Content

    • By Brian Soanes
      To unlock vehicles left in your traders over a server restart, open your epoch_server.pbo

      In epoch_server\compile\epoch_vehicle\EPOCH_load_vehicles.sqf
      Find
      if (_allowDamage) then { Just above that, add this
      A3E_SafeZonePosArray = [ [[18451.9,14278.1,0]], //Altis East trader [[13333.5,14494.3,0]], //Altis Central trader [[6192.46,16834,0]] //Altis West trader ]; { if (_vehicle distance (_x select 0) < 200) then { _vehicle lock false; diag_log format["Vehicle %1 left in trader unlocked @ %2", _class, mapGridPosition _vehicle]; }; } forEach A3E_SafeZonePosArray; Pack pbo and you're good to go
    • By Thug
      I have an overpoch Sauerland server. The vehicle traders are not spawning when you buy. The SOB takes your money and gives you a key, but no vehicle.  The arrow comes up for about 12 seconds.  After the restart, they are there, all on top of each other.
      NO, I do not have infistar installed.  It brakes the server. No admin tools at all.
      Here are my server and client RPTs. Can someone please take a look for me?
      Client
      Server
      All other traders work.
       
    • By ufukinwotm8
      Hi guys, have a problem with the server I help run. The hotkeys (1-2-3 for guns, 4-5-6 meds etc.) don't work. Setting the variable dayz_quickSwitch to true or false doesn't change anything.
    • By harcosgoogle
      Hi!
       
      Automatic vehicle unlock (2) after day ?
       
      (Inactive players,locked vehicle Example)
       
      Thanks
    • By harcosgoogle
      Hi!
       
      Trader - Server restart (3hour) unlock vehiles  in trade?
       
      So the vehicle will open at restart
      Unlock vehicle trader restart (3 hours)
      Many leave it in vehicle
       
      Sorry no speak English
  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...