orionjade Posted October 31, 2014 Report Share Posted October 31, 2014 I was wondering if anyone has vehicle key changer working with the coin system? I've seen many posts asking about it on the thread for it but seems like everyone ignores it over there. Here is a link to the version I'm looking for to be a little more specific. Link to comment Share on other sites More sharing options...
Gr8 Posted October 31, 2014 Report Share Posted October 31, 2014 I will try to Edit it, and get back to you Link to comment Share on other sites More sharing options...
orionjade Posted November 3, 2014 Author Report Share Posted November 3, 2014 That would be awesome, thanks. Link to comment Share on other sites More sharing options...
Vindomire Posted November 30, 2014 Report Share Posted November 30, 2014 i have it working on my server... wasnt too difficult to do... VehicleKeyChanger_init.sqf /***********************************/ /* Vehicle Key Changer v1.3 */ /* Written by OtterNas3 */ /* January, 11, 2014 */ /* Last update: 02/20/2014 */ /***********************************/ private ["_playerDollars","_itemsPlayer","_magazinesPlayer","_temp_Keys","_temp_keysDisplayName","_temp_keysDisplayNameParse","_key_colors","_ownerKeyId","_carKey","_hasKey","_cTarget","_keyName","_carKeyName","_targetVehicleKey","_temp_keysParse"]; ///////////////////////////////////////////////// ///////////////////////////////////////////////// // Edit these settings to fit your needs/likes // ///////////////////////////////////////////////// ///////////////////////////////////////////////// /// Claim Vehicles that does not yet need Key /// ///////// 0 = Not allowed | 1 = Allowed ///////// vkc_claiming = 1; ///////////////////////////////////////////////// //////// Claim Vehicles costs this Item ///////// /// Any Item can be used here, some examples: /// //// ItemTinBar, ItemSilverBar, ItemGoldBar, //// ////// ItemSilverBar10oz, ItemGoldBar10oz, ////// ///// ItemBriefcase20oz, ItemBriefcase100oz ///// //////// set to "0" to disable the costs //////// vkc_claimingPrice = 5000; ///////////////////////////////////////////////// ////////// Change Key costs this Item// ///////// ////////////// see above examples /////////////// //////// set to "0" to disable the costs //////// vkc_Price = 5000; ///////////////////////////////////////////////// /////// Need KeyKit to use this function //////// ////////// 0 = Not needed | 1 = Needed ////////// vkc_needKeykit = 1; ///////////////////////////////////////////////// ///////////////////////////////////////////////// /////////////// DONT EDIT BELOW ! /////////////// ///////////////////////////////////////////////// /* Reset variables function */ ON_fnc_vkc_reset = { _cTarget = objNull; _itemsPlayer = []; _temp_keys = []; _carKey = objNull; _hasKey = false; _temp_keysDisplayName = []; _temp_keysDisplayNameParse = []; _temp_keysParse = []; _targetVehicleKey = objNull; _carKeyName = ""; player removeAction s_player_copyToKey; s_player_copyToKey = -1; }; //Added for Fix dayz_objectUID_vkc = { private["_position","_dir","_key","_object"]; _object = _this; _position = getPosATL _object; _dir = direction _object; _key = [_dir,_position] call dayz_objectUID2_vkc; _key }; dayz_objectUID2_vkc = { private["_position","_dir","_key"]; _dir = _this select 0; _key = ""; _position = _this select 1; { _x = _x * 10; if ( _x < 0 ) then { _x = _x * -10 }; _key = _key + str(round(_x)); } forEach _position; _key = _key + str(round(_dir)); _key }; /* Wait for player full ingame so we can access the action-menu */ waitUntil {!isNil "dayz_animalCheck"}; s_player_copyToKey=-1; lastKeyChangeCursorTarget = [objNull,objNull,objNull,objNull,objNull]; /* Start the loop check */ while{true} do { sleep 3; _playerDollars = player getVariable['cashMoney', 0]; if (!isNull cursorTarget && speed player <= 1 && (vehicle player) == player && !isEngineOn cursorTarget && (cursorTarget isKindOf "Motorcycle" || cursorTarget isKindOf "Car" || cursorTarget isKindOf "Air" || cursorTarget isKindOf "Ship" || cursorTarget isKindOf "Truck" || cursorTarget isKindOf "Tank") && (cursorTarget distance player) <= 10 && cursorTarget getVariable ["VKC_disabled", 0] == 0 && cursorTarget getVariable ["VKC_claiming_disabled",0] == 0) then { _cTarget = cursorTarget; _itemsPlayer = items player; _magazinesPlayer = magazines player; if ((lastKeyChangeCursorTarget select 0) != _cTarget) then { if (s_player_copyToKey >= 0) then { player removeAction s_player_copyToKey; s_player_copyToKey = -1; }; }; lastKeyChangeCursorTarget set [0,_cTarget]; _carKey = _cTarget getVariable ["CharacterID","0"]; if (("ItemKeyKit" in _itemsPlayer || vkc_needKeykit == 0) && ((_carKey == "0" && vkc_claiming == 1 && (vkc_claimingPrice == 0 || vkc_claimingPrice < _playerDollars)) || _carKey != "0") && (vkc_Price == 0 || vkc_Price < _playerDollars)) then { if (_carKey == "0") then { _temp_keys = []; _temp_keysDisplayName = []; _temp_keysDisplayNameParse = []; _key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]; { if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _key_colors) then { _ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _x >> "keyid"); _keyName = getText(configFile >> "CfgWeapons" >> _x >> "displayName"); _temp_keysDisplayName set [count _temp_keysDisplayName,_keyName]; _temp_keys set [count _temp_keys,str(_ownerKeyId)]; }; } forEach _itemsPlayer; if ((count _temp_keys) > 0) then { if (s_player_copyToKey < 0) then { lastKeyChangeCursorTarget set [0,_cTarget]; s_player_copyToKey = player addAction [("<t color=""#0000FF"">" + ("Claim Vehicle") + "</t>"),"custom\VehicleKeyChanger\VehicleKeyChanger.sqf",[_cTarget, _temp_keys, "0", _temp_keysDisplayName, "0", "0", vkc_Price, vkc_claimingPrice],-1,false,false,"",""]; }; } else { [] call ON_fnc_vkc_reset; }; } else { _temp_keys = []; _temp_keysDisplayName = []; _temp_keysDisplayNameParse = []; _temp_keysParse = []; _key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]; { if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _key_colors) then { _ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _x >> "keyid"); _keyName = getText(configFile >> "CfgWeapons" >> _x >> "displayName"); _temp_keysDisplayName set [count _temp_keysDisplayName,_keyName]; _temp_keysDisplayNameParse set [_ownerKeyId,_keyName]; _temp_keys set [count _temp_keys,str(_ownerKeyId)]; _temp_keysParse set [_ownerKeyId, _x]; }; } forEach _itemsPlayer; _hasKey = _carKey in _temp_keys; if (_hasKey && (count _temp_keys) > 1) then { _carKeyName = (_temp_keysDisplayNameParse select (parseNumber _carKey)); _targetVehicleKey = (_temp_keysParse select (parseNumber _carKey)); _temp_keys = _temp_keys - [_carKey]; _temp_keysDisplayName = _temp_keysDisplayName - [_carKeyName]; if (s_player_copyToKey < 0) then { lastKeyChangeCursorTarget set [0,_cTarget]; s_player_copyToKey = player addAction [("<t color=""#0000FF"">" + ("Change Vehicle Key") + "</t>"),"custom\VehicleKeyChanger\VehicleKeyChanger.sqf",[_cTarget, _temp_keys, _carKey, _temp_keysDisplayName, _carKeyName, _targetVehicleKey, vkc_Price, 0],-1,false,false,"",""]; }; } else { [] call ON_fnc_vkc_reset; }; }; } else { [] call ON_fnc_vkc_reset; }; } else { lastKeyChangeCursorTarget = [objNull,objNull,objNull,objNull,objNull]; [] call ON_fnc_vkc_reset; }; }; VehicleKeyChanger.sqf /***********************************/ /* Vehicle Key Changer v1.3 */ /* Written by OtterNas3 */ /* January, 11, 2014 */ /* Last update: 02/20/2014 */ /***********************************/ /* Setup the private variables */ private ["_magazinesPlayer","_max","_j","_actionArray","_targetVehicle","_targetVehicleID","_targetVehicleUID","_playerKeys","_playerKeysDisplayName","_targetVehicleKeyName","_itemKeyName","_targetVehicleClassname","_targetVehiclePos","_targetVehicleDir","_Price","_claimingPrice"]; /* Remove the Action Menu entry */ player removeAction s_player_copyToKey; s_player_copyToKey = 0; /* Get the array and setup the variables */ _actionArray = _this select 3; _targetVehicle = _actionArray select 0; _targetVehicleID = _targetVehicle getVariable ["ObjectID","0"]; _targetVehicleUID = _targetVehicle getVariable ["ObjectUID","0"]; /* Check if the Vehicle is in the Database, if false exit */ if (_targetVehicleID == "0" && _targetVehicleUID == "0") exitWith {s_player_copyToKey = -1;}; /* Setup more variables */ _playerKeys = _actionArray select 1; _playerKeysDisplayName = _actionArray select 3; _targetVehicleKeyName = _actionArray select 4; _itemKeyName = _actionArray select 5; _Price = _actionArray select 6; _claimingPrice = _actionArray select 7; _targetVehicleClassname = typeOf _targetVehicle; _targetVehiclePos = getPosATL _targetVehicle; _targetVehicleDir = getDir _targetVehicle; /* Setup the Key Names list to select from */ keyNameList = []; for "_i" from 0 to (count _playerKeysDisplayName) -1 do { keyNameList set [(count keyNameList), _playerKeysDisplayName select _i]; }; /* Setup the Key Numbers list to select from */ keyNumberList = []; for "_i" from 0 to (count _playerKeys) -1 do { keyNumberList set [(count keyNumberList), _playerKeys select _i]; }; /* Resetting menu variables*/ keyNameSelect = ""; exitscript = true; snext = false; /* Creating the menu */ copyMenu = { private ["_keyMenu","_keyArray"]; _keyMenu = [["",true], ["Change Vehicle to Key:", [-1], "", -5, [["expression", ""]], "1", "0"]]; for "_i" from (_this select 0) to (_this select 1) do { _keyArray = [format['%1', keyNameList select (_i)], [_i - (_this select 0) + 2], "", -5, [["expression", format ["keyNameSelect = keyNameList select %1; keyNumberSelect = keyNumberList select %1", _i]]], "1", "1"]; _keyMenu set [_i + 2, _keyArray]; }; _keyMenu set [(_this select 1) + 2, ["", [-1], "", -5, [["expression", ""]], "1", "0"]]; if (count keyNameList > (_this select 1)) then { _keyMenu set [(_this select 1) + 3, ["Next", [12], "", -5, [["expression", "snext = true;"]], "1", "1"]]; } else { _keyMenu set [(_this select 1) + 3, ["", [-1], "", -5, [["expression", ""]], "1", "0"]]; }; _keyMenu set [(_this select 1) + 4, ["Exit", [13], "", -5, [["expression", "keyNameSelect = 'exitscript';"]], "1", "1"]]; showCommandingMenu "#USER:_keyMenu"; }; /* Wait for the player to select a Key from the list */ _j = 0; _max = 10; if (_max > 9) then {_max = 10;}; while {keyNameSelect == ""} do { [_j, (_j + _max) min (count keyNameList)] call copyMenu; _j = _j + _max; waitUntil {keyNameSelect != "" || snext}; snext = false; }; /* Player selected a Key, lets make the Vehicle update call */ if (keyNameSelect != "exitscript") then { /* Check again for the needed TinBar or claiming price and remove em from the players inventory */ _magazinesPlayer = magazines player; _playerDollars = player getVariable['cashMoney', 0]; if (_Price > 0) then { if (_Price < _playerDollars) then { //[player, _Price, 1] call BIS_fnc_invRemove; player setVariable["cashMoney",_playerDollars - _Price, true]; systemChat (format["Keychange costs %1 Dollars, thanks for your Payment!", _Price]); } else { systemChat (format["Keychange costs %1 Dollars, you had it and tried to trick the system - Keychange for this Vehicle disabled!", Price]); _targetVehicle setVariable ["VKC_disabled", 1, true]; s_player_copyToKey = -1; breakOut "exit"; }; }; if (_claimingPrice > 0) then { if (_claimingPrice < _playerDollars) then { //[player, _claimingPrice, 1] call BIS_fnc_invRemove; player setVariable["cashMoney",_playerDollars - _claimingPrice, true]; systemChat (format["Claiming Vehicle costs %1 Dollars, thanks for your Payment!", _claimingPrice]); } else { systemChat (format["Claiming Vehicle costs %1 Dollars, you had it and tried to trick the system - Claiming for this Vehicle disabled!", Price]); _targetVehicle setVariable ["VKC_claiming_disabled", 1, true]; s_player_copyToKey = -1; breakOut "exit"; }; }; /* We got the Money lets do our Job */ /* Lock the vehicle */ _targetVehicle setVehicleLock "LOCKED"; /* The super duper OneForAllAnimation... */ player playActionNow "Medic"; /* Remove the Key from the Toolbelt of the player and put it in the Backpack - No Backpack and the Key gets lost */ if (_itemKeyName != "0") then { if (!isNull (unitBackpack player)) then { [player, _itemKeyName, 1] call BIS_fnc_invRemove; (unitBackpack (vehicle player)) addWeaponCargoGlobal [_itemKeyName, 1]; systemChat (format["%1 has been moved to your Backpack", _targetVehicleKeyName]); }; }; /* Giving unique UID for claimed vehicles */ if (_targetVehicleUID=="0") then { _targetVehicleUID = _targetVehicle call dayz_objectUID_vkc; _targetVehicle setVariable ["ObjectUID",_targetVehicleUID,true]; // It does probably nothing and it's not needed :) }; /* This calls the custom update function which we put it in server_updateObject.sqf */ PVDZE_veh_Update = [_targetVehicle, "vehiclekey", player, _targetVehicleClassname, keyNumberSelect, keyNameSelect, _targetVehicleID, _targetVehicleUID]; publicVariableServer "PVDZE_veh_Update"; /* Inform the player about the success and tell him to check the Key */ systemChat (format["Changed Vehicle Key to %1", keyNameSelect]); if (_targetVehicleKeyName != "0") then { systemChat (format["Please check Vehicle function with %1 before you throw away %2!", keyNameSelect, _targetVehicleKeyName]); }; }; /* Reset the action menu variable for a new run */ s_player_copyToKey = -1; /**************************************/ /* That's it, hope you enjoy this Mod */ /* */ /* Yours sincerly, */ /* Otter */ /**************************************/ This uses Souls Version so those money variables are set up for his not the 999 version,,, DamianL and orionjade 2 Link to comment Share on other sites More sharing options...
orionjade Posted December 2, 2014 Author Report Share Posted December 2, 2014 i have it working on my server... wasnt too difficult to do... VehicleKeyChanger_init.sqf/***********************************/ /* Vehicle Key Changer v1.3 */ /* Written by OtterNas3 */ /* January, 11, 2014 */ /* Last update: 02/20/2014 */ /***********************************/ private ["_playerDollars","_itemsPlayer","_magazinesPlayer","_temp_Keys","_temp_keysDisplayName","_temp_keysDisplayNameParse","_key_colors","_ownerKeyId","_carKey","_hasKey","_cTarget","_keyName","_carKeyName","_targetVehicleKey","_temp_keysParse"]; ///////////////////////////////////////////////// ///////////////////////////////////////////////// // Edit these settings to fit your needs/likes // ///////////////////////////////////////////////// ///////////////////////////////////////////////// /// Claim Vehicles that does not yet need Key /// ///////// 0 = Not allowed | 1 = Allowed ///////// vkc_claiming = 1; ///////////////////////////////////////////////// //////// Claim Vehicles costs this Item ///////// /// Any Item can be used here, some examples: /// //// ItemTinBar, ItemSilverBar, ItemGoldBar, //// ////// ItemSilverBar10oz, ItemGoldBar10oz, ////// ///// ItemBriefcase20oz, ItemBriefcase100oz ///// //////// set to "0" to disable the costs //////// vkc_claimingPrice = 5000; ///////////////////////////////////////////////// ////////// Change Key costs this Item// ///////// ////////////// see above examples /////////////// //////// set to "0" to disable the costs //////// vkc_Price = 5000; ///////////////////////////////////////////////// /////// Need KeyKit to use this function //////// ////////// 0 = Not needed | 1 = Needed ////////// vkc_needKeykit = 1; ///////////////////////////////////////////////// ///////////////////////////////////////////////// /////////////// DONT EDIT BELOW ! /////////////// ///////////////////////////////////////////////// /* Reset variables function */ ON_fnc_vkc_reset = { _cTarget = objNull; _itemsPlayer = []; _temp_keys = []; _carKey = objNull; _hasKey = false; _temp_keysDisplayName = []; _temp_keysDisplayNameParse = []; _temp_keysParse = []; _targetVehicleKey = objNull; _carKeyName = ""; player removeAction s_player_copyToKey; s_player_copyToKey = -1; }; //Added for Fix dayz_objectUID_vkc = { private["_position","_dir","_key","_object"]; _object = _this; _position = getPosATL _object; _dir = direction _object; _key = [_dir,_position] call dayz_objectUID2_vkc; _key }; dayz_objectUID2_vkc = { private["_position","_dir","_key"]; _dir = _this select 0; _key = ""; _position = _this select 1; { _x = _x * 10; if ( _x < 0 ) then { _x = _x * -10 }; _key = _key + str(round(_x)); } forEach _position; _key = _key + str(round(_dir)); _key }; /* Wait for player full ingame so we can access the action-menu */ waitUntil {!isNil "dayz_animalCheck"}; s_player_copyToKey=-1; lastKeyChangeCursorTarget = [objNull,objNull,objNull,objNull,objNull]; /* Start the loop check */ while{true} do { sleep 3; _playerDollars = player getVariable['cashMoney', 0]; if (!isNull cursorTarget && speed player <= 1 && (vehicle player) == player && !isEngineOn cursorTarget && (cursorTarget isKindOf "Motorcycle" || cursorTarget isKindOf "Car" || cursorTarget isKindOf "Air" || cursorTarget isKindOf "Ship" || cursorTarget isKindOf "Truck" || cursorTarget isKindOf "Tank") && (cursorTarget distance player) <= 10 && cursorTarget getVariable ["VKC_disabled", 0] == 0 && cursorTarget getVariable ["VKC_claiming_disabled",0] == 0) then { _cTarget = cursorTarget; _itemsPlayer = items player; _magazinesPlayer = magazines player; if ((lastKeyChangeCursorTarget select 0) != _cTarget) then { if (s_player_copyToKey >= 0) then { player removeAction s_player_copyToKey; s_player_copyToKey = -1; }; }; lastKeyChangeCursorTarget set [0,_cTarget]; _carKey = _cTarget getVariable ["CharacterID","0"]; if (("ItemKeyKit" in _itemsPlayer || vkc_needKeykit == 0) && ((_carKey == "0" && vkc_claiming == 1 && (vkc_claimingPrice == 0 || vkc_claimingPrice < _playerDollars)) || _carKey != "0") && (vkc_Price == 0 || vkc_Price < _playerDollars)) then { if (_carKey == "0") then { _temp_keys = []; _temp_keysDisplayName = []; _temp_keysDisplayNameParse = []; _key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]; { if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _key_colors) then { _ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _x >> "keyid"); _keyName = getText(configFile >> "CfgWeapons" >> _x >> "displayName"); _temp_keysDisplayName set [count _temp_keysDisplayName,_keyName]; _temp_keys set [count _temp_keys,str(_ownerKeyId)]; }; } forEach _itemsPlayer; if ((count _temp_keys) > 0) then { if (s_player_copyToKey < 0) then { lastKeyChangeCursorTarget set [0,_cTarget]; s_player_copyToKey = player addAction [("<t color=""#0000FF"">" + ("Claim Vehicle") + "</t>"),"custom\VehicleKeyChanger\VehicleKeyChanger.sqf",[_cTarget, _temp_keys, "0", _temp_keysDisplayName, "0", "0", vkc_Price, vkc_claimingPrice],-1,false,false,"",""]; }; } else { [] call ON_fnc_vkc_reset; }; } else { _temp_keys = []; _temp_keysDisplayName = []; _temp_keysDisplayNameParse = []; _temp_keysParse = []; _key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]; { if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _key_colors) then { _ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _x >> "keyid"); _keyName = getText(configFile >> "CfgWeapons" >> _x >> "displayName"); _temp_keysDisplayName set [count _temp_keysDisplayName,_keyName]; _temp_keysDisplayNameParse set [_ownerKeyId,_keyName]; _temp_keys set [count _temp_keys,str(_ownerKeyId)]; _temp_keysParse set [_ownerKeyId, _x]; }; } forEach _itemsPlayer; _hasKey = _carKey in _temp_keys; if (_hasKey && (count _temp_keys) > 1) then { _carKeyName = (_temp_keysDisplayNameParse select (parseNumber _carKey)); _targetVehicleKey = (_temp_keysParse select (parseNumber _carKey)); _temp_keys = _temp_keys - [_carKey]; _temp_keysDisplayName = _temp_keysDisplayName - [_carKeyName]; if (s_player_copyToKey < 0) then { lastKeyChangeCursorTarget set [0,_cTarget]; s_player_copyToKey = player addAction [("<t color=""#0000FF"">" + ("Change Vehicle Key") + "</t>"),"custom\VehicleKeyChanger\VehicleKeyChanger.sqf",[_cTarget, _temp_keys, _carKey, _temp_keysDisplayName, _carKeyName, _targetVehicleKey, vkc_Price, 0],-1,false,false,"",""]; }; } else { [] call ON_fnc_vkc_reset; }; }; } else { [] call ON_fnc_vkc_reset; }; } else { lastKeyChangeCursorTarget = [objNull,objNull,objNull,objNull,objNull]; [] call ON_fnc_vkc_reset; }; }; VehicleKeyChanger.sqf/***********************************/ /* Vehicle Key Changer v1.3 */ /* Written by OtterNas3 */ /* January, 11, 2014 */ /* Last update: 02/20/2014 */ /***********************************/ /* Setup the private variables */ private ["_magazinesPlayer","_max","_j","_actionArray","_targetVehicle","_targetVehicleID","_targetVehicleUID","_playerKeys","_playerKeysDisplayName","_targetVehicleKeyName","_itemKeyName","_targetVehicleClassname","_targetVehiclePos","_targetVehicleDir","_Price","_claimingPrice"]; /* Remove the Action Menu entry */ player removeAction s_player_copyToKey; s_player_copyToKey = 0; /* Get the array and setup the variables */ _actionArray = _this select 3; _targetVehicle = _actionArray select 0; _targetVehicleID = _targetVehicle getVariable ["ObjectID","0"]; _targetVehicleUID = _targetVehicle getVariable ["ObjectUID","0"]; /* Check if the Vehicle is in the Database, if false exit */ if (_targetVehicleID == "0" && _targetVehicleUID == "0") exitWith {s_player_copyToKey = -1;}; /* Setup more variables */ _playerKeys = _actionArray select 1; _playerKeysDisplayName = _actionArray select 3; _targetVehicleKeyName = _actionArray select 4; _itemKeyName = _actionArray select 5; _Price = _actionArray select 6; _claimingPrice = _actionArray select 7; _targetVehicleClassname = typeOf _targetVehicle; _targetVehiclePos = getPosATL _targetVehicle; _targetVehicleDir = getDir _targetVehicle; /* Setup the Key Names list to select from */ keyNameList = []; for "_i" from 0 to (count _playerKeysDisplayName) -1 do { keyNameList set [(count keyNameList), _playerKeysDisplayName select _i]; }; /* Setup the Key Numbers list to select from */ keyNumberList = []; for "_i" from 0 to (count _playerKeys) -1 do { keyNumberList set [(count keyNumberList), _playerKeys select _i]; }; /* Resetting menu variables*/ keyNameSelect = ""; exitscript = true; snext = false; /* Creating the menu */ copyMenu = { private ["_keyMenu","_keyArray"]; _keyMenu = [["",true], ["Change Vehicle to Key:", [-1], "", -5, [["expression", ""]], "1", "0"]]; for "_i" from (_this select 0) to (_this select 1) do { _keyArray = [format['%1', keyNameList select (_i)], [_i - (_this select 0) + 2], "", -5, [["expression", format ["keyNameSelect = keyNameList select %1; keyNumberSelect = keyNumberList select %1", _i]]], "1", "1"]; _keyMenu set [_i + 2, _keyArray]; }; _keyMenu set [(_this select 1) + 2, ["", [-1], "", -5, [["expression", ""]], "1", "0"]]; if (count keyNameList > (_this select 1)) then { _keyMenu set [(_this select 1) + 3, ["Next", [12], "", -5, [["expression", "snext = true;"]], "1", "1"]]; } else { _keyMenu set [(_this select 1) + 3, ["", [-1], "", -5, [["expression", ""]], "1", "0"]]; }; _keyMenu set [(_this select 1) + 4, ["Exit", [13], "", -5, [["expression", "keyNameSelect = 'exitscript';"]], "1", "1"]]; showCommandingMenu "#USER:_keyMenu"; }; /* Wait for the player to select a Key from the list */ _j = 0; _max = 10; if (_max > 9) then {_max = 10;}; while {keyNameSelect == ""} do { [_j, (_j + _max) min (count keyNameList)] call copyMenu; _j = _j + _max; waitUntil {keyNameSelect != "" || snext}; snext = false; }; /* Player selected a Key, lets make the Vehicle update call */ if (keyNameSelect != "exitscript") then { /* Check again for the needed TinBar or claiming price and remove em from the players inventory */ _magazinesPlayer = magazines player; _playerDollars = player getVariable['cashMoney', 0]; if (_Price > 0) then { if (_Price < _playerDollars) then { //[player, _Price, 1] call BIS_fnc_invRemove; player setVariable["cashMoney",_playerDollars - _Price, true]; systemChat (format["Keychange costs %1 Dollars, thanks for your Payment!", _Price]); } else { systemChat (format["Keychange costs %1 Dollars, you had it and tried to trick the system - Keychange for this Vehicle disabled!", Price]); _targetVehicle setVariable ["VKC_disabled", 1, true]; s_player_copyToKey = -1; breakOut "exit"; }; }; if (_claimingPrice > 0) then { if (_claimingPrice < _playerDollars) then { //[player, _claimingPrice, 1] call BIS_fnc_invRemove; player setVariable["cashMoney",_playerDollars - _claimingPrice, true]; systemChat (format["Claiming Vehicle costs %1 Dollars, thanks for your Payment!", _claimingPrice]); } else { systemChat (format["Claiming Vehicle costs %1 Dollars, you had it and tried to trick the system - Claiming for this Vehicle disabled!", Price]); _targetVehicle setVariable ["VKC_claiming_disabled", 1, true]; s_player_copyToKey = -1; breakOut "exit"; }; }; /* We got the Money lets do our Job */ /* Lock the vehicle */ _targetVehicle setVehicleLock "LOCKED"; /* The super duper OneForAllAnimation... */ player playActionNow "Medic"; /* Remove the Key from the Toolbelt of the player and put it in the Backpack - No Backpack and the Key gets lost */ if (_itemKeyName != "0") then { if (!isNull (unitBackpack player)) then { [player, _itemKeyName, 1] call BIS_fnc_invRemove; (unitBackpack (vehicle player)) addWeaponCargoGlobal [_itemKeyName, 1]; systemChat (format["%1 has been moved to your Backpack", _targetVehicleKeyName]); }; }; /* Giving unique UID for claimed vehicles */ if (_targetVehicleUID=="0") then { _targetVehicleUID = _targetVehicle call dayz_objectUID_vkc; _targetVehicle setVariable ["ObjectUID",_targetVehicleUID,true]; // It does probably nothing and it's not needed :) }; /* This calls the custom update function which we put it in server_updateObject.sqf */ PVDZE_veh_Update = [_targetVehicle, "vehiclekey", player, _targetVehicleClassname, keyNumberSelect, keyNameSelect, _targetVehicleID, _targetVehicleUID]; publicVariableServer "PVDZE_veh_Update"; /* Inform the player about the success and tell him to check the Key */ systemChat (format["Changed Vehicle Key to %1", keyNameSelect]); if (_targetVehicleKeyName != "0") then { systemChat (format["Please check Vehicle function with %1 before you throw away %2!", keyNameSelect, _targetVehicleKeyName]); }; }; /* Reset the action menu variable for a new run */ s_player_copyToKey = -1; /**************************************/ /* That's it, hope you enjoy this Mod */ /* */ /* Yours sincerly, */ /* Otter */ /**************************************/ This uses Souls Version so those money variables are set up for his not the 999 version,,,I've tried with your files and it works for admins only, my players don't even see the option. I use infistar and I have it setup as the install instructions say. Not sure if it has to do with the server_updateObject.sqf or not. I see on your files that it says v1.3 and I only have the server_updateObject.sqf for the one that I linked in my original post. I've tried to edit the files that I linked but I keep getting errors in my RPT log so I must be doing something wrong. The files just seem to have a lot of differences in them. Link to comment Share on other sites More sharing options...
Gr8 Posted December 3, 2014 Report Share Posted December 3, 2014 add these to your allowed actions in AHconfig.sqf "s_player_copyToKey" orionjade 1 Link to comment Share on other sites More sharing options...
Vindomire Posted December 22, 2014 Report Share Posted December 22, 2014 dunno what to tell you about your version. I use 1.3... it works for me no issues... if there is an upgraded version i havent had to use it. Link to comment Share on other sites More sharing options...
physbo Posted January 8, 2015 Report Share Posted January 8, 2015 When i run this, it takes the money, but no longer changes keys. Link to comment Share on other sites More sharing options...
DamianL Posted January 10, 2015 Report Share Posted January 10, 2015 Thanks a lot for this! :) Link to comment Share on other sites More sharing options...
Oprama Posted February 23, 2015 Report Share Posted February 23, 2015 i have it working on my server... wasnt too difficult to do... VehicleKeyChanger_init.sqf /***********************************/ /* Vehicle Key Changer v1.3 */ /* Written by OtterNas3 */ /* January, 11, 2014 */ /* Last update: 02/20/2014 */ /***********************************/ private ["_playerDollars","_itemsPlayer","_magazinesPlayer","_temp_Keys","_temp_keysDisplayName","_temp_keysDisplayNameParse","_key_colors","_ownerKeyId","_carKey","_hasKey","_cTarget","_keyName","_carKeyName","_targetVehicleKey","_temp_keysParse"]; ///////////////////////////////////////////////// ///////////////////////////////////////////////// // Edit these settings to fit your needs/likes // ///////////////////////////////////////////////// ///////////////////////////////////////////////// /// Claim Vehicles that does not yet need Key /// ///////// 0 = Not allowed | 1 = Allowed ///////// vkc_claiming = 1; ///////////////////////////////////////////////// //////// Claim Vehicles costs this Item ///////// /// Any Item can be used here, some examples: /// //// ItemTinBar, ItemSilverBar, ItemGoldBar, //// ////// ItemSilverBar10oz, ItemGoldBar10oz, ////// ///// ItemBriefcase20oz, ItemBriefcase100oz ///// //////// set to "0" to disable the costs //////// vkc_claimingPrice = 5000; ///////////////////////////////////////////////// ////////// Change Key costs this Item// ///////// ////////////// see above examples /////////////// //////// set to "0" to disable the costs //////// vkc_Price = 5000; ///////////////////////////////////////////////// /////// Need KeyKit to use this function //////// ////////// 0 = Not needed | 1 = Needed ////////// vkc_needKeykit = 1; ///////////////////////////////////////////////// ///////////////////////////////////////////////// /////////////// DONT EDIT BELOW ! /////////////// ///////////////////////////////////////////////// /* Reset variables function */ ON_fnc_vkc_reset = { _cTarget = objNull; _itemsPlayer = []; _temp_keys = []; _carKey = objNull; _hasKey = false; _temp_keysDisplayName = []; _temp_keysDisplayNameParse = []; _temp_keysParse = []; _targetVehicleKey = objNull; _carKeyName = ""; player removeAction s_player_copyToKey; s_player_copyToKey = -1; }; //Added for Fix dayz_objectUID_vkc = { private["_position","_dir","_key","_object"]; _object = _this; _position = getPosATL _object; _dir = direction _object; _key = [_dir,_position] call dayz_objectUID2_vkc; _key }; dayz_objectUID2_vkc = { private["_position","_dir","_key"]; _dir = _this select 0; _key = ""; _position = _this select 1; { _x = _x * 10; if ( _x < 0 ) then { _x = _x * -10 }; _key = _key + str(round(_x)); } forEach _position; _key = _key + str(round(_dir)); _key }; /* Wait for player full ingame so we can access the action-menu */ waitUntil {!isNil "dayz_animalCheck"}; s_player_copyToKey=-1; lastKeyChangeCursorTarget = [objNull,objNull,objNull,objNull,objNull]; /* Start the loop check */ while{true} do { sleep 3; _playerDollars = player getVariable['cashMoney', 0]; if (!isNull cursorTarget && speed player <= 1 && (vehicle player) == player && !isEngineOn cursorTarget && (cursorTarget isKindOf "Motorcycle" || cursorTarget isKindOf "Car" || cursorTarget isKindOf "Air" || cursorTarget isKindOf "Ship" || cursorTarget isKindOf "Truck" || cursorTarget isKindOf "Tank") && (cursorTarget distance player) <= 10 && cursorTarget getVariable ["VKC_disabled", 0] == 0 && cursorTarget getVariable ["VKC_claiming_disabled",0] == 0) then { _cTarget = cursorTarget; _itemsPlayer = items player; _magazinesPlayer = magazines player; if ((lastKeyChangeCursorTarget select 0) != _cTarget) then { if (s_player_copyToKey >= 0) then { player removeAction s_player_copyToKey; s_player_copyToKey = -1; }; }; lastKeyChangeCursorTarget set [0,_cTarget]; _carKey = _cTarget getVariable ["CharacterID","0"]; if (("ItemKeyKit" in _itemsPlayer || vkc_needKeykit == 0) && ((_carKey == "0" && vkc_claiming == 1 && (vkc_claimingPrice == 0 || vkc_claimingPrice < _playerDollars)) || _carKey != "0") && (vkc_Price == 0 || vkc_Price < _playerDollars)) then { if (_carKey == "0") then { _temp_keys = []; _temp_keysDisplayName = []; _temp_keysDisplayNameParse = []; _key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]; { if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _key_colors) then { _ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _x >> "keyid"); _keyName = getText(configFile >> "CfgWeapons" >> _x >> "displayName"); _temp_keysDisplayName set [count _temp_keysDisplayName,_keyName]; _temp_keys set [count _temp_keys,str(_ownerKeyId)]; }; } forEach _itemsPlayer; if ((count _temp_keys) > 0) then { if (s_player_copyToKey < 0) then { lastKeyChangeCursorTarget set [0,_cTarget]; s_player_copyToKey = player addAction [("<t color=""#0000FF"">" + ("Claim Vehicle") + "</t>"),"custom\VehicleKeyChanger\VehicleKeyChanger.sqf",[_cTarget, _temp_keys, "0", _temp_keysDisplayName, "0", "0", vkc_Price, vkc_claimingPrice],-1,false,false,"",""]; }; } else { [] call ON_fnc_vkc_reset; }; } else { _temp_keys = []; _temp_keysDisplayName = []; _temp_keysDisplayNameParse = []; _temp_keysParse = []; _key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]; { if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _key_colors) then { _ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _x >> "keyid"); _keyName = getText(configFile >> "CfgWeapons" >> _x >> "displayName"); _temp_keysDisplayName set [count _temp_keysDisplayName,_keyName]; _temp_keysDisplayNameParse set [_ownerKeyId,_keyName]; _temp_keys set [count _temp_keys,str(_ownerKeyId)]; _temp_keysParse set [_ownerKeyId, _x]; }; } forEach _itemsPlayer; _hasKey = _carKey in _temp_keys; if (_hasKey && (count _temp_keys) > 1) then { _carKeyName = (_temp_keysDisplayNameParse select (parseNumber _carKey)); _targetVehicleKey = (_temp_keysParse select (parseNumber _carKey)); _temp_keys = _temp_keys - [_carKey]; _temp_keysDisplayName = _temp_keysDisplayName - [_carKeyName]; if (s_player_copyToKey < 0) then { lastKeyChangeCursorTarget set [0,_cTarget]; s_player_copyToKey = player addAction [("<t color=""#0000FF"">" + ("Change Vehicle Key") + "</t>"),"custom\VehicleKeyChanger\VehicleKeyChanger.sqf",[_cTarget, _temp_keys, _carKey, _temp_keysDisplayName, _carKeyName, _targetVehicleKey, vkc_Price, 0],-1,false,false,"",""]; }; } else { [] call ON_fnc_vkc_reset; }; }; } else { [] call ON_fnc_vkc_reset; }; } else { lastKeyChangeCursorTarget = [objNull,objNull,objNull,objNull,objNull]; [] call ON_fnc_vkc_reset; }; }; VehicleKeyChanger.sqf /***********************************/ /* Vehicle Key Changer v1.3 */ /* Written by OtterNas3 */ /* January, 11, 2014 */ /* Last update: 02/20/2014 */ /***********************************/ /* Setup the private variables */ private ["_magazinesPlayer","_max","_j","_actionArray","_targetVehicle","_targetVehicleID","_targetVehicleUID","_playerKeys","_playerKeysDisplayName","_targetVehicleKeyName","_itemKeyName","_targetVehicleClassname","_targetVehiclePos","_targetVehicleDir","_Price","_claimingPrice"]; /* Remove the Action Menu entry */ player removeAction s_player_copyToKey; s_player_copyToKey = 0; /* Get the array and setup the variables */ _actionArray = _this select 3; _targetVehicle = _actionArray select 0; _targetVehicleID = _targetVehicle getVariable ["ObjectID","0"]; _targetVehicleUID = _targetVehicle getVariable ["ObjectUID","0"]; /* Check if the Vehicle is in the Database, if false exit */ if (_targetVehicleID == "0" && _targetVehicleUID == "0") exitWith {s_player_copyToKey = -1;}; /* Setup more variables */ _playerKeys = _actionArray select 1; _playerKeysDisplayName = _actionArray select 3; _targetVehicleKeyName = _actionArray select 4; _itemKeyName = _actionArray select 5; _Price = _actionArray select 6; _claimingPrice = _actionArray select 7; _targetVehicleClassname = typeOf _targetVehicle; _targetVehiclePos = getPosATL _targetVehicle; _targetVehicleDir = getDir _targetVehicle; /* Setup the Key Names list to select from */ keyNameList = []; for "_i" from 0 to (count _playerKeysDisplayName) -1 do { keyNameList set [(count keyNameList), _playerKeysDisplayName select _i]; }; /* Setup the Key Numbers list to select from */ keyNumberList = []; for "_i" from 0 to (count _playerKeys) -1 do { keyNumberList set [(count keyNumberList), _playerKeys select _i]; }; /* Resetting menu variables*/ keyNameSelect = ""; exitscript = true; snext = false; /* Creating the menu */ copyMenu = { private ["_keyMenu","_keyArray"]; _keyMenu = [["",true], ["Change Vehicle to Key:", [-1], "", -5, [["expression", ""]], "1", "0"]]; for "_i" from (_this select 0) to (_this select 1) do { _keyArray = [format['%1', keyNameList select (_i)], [_i - (_this select 0) + 2], "", -5, [["expression", format ["keyNameSelect = keyNameList select %1; keyNumberSelect = keyNumberList select %1", _i]]], "1", "1"]; _keyMenu set [_i + 2, _keyArray]; }; _keyMenu set [(_this select 1) + 2, ["", [-1], "", -5, [["expression", ""]], "1", "0"]]; if (count keyNameList > (_this select 1)) then { _keyMenu set [(_this select 1) + 3, ["Next", [12], "", -5, [["expression", "snext = true;"]], "1", "1"]]; } else { _keyMenu set [(_this select 1) + 3, ["", [-1], "", -5, [["expression", ""]], "1", "0"]]; }; _keyMenu set [(_this select 1) + 4, ["Exit", [13], "", -5, [["expression", "keyNameSelect = 'exitscript';"]], "1", "1"]]; showCommandingMenu "#USER:_keyMenu"; }; /* Wait for the player to select a Key from the list */ _j = 0; _max = 10; if (_max > 9) then {_max = 10;}; while {keyNameSelect == ""} do { [_j, (_j + _max) min (count keyNameList)] call copyMenu; _j = _j + _max; waitUntil {keyNameSelect != "" || snext}; snext = false; }; /* Player selected a Key, lets make the Vehicle update call */ if (keyNameSelect != "exitscript") then { /* Check again for the needed TinBar or claiming price and remove em from the players inventory */ _magazinesPlayer = magazines player; _playerDollars = player getVariable['cashMoney', 0]; if (_Price > 0) then { if (_Price < _playerDollars) then { //[player, _Price, 1] call BIS_fnc_invRemove; player setVariable["cashMoney",_playerDollars - _Price, true]; systemChat (format["Keychange costs %1 Dollars, thanks for your Payment!", _Price]); } else { systemChat (format["Keychange costs %1 Dollars, you had it and tried to trick the system - Keychange for this Vehicle disabled!", Price]); _targetVehicle setVariable ["VKC_disabled", 1, true]; s_player_copyToKey = -1; breakOut "exit"; }; }; if (_claimingPrice > 0) then { if (_claimingPrice < _playerDollars) then { //[player, _claimingPrice, 1] call BIS_fnc_invRemove; player setVariable["cashMoney",_playerDollars - _claimingPrice, true]; systemChat (format["Claiming Vehicle costs %1 Dollars, thanks for your Payment!", _claimingPrice]); } else { systemChat (format["Claiming Vehicle costs %1 Dollars, you had it and tried to trick the system - Claiming for this Vehicle disabled!", Price]); _targetVehicle setVariable ["VKC_claiming_disabled", 1, true]; s_player_copyToKey = -1; breakOut "exit"; }; }; /* We got the Money lets do our Job */ /* Lock the vehicle */ _targetVehicle setVehicleLock "LOCKED"; /* The super duper OneForAllAnimation... */ player playActionNow "Medic"; /* Remove the Key from the Toolbelt of the player and put it in the Backpack - No Backpack and the Key gets lost */ if (_itemKeyName != "0") then { if (!isNull (unitBackpack player)) then { [player, _itemKeyName, 1] call BIS_fnc_invRemove; (unitBackpack (vehicle player)) addWeaponCargoGlobal [_itemKeyName, 1]; systemChat (format["%1 has been moved to your Backpack", _targetVehicleKeyName]); }; }; /* Giving unique UID for claimed vehicles */ if (_targetVehicleUID=="0") then { _targetVehicleUID = _targetVehicle call dayz_objectUID_vkc; _targetVehicle setVariable ["ObjectUID",_targetVehicleUID,true]; // It does probably nothing and it's not needed :) }; /* This calls the custom update function which we put it in server_updateObject.sqf */ PVDZE_veh_Update = [_targetVehicle, "vehiclekey", player, _targetVehicleClassname, keyNumberSelect, keyNameSelect, _targetVehicleID, _targetVehicleUID]; publicVariableServer "PVDZE_veh_Update"; /* Inform the player about the success and tell him to check the Key */ systemChat (format["Changed Vehicle Key to %1", keyNameSelect]); if (_targetVehicleKeyName != "0") then { systemChat (format["Please check Vehicle function with %1 before you throw away %2!", keyNameSelect, _targetVehicleKeyName]); }; }; /* Reset the action menu variable for a new run */ s_player_copyToKey = -1; /**************************************/ /* That's it, hope you enjoy this Mod */ /* */ /* Yours sincerly, */ /* Otter */ /**************************************/ This uses Souls Version so those money variables are set up for his not the 999 version,,, Can anyone confirm that this works with the newest version? Link to comment Share on other sites More sharing options...
inkko Posted February 25, 2015 Report Share Posted February 25, 2015 Posted a reply to the release for the script that is working for me with single currency 3.0 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