Jump to content
  • 0

Script edit help please, simple I am sure for scripter


azzdayz

Question

Hey guys I am sure this would be very simple, but I am not sure what the correct way of coding it would be.

I want to take this code and add a simple restriction in it. AKA....... IF 60 meters from itemplotpole THEN get no _menu1 option

Like I said it should be pretty simple to do, just not sure how to word it correctly.

//Repairing Vehicles
    if ((dayz_myCursorTarget != cursorTarget) and _isVehicle and !_isMan and _hasToolbox and (damage cursorTarget < 1)) then {
 
        if (s_player_repair_crtl < 0) then {
 
            _vehicle = cursorTarget;
            dayz_myCursorTarget = _vehicle;
 
            _menu = dayz_myCursorTarget addAction ["Repair Vehicle", "salvage\repair_vehicle.sqf",_vehicle, 0, true, false, "",""];
            _menu1 = dayz_myCursorTarget addAction ["Salvage Vehicle", "salvage\salvage_vehicle.sqf",_vehicle, 0, true, false, "",""];
 
            s_player_repairActions set [count s_player_repairActions,_menu];
            s_player_repairActions set [count s_player_repairActions,_menu1];
 
            s_player_repair_crtl = 1;
 
        } else {
            {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
            s_player_repair_crtl = -1;
        };
    };

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Here' s the fancy version :P

//Repairing Vehicles
if ((dayz_myCursorTarget != cursorTarget) and _isVehicle and !_isMan and _hasToolbox and (damage cursorTarget < 1)) then {

	if !(s_player_repair_crtl) then {

		dayz_myCursorTarget = cursorTarget;

		_menu = dayz_myCursorTarget addAction ["Repair Vehicle", "salvage\repair_vehicle.sqf",dayz_myCursorTarget, 0, true, false, "",""];
		s_player_repairActions set [0,_menu];

		_plot = nearestObjects [player, ["Plastic_Pole_EP1_DZ"], 60];

		if !(count _plot > 0) then {
			_menu1 = dayz_myCursorTarget addAction ["Salvage Vehicle", "salvage\salvage_vehicle.sqf",dayz_myCursorTarget, 0, true, false, "",""];
			s_player_repairActions set [1,_menu1];
		};
		s_player_repair_crtl = true;

	} else {
		{dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
		s_player_repair_crtl = false;
	};
};

Link to comment
Share on other sites

  • 0

LOL ya I can modify code, but integrating code is out of my depth.

Now this is me completely spit balling. let me know if I appear to be even close to anything remotely usable, LOL

//Repairing Vehicles
    if ((dayz_myCursorTarget != cursorTarget) and _isVehicle and !_isMan and _hasToolbox and (damage cursorTarget < 1)) then {
 
        if (s_player_repair_crtl < 0) then {
 
            _vehicle = cursorTarget;
            dayz_myCursorTarget = _vehicle;
 
                _menu = dayz_myCursorTarget addAction ["Repair Vehicle", "salvage\repair_vehicle.sqf",_vehicle, 0, true, false, "",""];
            
            if nearestObjects [player, ["Plastic_Pole_EP1_DZ"], 60]; then {
                
                _cancel = true;
                _reason = format["Cannot salvage part within a plot pole radius"];
                
            }else{
            
                _menu1 = dayz_myCursorTarget addAction ["Salvage Vehicle", "salvage\salvage_vehicle.sqf",_vehicle, 0, true, false, "",""];
                
            }
 
            s_player_repairActions set [count s_player_repairActions,_menu];
            s_player_repairActions set [count s_player_repairActions,_menu1];
 
            s_player_repair_crtl = 1;
 
        } else {
            {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
            s_player_repair_crtl = -1;
        };
    };

Link to comment
Share on other sites

  • 0

Well I was at work when I pasted the original post and didn't realize the one I pasted was an edit by someone apparently. Needless to say do to that fact the very nicely provided write by Raymix did not work. I was able to take some of the work and get it mostly working with the way my actual code is written, but it is working backwards. If your around a  plot pole you can salvage and if you out of a plot pole range then you cant savage, LOL could you Raymix or someone help me out one more time and let me know what needs to be done to reverse this?

    //Repairing Vehicles
if ((dayz_myCursorTarget != _cursorTarget) && _isVehicle && !_isMan && _hasToolbox && (damage _cursorTarget < 1) && !_isDisallowRepair) then {


        if (s_player_repair_crtl < 0) then {
            dayz_myCursorTarget = _cursorTarget;
            _menu = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_REPAIRV", "\z\addons\dayz_code\actions\repair_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
            
        _plot = nearestObjects [player, ["Plastic_Pole_EP1_DZ"], 60];
        
        if (count _plot > 0) then {
            _menu1 = dayz_myCursorTarget addAction ["Salvage Vehicle", "SCRIPTS\salvage_vehicle\salvage_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
            s_player_repairActions set [count s_player_repairActions,_menu1];
            };
            s_player_repairActions set [count s_player_repairActions,_menu];
            s_player_repair_crtl = 1;
        } else {
            {dayz_myCursorTarget removeAction _x} count s_player_repairActions;s_player_repairActions = [];
            s_player_repair_crtl = -1;
        };
    };

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

×
×
  • Create New...