azzdayz Posted September 22, 2015 Report Share Posted September 22, 2015 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 optionLike 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 More sharing options...
0 axeman Posted September 22, 2015 Report Share Posted September 22, 2015 take a look at:https://community.bistudio.com/wiki/nearestObjectsandhttps://community.bistudio.com/wiki/distanceam on phone so can't get too fancy :) Link to comment Share on other sites More sharing options...
0 raymix Posted September 22, 2015 Report Share Posted September 22, 2015 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; }; }; axeman 1 Link to comment Share on other sites More sharing options...
0 azzdayz Posted September 22, 2015 Author Report Share Posted September 22, 2015 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 More sharing options...
0 azzdayz Posted September 22, 2015 Author Report Share Posted September 22, 2015 Oh thanks Ramix, you rock. I will give it a try. As you can see from my post above I was way off from trying, LOLThanks Again Link to comment Share on other sites More sharing options...
0 azzdayz Posted September 23, 2015 Author Report Share Posted September 23, 2015 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 Vehiclesif ((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 More sharing options...
0 azzdayz Posted September 23, 2015 Author Report Share Posted September 23, 2015 Can anyone help me figure out why my edit is making it work backwards? I would really like to figure this out and every time I try something it breaks the whole code :( Link to comment Share on other sites More sharing options...
0 raymix Posted September 24, 2015 Report Share Posted September 24, 2015 The answer is still in my post, you gotta be more careful when editing without understanding: if !(count _plot > 0) then { //exclamation mark reverses logic Link to comment Share on other sites More sharing options...
0 azzdayz Posted September 24, 2015 Author Report Share Posted September 24, 2015 (edited) Ah, I tried looking up what that did, but couldn't find anything on it. Thanks I will give it a shoot :)Update!!!Worked like a charm, thanks again. Edited September 24, 2015 by azzdayz Link to comment Share on other sites More sharing options...
Question
azzdayz
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
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 accountSign in
Already have an account? Sign in here.
Sign In Now