Jump to content
  • 0

Don't harvest when someone is nearby


Droge Worst

Question

Hey everyone! I'm using a script to remove ''Fiberplants'', but when 2 people start harvisting the weedplant it will dupe the plant (cause both people get the ItemKiloHemp). How can I add a variable that blocks executing this script when a player is nearby?

 

This is the script: 

/*
put together for DayZ Epoch
Credits to Shogun338 from Insurrection gaming
modified for separate "gather weed" script
*/
 
private ["_gearmenu","_playerPos","_nearWeed","_weed","_objectID","_objectUID"];
_playerPos = getPosATL player;
_hempqty = {_x == "ItemKiloHemp"} count magazines player;
_nearWeed = count nearestObjects [_playerPos, ["fiberplant"], 4] > 0;
_weed = nearestObject [player, "fiberplant"];
 
if !(_nearWeed) exitWith {
	cutText [format["You need to be near the weed plants in order to gather."], "PLAIN DOWN"];
};
if (_hempqty > 2) exitWith { 
    cutText [format["WARNING: %1, You have maximum amount of weed in your inventory! You could get arrested by the police ;)", name player], "PLAIN DOWN"];
};
if (dayz_combat == 1) then { 
    cutText [format["You are in Combat and Cannot Gather the Weed."], "PLAIN DOWN"];
} else {
	disableSerialization;
	_gearmenu = FindDisplay 106;
	_gearmenu CloseDisplay 106;
	player playActionNow "Medic";
	r_interrupt = false;
	sleep 6;
	_objectID = _weed getVariable["ObjectID","0"];
	_objectUID = _weed getVariable["ObjectUID","0"];
	deleteVehicle _weed;
	[_objectID,_objectUID] call server_deleteObj;
	_weed setDamage 1;
	player addMagazine "ItemKiloHemp";
	sleep 2;
	cutText [format["You've Gathered Some Weed! Smoke that shit or sell it at Innocent Drugsdealer (no safezone)!!"], "PLAIN DOWN"];	
};
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

private ["_playernear];

_playernear = count nearestentities [player, ["CaManBase"], 5];

if ((_playernear) > 1) exitwith {};

put this at thetop of the script. the number (5) is the radius. you can change that number.

thats the way to go. but, Im on my mobile, so Im not sure nearestentities is correctly written. maybe someone can correct me.

Link to comment
Share on other sites

  • 0

private ["_playernear];

_playernear = count nearestentities [player, ["CaManBase"], 5];

if ((_playernear) > 1) exitwith {};

put this at thetop of the script. the number (5) is the radius. you can change that number.

thats the way to go. but, Im on my mobile, so Im not sure nearestentities is correctly written. maybe someone can correct me.

You're my hero! :D 

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