ShootingBlanks
OpenDayZ Guru!
Again, this another post where I provide too much information, but I think just giving completed code and fixes without explanation doesnt help anyone learn anything. I linked all the files on github so you can see which files and lines I am talking about.but why is it that when i harvest the weed it doesnt dissapear so all my players can just keep standing and harvest the same plant for hours
that sounds like a coding error. I have never fooled with the harvesthemp scripts as I personally find the practice of encouraging marijuana use and drug dealers to be ... subversive ... So this is based on my following the code on github.
You activate your own hemp file that spawns in all the weed farms. What about the default one? You didnt disable the harvesthemp in the scriptcontrol (and you shouldn't) or else the click action would not be working. If you look here you will see that when you 'harvest weed' in the click config.sqf file , it calls the hemp.sqf file (lines 87-)
Code:
If(HarvestHempScript)then{
HARVEST = [
["ItemKiloHemp","Smoke Weed","[] execVM 'scripts\HarvestHemp\smokeweed.sqf';","true"],
["ItemKnife","Harvest Weed","[] execVM 'scripts\HarvestHemp\hemp.sqf';","true"]
];
Code:
if (IsHarvesting)then{
cutText [format["You are already gathering Weed!"], "PLAIN DOWN"];
}else{
IsHarvesting = true;
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 it or sell it to a Black market dealer!"], "PLAIN DOWN"];
IsHarvesting = false;
But in your hempfarm.sqf file you are not creating any and assigning those to the plants you are spawning. This code is from the randomweedfarm.sqf file starting on line 117 where you can see the setvariable for objectId and objectUID which are just randomly generated.
Code:
_plantpositions = [[(_coords select 0),(_coords select 1),0],_amnt,5] call _fnc_positions_array;
{
_plant = createVehicle [_fiberplant, _x, [], 0, "CAN_COLLIDE"];
_plant setPos _x;
_uID = str(round(random 999999));
_plant setVariable ["ObjectID", _uID, true];
_plant setVariable ["ObjectUID", _uID, true];
_plant setVariable ["lastUpdate",time,true];
}forEach _plantpositions;
};
So your solution is to copy the random objectID and objectUID code and assign those variables to the weeds you are spawning. You can either do it for each and every fiberplant on the map by adding code to your hemp file like this:
Change each instance of your "fiberplant" code block from this (taken from your hempfarm.sqf file line 94, there are 58 instances of this code block in your file.
Code:
if (true) then
{
_this = createVehicle ["fiberplant", [1848.5686, 14561.254, -3.0517578e-005], [], 0, "CAN_COLLIDE"];
_vehicle_20 = _this;
_this setPos [1848.5686, 14561.254, -3.0517578e-005];
};
Code:
if (true) then
{
_this = createVehicle ["fiberplant", [1848.5686, 14561.254, -3.0517578e-005], [], 0, "CAN_COLLIDE"];
_vehicle_20 = _this;
_this setPos [1848.5686, 14561.254, -3.0517578e-005];
_uID = str(round(random 999999));
_this setVariable ["ObjectID", _uID, true];
_this setVariable ["ObjectUID", _uID, true];
_this setVariable ["lastUpdate",time,true];
};
Alternatively, and a better option is you can add a single block at the bottom of your hemp.sqf file to find all fiberplants on the map and add the random uid and id to them..
Code:
_plantpositions = nearestObjects[getmarkerpos "center", ["fiberplanet"],5000];
{
_uID = str(round(random 999999));
_x setVariable ["ObjectID", _uID, true];
_x setVariable ["ObjectUID", _uID, true];
_x setVariable ["lastUpdate",time,true];
}forEach _plantpositions;
http://pastebin.com/8j36hP5F
may not work ... not tested.
Last edited: