Jump to content

[RELEASE] Vehicle Key Changer - For making Masterkey - V 1.4 (Updated 06/15/2014)


OtterNas3

Recommended Posts

With private ["_playerPOS","_nearSP"]; it doesn't work at all, without it, it the script still works anywhere. I've changed the object I want the player to be in proximity to as well, it's now

// Increase distance only if AIR || SHIP_playerPos = getPosATL player;_nearSP = count nearestObjects [_playerPos, ["Map_Heli_H_cross],15] > 0;_allowedDistance = 4;_isAir = cursorTarget isKindOf "Air";_isShip = cursorTarget isKindOf "Ship";if(_isAir || _isShip) then {	_allowedDistance = 8;};/* Start the loop check */while{true} do {	if (!isNull cursorTarget && (cursorTarget isKindOf "AllVehicles") && (player distance cursorTarget < _allowedDistance) && (!isEngineOn cursorTarget) && (_nearSP)) then {
Link to comment
Share on other sites

[RELEASE] Vehicle Key Changer - For making Masterkey - V 1.5.4 (Updated 26/10/2014)

Changes: Debugging (heli distance menu appears) I'm sorry. Was my fault.

Have Fun!

Best regards

hellraver

Hint: This is a unofficial version and is not from Otternas3!!!

How to install this?

I added the folder + server_updateObject to the right places, but it doesn't work?

 

EDIT: Nvm, just follow the original install  :lol:

Link to comment
Share on other sites

Other question

 

How could i make it so that only some vehicles can be claimed.

Something like

 _claimveh=["SUV_Blue", "SUV_Camo", "SUV_Charcoal", "SUV_DZ", "SUV_Green", "SUV_Orange", "SUV_Pink"];

And then in the claim part

if (!isNull cursorTarget && /*(cursorTarget isKindOf "AllVehicles") not needed i guess???*/ && (player distance cursorTarget <= 10) && (!isEngineOn cursorTarget) && (cursorTarget in _claimveh)) then {

Something like this?

Link to comment
Share on other sites

Other question

 

How could i make it so that only some vehicles can be claimed.

Something like

 _claimveh=["SUV_Blue", "SUV_Camo", "SUV_Charcoal", "SUV_DZ", "SUV_Green", "SUV_Orange", "SUV_Pink"];

And then in the claim part

if (!isNull cursorTarget && /*(cursorTarget isKindOf "AllVehicles") not needed i guess???*/ && (player distance cursorTarget <= 10) && (!isEngineOn cursorTarget) && (cursorTarget in _claimveh)) then {

Something like this?

 

I thing that the following should work but I have not tested it myself:

 

private ["_claimveh", "_typeveh"];  // this can be a seaprate listing of these private variables, or the variables can be added to the main listing at the top of the script.

_claimveh=["SUV_Blue", "SUV_Camo", "SUV_Charcoal", "SUV_DZ", "SUV_Green", "SUV_Orange", "SUV_Pink"]; // array of vehicles that can be claimed

_typeveh = typeOf cursorTarget;  // get the class name for the vehicle.

 

if (!isNull cursorTarget && (player distance cursorTarget <= 10) && (!isEngineOn cursorTarget) && (_typeveh in _claimveh)) then {

 

I included the code to define _typeveh, but you can also omit it and just have the if statement as follows

 

if (!isNull cursorTarget && (player distance cursorTarget <= 10) && (!isEngineOn cursorTarget) && (typeOf cursorTarget in _claimveh)) then {

 

You might consider defining the list of vehicles that can be claimed using a global variable that is defined in the init file for the script to consolidate the settings, but that is a secondary point.

 

Hope this is helpful,

 

Ghost

Link to comment
Share on other sites

I've tried a few different ways to make it so this can only be used at certain locations, specifically within 10m of "Map_Heli_H_cross" which is my service point object. This is so the key changer will act like part of the service point, and players have to travel to a certain location to claim vehicles and change keys. Is that something you can help me accomplish?

Link to comment
Share on other sites

I've tried a few different ways to make it so this can only be used at certain locations, specifically within 10m of "Map_Heli_H_cross" which is my service point object. This is so the key changer will act like part of the service point, and players have to travel to a certain location to claim vehicles and change keys. Is that something you can help me accomplish?

 

You can test whether an object like "Map_Heli_H_Cross" is near the player (or any other object really) with nearestObjects (object, ["array of items to look for nearby"], distanceToSearch];.

 

You could try something like this:

if (!isNull cursorTarget && (player distance cursorTarget <= 10) && (!isEngineOn cursorTarget) && (nearestObjects [player, "Map_Heli_H_Cross", 10] > 0)) then {

 

Hope this is helpful.

Link to comment
Share on other sites

I've tried a few different ways to make it so this can only be used at certain locations, specifically within 10m of "Map_Heli_H_cross" which is my service point object. This is so the key changer will act like part of the service point, and players have to travel to a certain location to claim vehicles and change keys. Is that something you can help me accomplish?

Why do not read my Question? I do not get it ^^

Link to comment
Share on other sites

Other question

 

How could i make it so that only some vehicles can be claimed.

Something like

 _claimveh=["SUV_Blue", "SUV_Camo", "SUV_Charcoal", "SUV_DZ", "SUV_Green", "SUV_Orange", "SUV_Pink"];
And then in the claim part

if (!isNull cursorTarget && /*(cursorTarget isKindOf "AllVehicles") not needed i guess???*/ && (player distance cursorTarget <= 10) && (!isEngineOn cursorTarget) && (cursorTarget in _claimveh)) then {
Something like this?

Use this Code:

 

vkc_AllowedClaimVehicle = [
	"SUV_Blue", "SUV_Camo", "SUV_Charcoal", "SUV_DZ", "SUV_Green", "SUV_Orange", "SUV_Pink"
];

if (!isNull cursorTarget && (typeOf cursorTarget) in vkc_AllowedClaimVehicle && (player distance cursorTarget <= 10) && (!isEngineOn cursorTarget)) then {
Link to comment
Share on other sites

You can test whether an object like "Map_Heli_H_Cross" is near the player (or any other object really) with nearestObjects (object, ["array of items to look for nearby"], distanceToSearch];.

 

You could try something like this:

if (!isNull cursorTarget && (player distance cursorTarget <= 10) && (!isEngineOn cursorTarget) && (nearestObjects [player, "Map_Heli_H_Cross", 10] > 0)) then {

 

Hope this is helpful.

This didn't work, No option to claim anywhere, with the line you gave me removed it works though.

/***********************************/ 	
/* Vehicle Key Changer v1.5.4      */
/* Written by OtterNas3            */
/* January, 11, 2014               */
/* Last update: 26/10/2014         */
/* Advanced by hellraver           */
/***********************************/


/////////////////////////////////////////////////
/////////////////////////////////////////////////
// Edit these settings to fit your needs/likes //
/////////////////////////////////////////////////
/////////////////////////////////////////////////
///// Claim Vehicles that do not have a Key /////
///////// 0 = Not allowed | 1 = Allowed /////////
vkc_claimKey = 1;
/////////////////////////////////////////////////
/////// Change Key to create a Masterkey ////////
///////// 0 = Not allowed | 1 = Allowed /////////
vkc_changeKey = 1;
/////////////////////////////////////////////////
//////// Set to "0" to disable the costs ////////
vkc_claimKeyPrice = "ItemGoldBar10oz";
/////////////////////////////////////////////////
//////// Set to "0" to disable the costs ////////
vkc_changeKeyPrice = "ItemGoldBar10oz";
/////////////////////////////////////////////////
////// Need KeyKit to use Claim Vehicle Key /////
////////// 0 = Not needed | 1 = Needed //////////
vkc_claimNeedKeykit = 1;
/////////////////////////////////////////////////
///// Need KeyKit to use Change Vehicle Key /////
////////// 0 = Not needed | 1 = Needed //////////
vkc_changeNeedKeykit = 1;
/////////////////////////////////////////////////
// Change Key & Claim Vehicles costs this Item //
/// Any Item can be used here, some examples: ///
//// ItemTinBar, ItemSilverBar, ItemGoldBar, ////
////// ItemSilverBar10oz, ItemGoldBar10oz, //////
///// ItemBriefcase20oz, ItemBriefcase100oz /////
/////////////////////////////////////////////////
/////////////////////////////////////////////////
/////////////// DONT EDIT BELOW ! ///////////////
/////////////////////////////////////////////////

/* Wait for player full ingame so we can access the action-menu */
waitUntil {!isNil "dayz_animalCheck"};

/* Start the loop check */
while{true} do {
	if (!isNull cursorTarget && (cursorTarget isKindOf "AllVehicles") && (player distance cursorTarget <= 10) && (!isEngineOn cursorTarget) && (nearestObjects [player, "Map_Heli_H_Cross", 10] > 0)) then {
		vkc_cursorTarget = cursorTarget;
		vkc_ownerID = vkc_cursorTarget getVariable ["CharacterID","0"];

		if (vkc_claimKey == 1 && vkc_ownerID == "0" && vkc_cursorTarget getVariable ["VKC_claiming_disabled", 0] == 0) then {
			vkc_magazinesPlayer = magazines player;
			vkc_itemsPlayer = items player;
		
			if (("ItemKeyKit" in vkc_itemsPlayer || vkc_claimNeedKeykit == 0) && (vkc_claimKeyPrice == "0" || vkc_claimKeyPrice in vkc_magazinesPlayer)) then {
				vkc_objectID = vkc_cursorTarget getVariable ["ObjectID","0"];
				vkc_objectUID = vkc_cursorTarget getVariable ["ObjectUID","0"];

				if (!(vkc_objectID == "0" && vkc_objectUID == "0")) then {

					if (s_player_claimKey < 0) then {
						s_player_claimKey = player addAction [("<t color='#00FFFF'>" + ("Claim Vehicle Key") + "</t>"),"custom\VehicleKeyChanger\VehicleKeyChanger.sqf",[vkc_cursorTarget, vkc_temp_keys, vkc_ownerID, vkc_temp_keysDisplayName, "0", "0", "0", vkc_claimKeyPrice],-1002,false,false,"",""];
					};

				} else {

					player removeAction s_player_claimKey;
					s_player_claimKey = -1;
				};

			} else {

				player removeAction s_player_claimKey;
				s_player_claimKey = -1;
			};

		} else {

			player removeAction s_player_claimKey;
			s_player_claimKey = -1;
		};

		if (vkc_changeKey == 1 && vkc_ownerID != "0" && vkc_cursorTarget getVariable ["VKC_disabled",0] == 0) then {
			vkc_magazinesPlayer = magazines player;
			vkc_itemsPlayer = items player;

			if (("ItemKeyKit" in vkc_itemsPlayer || vkc_changeNeedKeykit == 0) && (vkc_changeKeyPrice == "0" || vkc_changeKeyPrice in vkc_magazinesPlayer)) then {
				vkc_objectID = vkc_cursorTarget getVariable ["ObjectID","0"];
				vkc_objectUID = vkc_cursorTarget getVariable ["ObjectUID","0"];

				if (!(vkc_objectID == "0" && vkc_objectUID == "0")) then {
		
					vkc_key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
					vkc_temp_keys = [];
					vkc_temp_keysDisplayName = [];
					vkc_temp_keysDisplayNameParse = [];
					vkc_temp_keysParse = [];

					{

						if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in vkc_key_colors) then {
							vkc_ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _x >> "keyid");
							vkc_keyName = getText(configFile >> "CfgWeapons" >> _x >> "displayName");
							vkc_temp_keysDisplayName set [count vkc_temp_keysDisplayName,vkc_keyName];
							vkc_temp_keysDisplayNameParse set [vkc_ownerKeyId,vkc_keyName];
							vkc_temp_keys set [count vkc_temp_keys,str(vkc_ownerKeyId)];
							vkc_temp_keysParse set [vkc_ownerKeyId, _x];
						};
					} forEach vkc_itemsPlayer;

					vkc_hasKey = vkc_ownerID in vkc_temp_keys;

					if (vkc_hasKey && (count vkc_temp_keys) > 1) then {
						vkc_carKeyName = (vkc_temp_keysDisplayNameParse select (parseNumber vkc_ownerID));
						vkc_targetVehicleKey = (vkc_temp_keysParse select (parseNumber vkc_ownerID));
						vkc_temp_keys = vkc_temp_keys - [vkc_ownerID];
						vkc_temp_keysDisplayName = vkc_temp_keysDisplayName - [vkc_carKeyName];

						if (s_player_changeKey < 0) then {
							s_player_changeKey = player addAction [("<t color=""#0000FF"">" + ("Change Vehicle Key") + "</t>"),"custom\VehicleKeyChanger\VehicleKeyChanger.sqf",[vkc_cursorTarget, vkc_temp_keys, vkc_ownerID, vkc_temp_keysDisplayName, vkc_carKeyName, vkc_targetVehicleKey, vkc_changeKeyPrice, "0"],-1002,false,false,"",""];
						};

					} else {
				
						player removeAction s_player_changeKey;
						s_player_changeKey = -1;
					};

				} else {
				
					player removeAction s_player_changeKey;
					s_player_changeKey = -1;
				};

			} else {
			
				player removeAction s_player_changeKey;
				s_player_changeKey = -1;
			};

		} else {
				
			player removeAction s_player_changeKey;
			s_player_changeKey = -1;
		};

	} else {

		player removeAction s_player_claimKey;
		s_player_claimKey = -1;
		player removeAction s_player_changeKey;
		s_player_changeKey = -1;
	};

};

Hellraver i'm not sure what you mean, i know you don't speak english natively so we must be losing something in translation

Link to comment
Share on other sites

Tried at the beginning and end of that line just for giggles and same situation. Maybe I can't use the MAP_Heli_H_Cross Class? It's a pain to work with in the editor anyways but I know it's not used anywhere else on the map. Also no errors in the local or server RPT files that point toward this script, just one from my bury/eat body script.

Link to comment
Share on other sites

  • 2 weeks later...

So looked through the thread didnt see this but is there a way to add the master key to loadout. This is my current loadout.sqf

 

//Default Loadout
DefaultMagazines = ["ItemMorphine","ItemBandage","ItemBandage","HandChemRed","ItemHeatPack","ItemPainkiller","ItemWaterbottleBoiled","FoodCanSardines","64Rnd_9x19_SD_Bizon","64Rnd_9x19_SD_Bizon","64Rnd_9x19_SD_Bizon"];
DefaultWeapons = ["ItemMap","Binocular","ItemCompass","ItemToolbox","ItemHatchet","bizon_silenced"];
DefaultBackpack = "DZ_Patrol_Pack_EP1";
DefaultBackpackWeapon = "ItemMorphine","ItemMorphine";

//Admin Loadout
if ((getPlayerUID player) in ["000000000000"]) then {  //Admins high
DefaultMagazines = ["ItemMorphine","ItemBandage","ItemBandage","ItemHeatPack","ItemPainkiller","ItemWaterbottleBoiled","FoodCanSardines","64Rnd_9x19_SD_Bizon","64Rnd_9x19_SD_Bizon","64Rnd_9x19_SD_Bizon"];
DefaultWeapons = ["ItemMap","Binocular","ItemKeyBlue592","ItemCompass","ItemToolbox","ItemHatchet","bizon_silenced"];
DefaultBackpack = "DZ_Patrol_Pack_EP1";
DefaultBackpackWeapon = "ItemMorphine","ItemMorphine";


//Admin Loadout
if ((getPlayerUID player) in ["0000000000"]) then {  //Admins low
    DefaultMagazines = ["ItemBandage","ItemBandage","ItemMorphine","ItemPainkiller","FoodSteakCooked","15Rnd_9x19_M9","15Rnd_9x19_M9","15Rnd_9x19_M9"];
    DefaultWeapons = ["ItemMap","ItemCompass","M9"];
    DefaultBackpack = "DZ_Patrol_Pack_EP1";
    DefaultBackpackWeapon = "";
    };

Link to comment
Share on other sites

In the next update i will integrate the nearest Object function ^^ Ok?

First thank you and Nas for this awesome script. Have it on my test server and so far it's working great. 

 

One suggestion that might make this a little easier is some dialog telling users they must have both keys and a keymakers kit and the required gold/silver in their inventory in order to claim/change the key. I'm unsure where to put that dialog in the script.  I assuming it's in the loop check. 

Link to comment
Share on other sites

It seems like nothing is being defined on a fresh install... Other people in the thread have had this problem but no one is giving a solution... How exactly do I fix these errors? EDIT: I also got these errors with OP's files and I did it again with hellravers and it still won't work...

if (vkc_claimKey == 1 && vkc_ownerID == "0" && vkc_cursorTarget g>
  Error position: <vkc_ownerID == "0" && vkc_cursorTarget g>
  Error Undefined variable in expression: vkc_ownerid
File mpmissions\__CUR_MP.Napf\custom\VehicleKeyChanger\VehicleKeyChanger_init.sqf, line 56
Error in expression <= -1;
};

} else {

player removeAction s_player_claimKey;
s_player_claimKey = ->
  Error position: <s_player_claimKey;
s_player_claimKey = ->
  Error Undefined variable in expression: s_player_claimkey
File mpmissions\__CUR_MP.Napf\custom\VehicleKeyChanger\VehicleKeyChanger_init.sqf, line 154
Link to comment
Share on other sites

This is such a great script! I installed it on my server just over a week ago (I think) and have had so many positive comments about it. Managing multiple keys was a real pain sometimes, and this has completely removed it. 

 

Also, being able to claim spawned vehicles is a really great feature, which again, has had lots of really great feedback.

 

Thanks for making our gaming lives a lot easier OtterNas. Really appreciate your great work, and thank you for sharing this with us all.

Link to comment
Share on other sites

 

It seems like nothing is being defined on a fresh install... Other people in the thread have had this problem but no one is giving a solution... How exactly do I fix these errors? EDIT: I also got these errors with OP's files and I did it again with hellravers and it still won't work...

if (vkc_claimKey == 1 && vkc_ownerID == "0" && vkc_cursorTarget g>
  Error position: <vkc_ownerID == "0" && vkc_cursorTarget g>
  Error Undefined variable in expression: vkc_ownerid
File mpmissions\__CUR_MP.Napf\custom\VehicleKeyChanger\VehicleKeyChanger_init.sqf, line 56
Error in expression <= -1;
};

} else {

player removeAction s_player_claimKey;
s_player_claimKey = ->
  Error position: <s_player_claimKey;
s_player_claimKey = ->
  Error Undefined variable in expression: s_player_claimkey
File mpmissions\__CUR_MP.Napf\custom\VehicleKeyChanger\VehicleKeyChanger_init.sqf, line 154

 

http://epochmod.com/forum/index.php?/topic/20979-s-player-settings-variable-in-several-scripts-and-generating-rpt-errrors-how-to-fix/?hl=charid#entry167595

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×
×
  • Create New...