Jossy Posted August 6, 2014 Report Share Posted August 6, 2014 This is just a quick script to a follow up request, no ongoing support really, though it shouldn't need much.. Setup Instructions You will need custom fn_selfActions.sqf and variables.sqf files for this, if you don't already have these then you will need to look up how to setup a custom compiles.sqf. 1. Save this code into a new file under your mission folder, preferably custom\vehicle_lockUnlock.sqf. (if you save it to a different folder be sure to rename the paths in step 4.) private ["_action","_vehicle","_lock","_keyName"]; _action = _this select 3; _vehicle = _action select 0; _lock = _action select 1; if (count _action > 2) then { _keyName = _action select 2; }; {_vehicle removeAction _x} forEach s_player_incarlockunlock;s_player_incarlockunlock = []; s_player_inCarlockUnlock_crtl = -1; if (_lock) then { _vehicle setVehicleLock "LOCKED"; PVDZE_veh_Lock = [_vehicle,true]; publicVariable "PVDZE_veh_Lock"; if (_keyName != "") then { cutText [ format ["%1 key used to lock vehicle", _keyName], "PLAIN DOWN"]; } else { cutText [ format ["You locked the vehicle", _keyName], "PLAIN DOWN"]; }; } else { _vehicle setVehicleLock "UNLOCKED"; PVDZE_veh_Lock = [_vehicle,false]; publicVariable "PVDZE_veh_Lock"; if (_keyName != "") then { cutText [ format ["%1 key used to unlock vehicle", _keyName], "PLAIN DOWN"]; } else { cutText [ format ["You unlocked the vehicle"], "PLAIN DOWN"]; }; }; s_player_inCarlockUnlock_crtl = -1; 2. Paste this in the dayz_resetSelfActions section of your custom variables.sqf file at roughly line 254. s_player_inCarlockUnlock_crtl = -1; s_player_incarlockunlock = []; 3. Also paste this in your custom variables.sqf file at roughly line 757 dayz_myLockedVehicle = objNull; 4a. This part is for Locking/Unlocking vehicles with no key requirement, paste this code into your fn_selfActions.sqf file at roughly line 14. // Lock car doors with no key if (_inVehicle && driver _vehicle == player) then { if (s_player_inCarlockUnlock_crtl < 0) then { dayz_myLockedVehicle = _vehicle; _text = getText (configFile >> "CfgVehicles" >> typeOf(dayz_myLockedVehicle) >> "displayName"); cutText [ format ["vehicle: %1", _text], "PLAIN DOWN"]; if(locked dayz_myLockedVehicle) then { _Unlock = dayz_myLockedVehicle addAction [format[localize "STR_EPOCH_ACTIONS_UNLOCK",_text], "custom\vehicle_lockUnlock.sqf", [dayz_myLockedVehicle, false], 2, true, true, "", ""]; s_player_incarlockunlock set [count s_player_incarlockunlock,_Unlock]; s_player_inCarlockUnlock_crtl = 1; } else { _lock = dayz_myLockedVehicle addAction [format[localize "STR_EPOCH_ACTIONS_LOCK",_text], "custom\vehicle_lockUnlock.sqf", [dayz_myLockedVehicle, true], 1, false, true, "", ""]; s_player_incarlockunlock set [count s_player_incarlockunlock,_lock]; s_player_inCarlockUnlock_crtl = 1; }; }; } else { {dayz_myLockedVehicle removeAction _x} count s_player_incarlockunlock;s_player_incarlockunlock = []; s_player_inCarlockUnlock_crtl = -1; }; 4b. This option is for having a matching key requirement and is slightly different, paste this section into your fn_selfActions.sqf anywhere after _inVehicle = (_vehicle != player); roughly line 14. // Lock car doors with key private ["_carID","_hasKeyinCar"]; if (_inVehicle && driver _vehicle == player) then { _itemsPlayer = items player; _temp_keys = []; _temp_keys_names = []; // find available keys _key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]; { if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _key_colors) then { _ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _x >> "keyid"); _ownerKeyName = getText(configFile >> "CfgWeapons" >> _x >> "displayName"); _temp_keys_names set [_ownerKeyId,_ownerKeyName]; _temp_keys set [count _temp_keys,str(_ownerKeyId)]; }; } count _itemsPlayer; _carID = _vehicle getVariable ["CharacterID", "0"]; _hasKeyinCar = _carID in _temp_keys; if (s_player_inCarlockUnlock_crtl < 0 && _hasKeyinCar) then { dayz_myLockedVehicle = _vehicle; _text = getText (configFile >> "CfgVehicles" >> typeOf(dayz_myLockedVehicle) >> "displayName"); if(locked dayz_myLockedVehicle) then { _Unlock = dayz_myLockedVehicle addAction [format[localize "STR_EPOCH_ACTIONS_UNLOCK",_text], "custom\vehicle_lockUnlock.sqf",[dayz_myLockedVehicle, false, (_temp_keys_names select (parseNumber _carID))], 2, true, true, "", ""]; s_player_incarlockunlock set [count s_player_incarlockunlock,_Unlock]; s_player_inCarlockUnlock_crtl = 1; } else { _lock = dayz_myLockedVehicle addAction [format[localize "STR_EPOCH_ACTIONS_LOCK",_text], "custom\vehicle_lockUnlock.sqf",[dayz_myLockedVehicle, true, (_temp_keys_names select (parseNumber _carID))], 1, false, true, "", ""]; s_player_incarlockunlock set [count s_player_incarlockunlock,_lock]; s_player_inCarlockUnlock_crtl = 1; }; }; } else { {dayz_myLockedVehicle removeAction _x} count s_player_incarlockunlock;s_player_incarlockunlock = []; s_player_inCarlockUnlock_crtl = -1; }; 31_D!4b10, AG.Ndogg97 and looter809 3 Link to comment Share on other sites More sharing options...
AG.Ndogg97 Posted August 6, 2014 Report Share Posted August 6, 2014 Hey man great work I'll report back to you how it works when our head coder gets back. Should be this weekend, give or take. Cheers again man keep up the great work! Link to comment Share on other sites More sharing options...
Coco-Nuts Posted September 5, 2014 Report Share Posted September 5, 2014 Hello, I put the event to unlock abandoned vehicle. Can I lock my "abandoned vehicle" if I got the key ? I mean, if my vehicle is definitively unlock by the SQL event, can I lock the vehicle with the right key with this script ? Link to comment Share on other sites More sharing options...
Jossy Posted September 6, 2014 Author Report Share Posted September 6, 2014 if your SQL unlocks vehicles then there is no right key, it removes the key from the vehicle so no you will not unless you use the code to lock it without keys Link to comment Share on other sites More sharing options...
Coco-Nuts Posted September 6, 2014 Report Share Posted September 6, 2014 Ok I see. Do you have a solution to lock again the vehicle ? Link to comment Share on other sites More sharing options...
Coco-Nuts Posted September 7, 2014 Report Share Posted September 7, 2014 Bump Link to comment Share on other sites More sharing options...
Tricks Posted September 12, 2014 Report Share Posted September 12, 2014 Can someone explain better what this script does exactly? Link to comment Share on other sites More sharing options...
Zupa Posted September 12, 2014 Report Share Posted September 12, 2014 It allows you to lock a car when you are in it. You are in trader, your m8 goes sell stuff, driver locks the door from the inside utill friend is back sagely Link to comment Share on other sites More sharing options...
Tricks Posted September 12, 2014 Report Share Posted September 12, 2014 That's amazing! I am assuming you can unlock the vehicle from within as well? This will help greatly with the trader lag and players getting into vehicles before they lock! Thank you Link to comment Share on other sites More sharing options...
Jossy Posted September 12, 2014 Author Report Share Posted September 12, 2014 That's amazing! I am assuming you can unlock the vehicle from within as well? This will help greatly with the trader lag and players getting into vehicles before they lock! Thank you You can't get out once it's locked though if that's what you're thinking, it's more to stop people trolling you and getting into your vehicle while you're still Link to comment Share on other sites More sharing options...
SadBoy1981 Posted September 12, 2014 Report Share Posted September 12, 2014 Any config for Infistar??? edit I try config on AHconfig.sqf add in line _dayzActions = "s_player_inCarlockUnlock_crtl","s_player_incarlockunlock","dayz_myLockedVehicle" im not sure is this needed, but for me works, nobody banned or kicked out Is it possible to add something like, if player dont have key, he cant use driver sit? Link to comment Share on other sites More sharing options...
oSoDirty Posted October 20, 2014 Report Share Posted October 20, 2014 Ok I see. Do you have a solution to lock again the vehicle ? When your sql unlocks the car it sets the char ID to 0 thus removing it ability to use a key. What you can do, if you have the key and know what the variables for that key mean (ie. color letters & numbers) as they all correspond to the char ID. You can find that vehicle in the data base and edit the char ID.(Im not positive how keys work but use a lock box as a reference .. for the code red42 the char ID will be 10042 the 100 is red and 42 is well... duh! and with a bit of testing im sure could figure it out.) OR (easier way) with infistar just find a locked vehicle in the DB and use its char ID for a reference. make a new char ID using the same format (obviously one that does not exist) then use infistar's generate key function. However, most people that have left a vehicle abandoned for 2 or more weeks usually have no desire to repossess it and most likely have forgotten of its existence! Link to comment Share on other sites More sharing options...
probygoingtoneedlotsofhelp Posted November 27, 2014 Report Share Posted November 27, 2014 can someone make a script using the unlock non key script so that if someone breaks the driver side window you can unlock the car (only for cars)? Link to comment Share on other sites More sharing options...
CordIAsis Posted November 27, 2014 Report Share Posted November 27, 2014 @oSoDirty, little nugget of wisdom on keys for you :) To find the corresponding character id for a key you can use this piece of code- _keyid = getNumber(configFile/'cfgWeapons'/_thekey/'keyid'); Where _thekey is the class name of the target key. And to find the corresponding key to a vehicle you can use this- _vid = parseNumber (cursorTarget getVariable ['CharacterID','0']); if ((_vid > 0) && (_vid <= 2500)) then {_key = format ['ItemKeyGreen%1',_vid];}; if ((_vid > 2500) && (_vid <= 5000)) then {_key = format ['ItemKeyRed%1',(_vid - 2500)];}; if ((_vid > 5000) && (_vid <= 7500)) then {_key = format ['ItemKeyBlue%1',(_vid - 5000)];}; if ((_vid > 7500) && (_vid <= 10000)) then {_key = format ['ItemKeyYellow%1',(_vid - 7500)];}; if ((_vid > 10000) && (_vid <= 12500)) then {_key = format ['ItemKeyBlack%1',(_vid - 10000)];}; That one is pulled straight from something I'm making and checks the cursorTarget but that's easy to change. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now