Jump to content
OtterNas3

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

Recommended Posts

I cant get this to work.

do I need anything more than 2 cars and the keys to get this working ?

init.sqf.........

call compile preprocessFileLineNumbers "compiles.sqf"; //Compile regular functions my compiles in root

 

compiles............ 

fnc_usec_selfActions = compile preprocessFileLineNumbers "custom\fn_selfActions.sqf";

 

fn_selfActions.sqf............. changed "custom\VehicleKeyChanger.sqf", this is where I put it.

//Vehicle Key Changer START

    if (speed player <= 1 && !isEngineOn _cursorTarget && (_typeOfCursorTarget == "Car" || _typeOfCursorTarget == "Air" || _typeOfCursorTarget == "Ship")) then {
        if (_ownerID != "0") then {
            _temp_keysDisplayName = [];
            {
                if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _key_colors) then {
                    _ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _x >> "keyid");
                    _keyName = getText(configFile >> "CfgWeapons" >> _x >> "displayName");
                    _tempPlayerKeysNames set [count _tempPlayerKeysNames,_keyName];
                };
            } forEach _itemsPlayer;
            if (_ownerID in _temp_keys && (count _temp_keys) > 1) then {
                _carKeyName = (_temp_keys_names select (parseNumber _ownerID));
                _tempPlayerKeys = _temp_keys - [_ownerID];
                _tempPlayerKeysNames = _tempPlayerKeysNames - [_carKeyName];
                if (s_player_copyToKey < 0) then {
                    s_player_copyToKey = player addAction [("<t color="#0000FF"">" + ("Change Vehicle Key") + "</t>"),"custom\VehicleKeyChanger.sqf",[_cursorTarget, _tempPlayerKeys, _ownerID, _tempPlayerKeysNames, _carKeyName],-1,false,false,"","];
                };
            } else {
                player removeAction s_player_copyToKey;
                s_player_copyToKey = -1;
            };
        } else {
            player removeAction s_player_copyToKey;
            s_player_copyToKey = -1;
        };
    } else {
        player removeAction s_player_copyToKey;
        s_player_copyToKey = -1;
    };
    // Vehicle Key Changer END

Share this post


Link to post
Share on other sites

Sorry i was out for lunch when i found the failure and it seems my mobile did not made the change complete to the post.

Looks like you copied before i made the change to the code for the fn_selfActions.sqf

 

 

change this line:

    if (speed player <= 1 && !isEngineOn _cursorTarget && (_typeOfCursorTarget == "Car" || _typeOfCursorTarget == "Air" || _typeOfCursorTarget == "Ship")) then {

to this:

    if (speed player <= 1 && !isEngineOn _cursorTarget && (_cursorTarget isKindOf "Car" || _cursorTarget isKindOf "Air" || _cursorTarget isKindOf == "Ship")) then {

And you just need the one Car you wanna change to a new Key. You need the Key to change it to and the Key it is actually on.

Both have to be in your Inventory (Toolbelt), not in your Backpack.

Share this post


Link to post
Share on other sites

I just installed this, however I added the key makers kit as a requirement.

 

here are my first 4 lines, the rest is the same.

//Vehicle Key changer script
	if("ItemKeyKit" in _itemsPlayer) then {
	      hasItemKeyKit = true;
        }
	if (speed player <= 1 && hasItemKeyKit && !isEngineOn _cursorTarget && (_cursorTarget isKindOf "Car" || _cursorTarget isKindOf "Air" || _cursorTarget isKindOf == "Ship")) then {

edit for typo

Edited by NAIL

Share this post


Link to post
Share on other sites

Good idea with the Keykit, never thought about it :P

 

You could do this with a oneliner also:

_hasKeyKit = "ItemKeyKit" in _itemsPlayer;
if (speed player <= 1 && _hasKeyKit && !isEngineOn _cursorTarget && (_cursorTarget isKindOf "Car" || _cursorTarget isKindOf "Air" || _cursorTarget isKindOf == "Ship")) then {

updated my first post with it, thanks for the idea!

Share this post


Link to post
Share on other sites

Good idea with the Keykit, never thought about it :P

 

You could do this with a oneliner also:

_hasKeyKit = "ItemKeyKit" in _itemsPlayer;
if (speed player <= 1 && _hasKeyKit && !isEngineOn _cursorTarget && (_cursorTarget isKindOf "Car" || _cursorTarget isKindOf "Air" || _cursorTarget isKindOf == "Ship")) then {

updated my first post with it, thanks for the idea!

 

 

Your welcome, and thanks for your code, I have been wanting this for a while myself.  I'm just starting coding in Arma so I don't take on large project yet, but I am learning every day and I can usually adapt things to suit my needs.

 

You may want to add the criteria of having the kit to your first post aswell. people will install it and it won't work because they don't have the kit.  Then instead of reading down to the 5th post, they will spam this topic with "it doesn't work".

Share this post


Link to post
Share on other sites
 
10:30:56 Error in expression <sKindOf "Air" || _cursorTarget isKindOf == "Ship")) then {
if (_ownerID != "0") >
10:30:56   Error position: <== "Ship")) then {
if (_ownerID != "0") >
10:30:56   Error Invalid number in expression
10:30:56 File mpmissions\__cur_mp.panthera2\scripts\fn_selfActions.sqf, line 226
10:30:56 Error in expression <sKindOf "Air" || _cursorTarget isKindOf == "Ship")) then {
if (_ownerID != "0") >
10:30:56   Error position: <== "Ship")) then {
if (_ownerID != "0") >
10:30:56   Error Invalid number in expression
10:30:56 File mpmissions\__cur_mp.panthera2\scripts\fn_selfActions.sqf, line 226
10:30:57 Error in expression <17578e-005];
 
(_cursorTarget isKindOf "Car" || _cursorTarget isKindOf "Air" || _cursorTarget isKindOf == "Ship")

note the ==   its only in the last statement.

 

 

Share this post


Link to post
Share on other sites

its working up till selecting the key for me.  take out the == in the line i mention above your post to get where I am.

 

after select

 

Change Vehicle Key

 

I get

 

Change Vehicle to Key:

 

= Exit

 

no option to select the key.

Share this post


Link to post
Share on other sites

Your welcome, and thanks for your code, I have been wanting this for a while myself.  I'm just starting coding in Arma so I don't take on large project yet, but I am learning every day and I can usually adapt things to suit my needs.

 

You may want to add the criteria of having the kit to your first post aswell. people will install it and it won't work because they don't have the kit.  Then instead of reading down to the 5th post, they will spam this topic with "it doesn't work".

 

Already put it in my first post :)

 

 

 

 
10:30:56 Error in expression <sKindOf "Air" || _cursorTarget isKindOf == "Ship")) then {
if (_ownerID != "0") >
10:30:56   Error position: <== "Ship")) then {
if (_ownerID != "0") >
10:30:56   Error Invalid number in expression
10:30:56 File mpmissions\__cur_mp.panthera2\scripts\fn_selfActions.sqf, line 226
10:30:56 Error in expression <sKindOf "Air" || _cursorTarget isKindOf == "Ship")) then {
if (_ownerID != "0") >
10:30:56   Error position: <== "Ship")) then {
if (_ownerID != "0") >
10:30:56   Error Invalid number in expression
10:30:56 File mpmissions\__cur_mp.panthera2\scripts\fn_selfActions.sqf, line 226
10:30:57 Error in expression <17578e-005];
 
(_cursorTarget isKindOf "Car" || _cursorTarget isKindOf "Air" || _cursorTarget isKindOf == "Ship")

note the ==   its only in the last statement.

 

 

 

Yeah i really hate those typos, changed it, thanks for the hint!

 

 

its working up till selecting the key for me.  take out the == in the line i mention above your post to get where I am.

 

after select

 

Change Vehicle Key

 

I get

 

Change Vehicle to Key:

 

= Exit

 

no option to select the key.

 

Did you had 2 Keys in your inventory?

The key for the vehicle you wanna change and a Key to move it to?

 

I think i should post it with my script for checking if addAction is needed, i doesnt like this fn_selfActions.sqf for it anyway.

i just had to convert it from my caller to the fn_selfActions.sqf thought would be better, bad idea...

 

 

Gimme 10 minutes and i update my first Post with a package with my caller in it, which definately works...

Share this post


Link to post
Share on other sites

Did you had 2 Keys in your inventory?

The key for the vehicle you wanna change and a Key to move it to?

 

I think i should post it with my script for checking if addAction is needed, i doesnt like this fn_selfActions.sqf for it anyway.

i just had to convert it from my caller to the fn_selfActions.sqf thought would be better, bad idea...

 

 

Gimme 10 minutes and i update my first Post with a package with my caller in it, which definately works...

 

 

Yes, I went to my +debug island+ spawned in 2 muzzies and had only their keys in my gear.  Got no option without the keymakers kit.  Added keymakers kit and got the option.  but no key menu.  

 

It may have to do with the infistar AH. one of my clanmates was kicked for attempting it, have to whitelist the add menu action.  I will check it again when i restart server next.  

 

I do rather like having it in fn_selfActions.sqf better, gives me personally more control, and I am pretty sure the problem I have has nothing to do with that, its either the AH or the VehicleKeyChanger.sqf file (probably the AH)

Share this post


Link to post
Share on other sites

left the fn_selfActions.sqf out in the instructions ??

No need for the fn_selfActions.sqf anymore its called in the init.sqf

 

 

Why are you calling this file from init.sqf

 

    _nil = [] execVM "custom\vehiclefunctions.sqf";

 
When the zip includes VehicleKeyChanger\VehicleKeyChanger.sqf

 

This is the init line for it, it starts a checker, which checks every 3 seconds for a valid Target, instead all 0.2 seconds like fn_selfActions.sqf does

No need to check it that often, in my opinion

 

So just insert this line in your init.sqf on the mentioned position and youre good to go

You can remove the code from your custom fn_selfActions.sqf

If you did not mady any other change to the fn_selfActions.sqf or compiles.sqf, for another mod, you can change the compiles.sqf call in your init.sqf back to standard

call compile preprocessFileLineNumbers "dayz_code\init\compiles.sqf";

to

call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf";

 

:huh:  verry confused 

do I still keep the fn_selfactions that used to be in the instructions or  start fresh and only add to init.sqf ?

Start fresh and just add this line to your init.sqf

 

 

Yes, I went to my +debug island+ spawned in 2 muzzies and had only their keys in my gear.  Got no option without the keymakers kit.  Added keymakers kit and got the option.  but no key menu.  

 

It may have to do with the infistar AH. one of my clanmates was kicked for attempting it, have to whitelist the add menu action.  I will check it again when i restart server next.  

 

I do rather like having it in fn_selfActions.sqf better, gives me personally more control, and I am pretty sure the problem I have has nothing to do with that, its either the AH or the VehicleKeyChanger.sqf file (probably the AH)

I hope this +debug island+ is not really in the debug zone ^^ i had problems with saving Vehicles there and get variables from vehicles

But cuase your clanmate got kicked im sure it has something todo with whitelist the action.

Share this post


Link to post
Share on other sites

Shouldn't this _nil = [] execVM "custom\vehiclefunctions.sqf"; be this instead _nil = [] execVM "custom\VehicleKeyChanger.sqf"; ? :huh:

Nope, the custom\vehiclefunctions.sqf is the looper for checking for valid vehicles and if it founds one with all conditions meet it gives you the action menu entry WHICH calls the custom\VehicleKeyChanger\VehicleKeyChanger.sqf

Share this post


Link to post
Share on other sites

Nope, the custom\vehiclefunctions.sqf is the looper for checking for valid vehicles and if it founds one with all conditions meet it gives you the action menu entry WHICH calls the custom\VehicleKeyChanger\VehicleKeyChanger.sqf

But I don't have a file in my custom folder called vehiclefunctions.sqf so how can it call it or is the vehiclefunctions.sqf file not needed in the custom folder ? Surely it's needed if it's being called in the init.sqf ?

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...

  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...