Jump to content

[Release] Vehicle Pointer v0.1 (for use w/, w/o Masterkey Script)


jahangir13

Recommended Posts

private ["_control","_button","_parent","_group","_pos","_item","_conf","_name","_cfgActions","_numActions","_height","_menu","_config","_type","_script","_outputOriented","_compile","_array","_outputClass","_outputType"];
disableSerialization;
_control = 	_this select 0;
_button =	_this select 1;
_parent = 	findDisplay 106;

//if ((time - dayzClickTime) < 1) exitWith {};
if (!DZE_SelfTransfuse && ((gearSlotData _control) == "ItemBloodBag")) exitWith {};
if (_button == 1) then {
	//dayzClickTime = time;
	_group = _parent displayCtrl 6902;
	
	_pos = 		ctrlPosition _group;
	_pos set [0,((_this select 2) + 0.48)];
	_pos set [1,((_this select 3) + 0.07)];
	
	_item = gearSlotData _control;
	
	_conf = configFile >> "cfgMagazines" >> _item;
	if (!isClass _conf) then {
		_conf = configFile >> "cfgWeapons" >> _item;
	};
	_name = getText(_conf >> "displayName");
	
	_cfgActions = _conf >> "ItemActions";
	_numActions = (count _cfgActions);
	_height = 0;
	
	//Populate Menu
	for "_i" from 0 to (_numActions - 1) do 
	{
		_menu = 	_parent displayCtrl (1600 + _i);
		_menu ctrlShow true;
		_config = 	(_cfgActions select _i);
		_type = 	getText	(_config >> "text");
		_script = 	getText	(_config >> "script");
		_outputOriented = 	getNumber	(_config >> "outputOriented") == 1;
		_height = _height + (0.025 * safezoneH);
		_compile =  format["_id = '%2' %1;",_script,_item];
		uiNamespace setVariable ['uiControl', _control];
		if (_outputOriented) then {
			/*
				This flag means that the action is output oriented
				the output class will then be transferred to the script
				&& the type used for the name
			*/			
			_array = 	getArray	(_config >> "output");
			_outputClass = _array select 0;
			_outputType = _array select 1;
			_name = getText (configFile >> _outputType >> _outputClass >> "displayName");
			_compile =  format["_id = ['%2',%3] %1;",_script,_item,_array];
		};
		
		_menu ctrlSetText format[_type,_name];
		_menu ctrlSetEventHandler ["ButtonClick",_compile];
	};
	
///// jahan - begin vehicle pointer
        // key colors
        _colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
		if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _item)) in _colors) then {
            // characterID of the key (car character number)
			_keyOwner = getNumber(configFile >> "CfgWeapons" >> _item >> "keyid");
            // key name (like: e3f2)
            _keyName = getText(configFile >> "CfgWeapons" >> _item >> "displayName");

            //Menu entry Key vehicle pointer
            _control =  _parent displayCtrl (1600 + _numActions);
            _control ctrlShow true;
            _height = _height + (0.025 * safezoneH);
            // this needs to point the place where the script is in your mission (vehicle_pointer.sqf)
            _script =  "custom\VehiclePointer\vehicle_pointer.sqf";
            _exescript = format["_id = ['%2','%3'] execVM '%1';closeDialog 0;",_script,_keyOwner,_keyName];
            uiNamespace setVariable ['uiControl', _control];
            // sets the text in the right button menu
            _control ctrlSetText "Vehicle Pointer";
            _control ctrlSetTextColor [0.3,0.4,1,1];
            _control ctrlSetTooltip "Pinpoint vehicle. Mark on map if not in range.";
            _control ctrlSetTooltipColorBox [0.3,0.4,1,1];
            _control ctrlSetTooltipColorShade [0, 0, 0, 1];
            _control ctrlSetTooltipColorText [0.3,0.4,1,1];
            _control ctrlSetEventHandler ["ButtonClick",_exescript];
            _numActions = _numActions + 1; // if there are other item action after that (other mods) add 1 to _numactions
		};
///// jahan - end vehicle pointer
		
        // Add extra context menus
        _erc_cfgActions = (missionConfigFile >> "ExtraRc" >> _item);
        _erc_numActions = (count _erc_cfgActions);
        if (isClass _erc_cfgActions) then {
                for "_j" from 0 to (_erc_numActions - 1) do {
                        _menu =  _parent displayCtrl (1600 + _j + _numActions);
                        _menu ctrlShow true;
                        _config =  (_erc_cfgActions select _j);
                        _text =  getText (_config >> "text");
                        _script =  getText (_config >> "script");
                        _height = _height + (0.025 * safezoneH);
                        uiNamespace setVariable ['uiControl', _control];
                        _menu ctrlSetText _text;
                        _menu ctrlSetEventHandler ["ButtonClick",_script];
                };
        };
	_pos set [3,_height];
	//hint format["Obj: %1 \nHeight: %2\nPos: %3",_item,_height,_grpPos];		

	_group ctrlShow true;
	ctrlSetFocus _group;
	_group ctrlSetPosition _pos;
	_group ctrlCommit 0;
};

I cant figure out why im not getting the option on any keys any ideas?

Link to comment
Share on other sites

No. It's just a try. I had some issues to find the right way but I also use this remote vehicle door opener.

I tried to enter my stuff after the remote vehicle opener stuff and my option wasn't shown. Then I recognized that something like this was missing:

_numActions = _numActions + 1; // if there are other item action after that (other mods) add 1 to _numactions

 

...so that the next menu option counts on top of it. In the end I've ended with what I've told you...I put my part below the rc extra stuff method by Maca and before _pos set [3,_height];

 

So I cannot guarantee a way which works for everyone (if not used in the vanilla Epoch version)...as everybody has whatever changes in ui_selectSlot.sqf.

 

This is my file...you can use it to compare. But already the beginning is different to yours as I use Macas old way for the selfBloodBag and not the new Epoch way for self-transfuse.

So you cannot take this 1 to 1. Start with comparison from: //Populate Menu

 

private ["_control","_button","_parent","_group","_pos","_item","_conf","_name","_cfgActions","_numActions","_height","_menu","_config","_type","_script","_outputOriented","_compile","_array","_outputClass","_outputType","_key_colors","_ownerKeyId","_itemsPlayer","_hasKey","_objects","_ownerID","_i"];
disableSerialization;
_control =     _this select 0;
_button =    _this select 1;
_parent =     findDisplay 106;

//if ((time - dayzClickTime) < 1) exitWith {};
// jahan - self transfusion mit check variable ausschalten
/////if (!DZE_SelfTransfuse && ((gearSlotData _control) == "ItemBloodBag")) exitWith {};

if (_button == 1) then {
    //dayzClickTime = time;
    _group = _parent displayCtrl 6902;
    
    _pos =         ctrlPosition _group;
    _pos set [0,((_this select 2) + 0.48)];
    _pos set [1,((_this select 3) + 0.07)];
    
    _item = gearSlotData _control;
    
    _conf = configFile >> "cfgMagazines" >> _item;
    if (!isClass _conf) then {
        _conf = configFile >> "cfgWeapons" >> _item;
    };
    _name = getText(_conf >> "displayName");
    _cfgActions = _conf >> "ItemActions";
    ///// jahan - if selfbloodpack, sonst geht das menu nicht
    if !((gearSlotData _control) == "ItemBloodBag") then {
    _numActions = (count _cfgActions);
    } else {
    _numActions = 0;
    };
    _height = 0;
    
    ///// jahan - selfbloodpack
    if !((gearSlotData _control) == "ItemBloodBag") then {
    //Populate Menu
    for "_i" from 0 to (_numActions - 1) do
    {
        _menu =     _parent displayCtrl (1600 + _i);
        _menu ctrlShow true;
        _config =     (_cfgActions select _i);
        _type =     getText    (_config >> "text");
        _script =     getText    (_config >> "script");
        _outputOriented =     getNumber    (_config >> "outputOriented") == 1;
        _height = _height + (0.025 * safezoneH);
        _compile =  format["_id = '%2' %1;",_script,_item];
        uiNamespace setVariable ['uiControl', _control];
        if (_outputOriented) then {
            /*
                This flag means that the action is output oriented
                the output class will then be transferred to the script
                && the type used for the name
            */            
            _array =     getArray    (_config >> "output");
            _outputClass = _array select 0;
            _outputType = _array select 1;
            _name = getText (configFile >> _outputType >> _outputClass >> "displayName");
            _compile =  format["_id = ['%2',%3] %1;",_script,_item,_array];
        };
        
        _menu ctrlSetText format[_type,_name];
        _menu ctrlSetEventHandler ["ButtonClick",_compile];
    };
   };
    
    ///// jahan self boodpack und evac chopper
    ////////// jahan: Add extra context menus (for SelfBloodbag and Radio Communication
_erc_cfgActions = (missionConfigFile >> "ExtraRc" >> _item);
_erc_numActions = (count _erc_cfgActions);
if (isClass _erc_cfgActions) then {
    for "_j" from 0 to (_erc_numActions - 1) do
    {
        _menu =  _parent displayCtrl (1600 + _j + _numActions);
        _menu ctrlShow true;
        _config =  (_erc_cfgActions select _j);
        _text =  getText (_config >> "text");
        _script =  getText (_config >> "script");
        _height = _height + (0.025 * safezoneH);
        uiNamespace setVariable ['uiControl', _control];
        _menu ctrlSetText _text;
        _menu ctrlSetEventHandler ["ButtonClick",_script];
    };
};
///// end jahan self bloodpack and evac chopper


///// jahan - begin vehicle pointer
        // key colors
        _colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
        if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _item)) in _colors) then {
            // characterID of the key (car character number)
            _keyOwner = getNumber(configFile >> "CfgWeapons" >> _item >> "keyid");
            // key name (like: e3f2)
            _keyName = getText(configFile >> "CfgWeapons" >> _item >> "displayName");

            //Menu entry Key vehicle pointer
            _control =  _parent displayCtrl (1600 + _numActions);
            _control ctrlShow true;
            _height = _height + (0.025 * safezoneH);
            // this needs to point the place where the script is in your mission (vehicle_pointer.sqf)
            _script =  "custom\jtools\vehicle_pointer.sqf";
            _exescript = format["_id = ['%2','%3'] execVM '%1';closeDialog 0;",_script,_keyOwner,_keyName];
            uiNamespace setVariable ['uiControl', _control];
            // sets the text in the right button menu
            _control ctrlSetText "Vehicle Pointer";
            _control ctrlSetTextColor [0.3,0.4,1,1];
            _control ctrlSetTooltip "Pinpoint vehicle. Mark on map if not in range.";
            _control ctrlSetTooltipColorBox [0.3,0.4,1,1];
            _control ctrlSetTooltipColorShade [0, 0, 0, 1];
            _control ctrlSetTooltipColorText [0.3,0.4,1,1];
            _control ctrlSetEventHandler ["ButtonClick",_exescript];
            _numActions = _numActions + 1; // if there are other item action after that (other mods) add 1 to _numactions
        };
///// jahan - end vehicle pointer


///// jahan - begin remote vehicle door opener
/*
        Begin: Vehicle remote lock/unlock
    */
        _itemsPlayer = items player;
        
        _temp_keys = [];
        _temp_keys_names = [];
        // find available keys
        _key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
        if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _item)) in _key_colors) then {
            _ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _item >> "keyid");
            _ownerKeyName = getText(configFile >> "CfgWeapons" >> _item >> "displayName");
            _temp_keys_names set [_ownerKeyId,_ownerKeyName];
            
            _objects = nearestObjects [getPos player, ["LandVehicle","Helicopter","Plane","Ship"], 50];
            _i = 0;
            {
                if (alive _x) then {
                    _ownerID = _x getVariable ["CharacterID", "0"];
                    _hasKey = (_ownerID == str(_ownerKeyId));
                    _oldOwner = (_ownerID == dayz_playerUID);

                    if(_hasKey or _oldOwner) then {
                        if(locked _x) then {
                            //Unlock
                            _menu =  _parent displayCtrl (1600 + _numActions);
                            _menu ctrlShow true;
                            _text =  "Unlock";
                            _script =  "[""" + _ownerID + """] execVM ""custom\remote_unlock.sqf""";
                            _height = _height + (0.025 * safezoneH);
                            uiNamespace setVariable ['uiControl', _control];
                            _menu ctrlSetText _text;
                            _menu ctrlSetEventHandler ["ButtonClick",_script];
                        } else {
                            //Lock
                            _menu =  _parent displayCtrl (1600 + _numActions);
                            _menu ctrlShow true;
                            _text =  "Lock";
                            _script =  "[""" + _ownerID + """] execVM ""custom\remote_lock.sqf""";
                            _height = _height + (0.025 * safezoneH);
                            uiNamespace setVariable ['uiControl', _control];
                            _menu ctrlSetText _text;
                            _menu ctrlSetEventHandler ["ButtonClick",_script];
                        };
                        //Engine start
                        _menu =  _parent displayCtrl (1600 + _numActions + 1);
                        _menu ctrlShow true;
                        _text =  "Engine";
                        _script =  "[""" + _ownerID + """] execVM ""custom\remote_engine.sqf""";
                        _height = _height + (0.025 * safezoneH);
                        uiNamespace setVariable ['uiControl', _control];
                        _menu ctrlSetText _text;
                        _menu ctrlSetEventHandler ["ButtonClick",_script];
                    };
                    
                    _i = _i + 1;
                };
            } forEach _objects;
        };
    /*
        End: Vehicle remote lock/unlock
    */
///// jahan - end remote vehicle door opener


    _pos set [3,_height];
    //hint format["Obj: %1 \nHeight: %2\nPos: %3",_item,_height,_grpPos];        

    _group ctrlShow true;
    ctrlSetFocus _group;
    _group ctrlSetPosition _pos;
    _group ctrlCommit 0;
};

Link to comment
Share on other sites

There seems to be a bug with createVehicleLocal for some objects which might spam the RPT log:

https://dev.withsix.com/issues/25648

 

Just to let you know. Seems that this has not been fixed so far. But I think it's more interesting to use the createVehicle function which everybody else on the server can see ,))

I am still not 100% sure which _classnames that are where the spamming occurs. Either should be made non-local or another classname should be used in this case.

Link to comment
Share on other sites

@fluke/BetterDeadThanZed: how many vehicles do you have on your map?

 

I think if you put the script into the mission, restart the server and directly test this...then the server is doing whatever stuff (running server_monitor and populating all the vehicles and whatever actions there are).

I don't know how that is on the windows server as I am using the Linux version which loads these things differently.

 

I can imagine that the search for a car may take some time (especially directly after restarting)...if there are many vehicles around. I need to check with a diag_log line that if you search for a vehicle from type xyz, if it needs to search through all vehicles or only all from this type. That's something I do not know. After testing it is a bit more clear to me how that works.

So what I mean: for the lower range scan (with showing the arrow) does the search go through all Vehs on the map to see which are within the lower range and returns the list of Vehs which fit to the radius...or is the algorithm (however that works) smart enough to start in the center of search position and just touch the ones in the radius. I think in any case all vehicles need to be touched (same for type, I guess...but not sure).

 

I did not put the search into ui_selectSlot so that one needs to wait there until the search is finished as I saw it in other scripts. It's executed via ExecVM to execute an external script in parallel.

And the script exits the loop as soon as it finds the vehicle which matches ( if ( _keyOwner == _ownerID ) exitWith {  ) so that we do not search for unneccessary things anymore. I don't think that this can be optimized much (but I am happy with any hints if so).

Link to comment
Share on other sites

  • 2 weeks later...

Yes, there are always scripts doing similar tasks. I did not want to click on the map (just on the key directly as I wanted to know where this specific key belongs to) and I wanted vehicles which are near (in your car park) to show up with a sign instead of showing these on the map. So this is a similar script which handles things a bit different.

Link to comment
Share on other sites

What I meant was, because our scripts are very similar, if you needed a infistar fix or if you had wanted to provide a version for the masterkey script, you could have got the information from my thread.

The infistar fix is basically the same for both our scripts. You did not need to wait for ebaydayz to provide a fix you could have just looked at the one that I had provided with my script.

Link to comment
Share on other sites

  • 1 month later...

Has anyone got this working on infistar?

iv applied the fixs from the other topic but still only works for admins and not players, the script itself dont even kick-in. they dont even get the writing on the bottom left of the screen.

 

iv tried with a few different setting in the ahconfig with dialog true and false ect

 

thanks

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...

Hi

I have installed vehicle pointer onto my server, when i right click on a key i get the option Vehicle Pointer but when i click on it nothing happens. Any idea?

 

Same here.  I have the option when I right click on the key but nothing happens for me either.  Let me know if you figure it out.  

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 year later...
On 1/30/2015 at 7:13 PM, tasman said:

Hi

I have installed vehicle pointer onto my server, when i right click on a key i get the option Vehicle Pointer but when i click on it nothing happens. Any idea?

 

On 3/16/2015 at 3:26 AM, FieldySnutz said:

 

Same here.  I have the option when I right click on the key but nothing happens for me either.  Let me know if you figure it out.  

 

On 4/12/2015 at 8:16 PM, Logan said:

^ Do you 2 have The gold coin currency 3.0 installed. Only stopped working for me once I installed that.

I'm having the same issue - Installed - right click option is working but nothing happens when I do it. 

Running 2.0 SCB

I Dropped the file here and changed the line to point to it - "custom\vehicle_pointer.sqf";

I'm Going to try and move the position of the code inside the  ui_selectSlot.sqf  now ...

EDIT: AFTER MOVING THE CODE I STILL HAVE THE SAME RESULT - NOTHING HAPPENS WHEN I CLICK "VEHICLE POINTER" 

 Any other Ideas what I'm doing wrong? 

https://gist.github.com/anonymous/c5aa60ce67789c2d9a6e503c7fd1c332

EDIT; I'm using infiStar and applied the following changes :

 

createMarkerLocal='yes';
setMarkerShapeLocal='yes';
setMarkerTypeLocal='yes';
setMarkerColorLocal='yes';
setMarkerSizeLocal='yes';
setMarkerTextLocal='yes';

----------

BUT I WAS UNABLE TO FIND THIS IN MY AH.sqf

----------

Then search for this line:
vehicles = [vehicle player];

Replace it with this:
vehicles = vehicles;

 

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
  • Discord

×
×
  • Create New...