Jump to content
  • 0

How to delete a road


ViktorReznov

Question

seriously, ive gone through hell to extract a classname on a road. Selecting the road as an object is done so theoretically, deleting it with deletevehicle should do it no? well it doesnt and im trying to figure out how to make it happen.

heres the (blown apart with diag_logs) code that will return the classname of road

updated to fix whitespaces in the name as well asf1_7 100 into MAP_asf1_7_100

Spoiler

private[];

_player = player; //define player
diag_log format["[Roads][Vars] Testing each var individually!!! _player = %1",_player];
_pos = getPos player; //get players position
diag_log format["[Roads][Vars] Testing each var individually!!! _pos = %1",_pos];
_posOnRoad = isOnRoad _pos; //bool if player pos is on road
diag_log format["[Roads][Vars] Testing each var individually!!! _posOnRoad = %1",_posOnRoad];
_roads = _pos nearRoads 25; //return array of roads within 10m of player
diag_log format["[Roads][Vars] Testing each var individually!!! _roads = %1",_roads];
_roads2 = (_roads select 0); //return road object from array
diag_log format["[Roads][Vars] Testing each var individually!!! _roads2 = %1",_roads2];
_roads3 = (str(_roads select 0)); //convert object to string to cut it down to class name
diag_log format["[Roads][Vars] Testing each var individually!!! _roads3 = %1",_roads3];
_roads4 = []; //empty container for preConversion name
diag_log format["[Roads][Vars] Testing each var individually!!! _roads4 = %1",_roads4];
_roads4 = _roads4 + toArray(_roads3); //load container with name converted to numbers
diag_log format["[Roads][Vars] Testing each var individually!!! _roads4 = %1",_roads4];
_roads5 = []; //empty container for postConversion name
diag_log format["[Roads][Vars] Testing each var individually!!! _roads5 = %1",_roads5];
_start = (_roads4 find 32); //selecting numeral for whitespace, with road will be space right before obj classname
diag_log format["[Roads][Vars] Testing each var individually!!! _start = %1",_start];
_end = (_roads4 find 46); //selecting numeral for period after classname
diag_log format["[Roads][Vars] Testing each var individually!!! _end = %1",_end];
_roadFound = ((count _roads) != 0); //bool for if road array is not empty
diag_log format["[Roads][Vars] Testing each var individually!!! _roadFound = %1",_roadFound];
//_roadSpace = nearestObject _roads;
//diag_log format["[Roads][Vars] Testing each var individually!!! _roadSpace = %1",_roadSpace];

for "_i" from ((_start)+1) to ((_end)-1) do { //begin loop after whitespace and end before period need to change 32 into 95
  _whiteSpace = 32; //code for whitespace
  _sel = _roads4 select _i; //container for comparing whats in it
  if (_sel == _whiteSpace) then {
    _roads5 = _roads5 + [95];
     diag_log format["[Roads][Vars] Testing each var individually, 42 to 95 convert!!! _roads5 = %1",_roads5];
  } else {
    _roads5 = _roads5 + [_roads4 select _i]; //load our select numerals into new array for conversion
    diag_log format["[Roads][Vars] Testing each var individually!!! _roads5 = %1",_roads5];
  };
};

_roads6 = toString(_roads5); //our converted classname of road
diag_log format["[Roads][Vars] Testing each var individually!!! _roads6 = %1",_roads6];
_roads7 = str(_roads6); //our converted classname of road
diag_log format["[Roads][Vars] Testing each var individually!!! _roads7 = %1",_roads7];
_roads8 = _roads6; 
diag_log format["[Roads][Vars] Testing each var individually!!! _roads8 = %1",_roads8];
_roads9 = "MAP_" + _roads8; //our converted classname of road concentated with MAP_
diag_log format["[Roads][Vars] Testing each var individually!!! _roads9 = %1",_roads9];
_roadParts = getArray(missionConfigFile >> "Custom_Buildables" >> "Buildables" >> "RoadsAsphalt1" >> _roads9 >> "requiredmaterials");
diag_log format["[Roads][Vars] Testing each var individually!!! _roadParts = %1",_roadParts];

_objectID = _roads2 getVariable ["ObjectID","0"];
diag_log format["[Roads][Vars] Testing each var individually!!! _objectID = %1",_objectID];
_objectUID = _roads2 getVariable ["ObjectUID","0"];
diag_log format["[Roads][Vars] Testing each var individually!!! _objectUID = %1",_objectUID];
_typeOf = _roads9;
diag_log format["[Roads][Vars] Testing each var individually!!! _typeOf = %1",_typeOf];

if ((_posOnRoad) && (_roadFound)) then { //trying to delete the MFFER
  PVDZ_obj_Destroy = [_objectID,_objectUID,player,_typeOf];
  publicVariableServer "PVDZ_obj_Destroy";

  deleteVehicle _roads2;
  diag_log ("[Roads][Deletion] Did it delete?");
};

and this is the diagLogs produced, if you check _roads8 it indeed has produced a classname (intended for use elsewhere, the obj container _roads2 should still delete with deletevehicle no?)

Spoiler

"[Roads][Vars] Testing each var individually!!! _player = B 1-1-B:1 (Patriarch)"
"[Roads][Vars] Testing each var individually!!! _pos = [742.378,1898.83,0.00144482]"
"[Roads][Vars] Testing each var individually!!! _posOnRoad = true"
"[Roads][Vars] Testing each var individually!!! _roads = [1034273: asf1_7 100.p3d,1034272: asf1_12.p3d,1034271: asf1_15 75.p3d]"
"[Roads][Vars] Testing each var individually!!! _roads2 = 1034273: asf1_7 100.p3d"
"[Roads][Vars] Testing each var individually!!! _roads3 = 1034273: asf1_7 100.p3d"
"[Roads][Vars] Testing each var individually!!! _roads4 = []"
"[Roads][Vars] Testing each var individually!!! _roads4 = [49,48,51,52,50,55,51,58,32,97,115,102,49,95,55,32,49,48,48,46,112,51,100]"
"[Roads][Vars] Testing each var individually!!! _roads5 = []"
"[Roads][Vars] Testing each var individually!!! _start = 8"
"[Roads][Vars] Testing each var individually!!! _end = 19"
"[Roads][Vars] Testing each var individually!!! _roadFound = true"
"[Roads][Vars] Testing each var individually!!! _roads5 = [97]"
"[Roads][Vars] Testing each var individually!!! _roads5 = [97,115]"
"[Roads][Vars] Testing each var individually!!! _roads5 = [97,115,102]"
"[Roads][Vars] Testing each var individually!!! _roads5 = [97,115,102,49]"
"[Roads][Vars] Testing each var individually!!! _roads5 = [97,115,102,49,95]"
"[Roads][Vars] Testing each var individually!!! _roads5 = [97,115,102,49,95,55]"
"[Roads][Vars] Testing each var individually, 42 to 95 convert!!! _roads5 = [97,115,102,49,95,55,95]"
"[Roads][Vars] Testing each var individually!!! _roads5 = [97,115,102,49,95,55,95,49]"
"[Roads][Vars] Testing each var individually!!! _roads5 = [97,115,102,49,95,55,95,49,48]"
"[Roads][Vars] Testing each var individually!!! _roads5 = [97,115,102,49,95,55,95,49,48,48]"
"[Roads][Vars] Testing each var individually!!! _roads6 = asf1_7_100"
"[Roads][Vars] Testing each var individually!!! _roads7 = "asf1_7_100""
"[Roads][Vars] Testing each var individually!!! _roads8 = asf1_7_100"
"[Roads][Vars] Testing each var individually!!! _roads9 = MAP_asf1_7_100"
"[Roads][Vars] Testing each var individually!!! _roadParts = ["ItemStone","ItemStone","MortarBucket","PartGeneric"]"
"[Roads][Vars] Testing each var individually!!! _objectID = 0"
"[Roads][Vars] Testing each var individually!!! _objectUID = 0"
"[Roads][Vars] Testing each var individually!!! _typeOf = MAP_asf1_7_100"
"[Roads][Deletion] Did it delete?"

Now that road is a road that was generated by the map, if I attempt to use this on a road I created with script, im unable to (currently) track it down, ill get a postive on the isOnRoad function but cannot find the road as an object

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0

@ViktorReznov

not sure if works with roads.. but try execute this one at bottom of init.sqf

execVM "remove_roads.sqf";

remove_roads.sqf

Spoiler

_target = [0,0,0];//change by your coords
_damage_ratio=150;


_server_roads= _target nearObjects ["Roads ids here", _damage_ratio];
{deletevehicle _x } forEach _server_roads;

 

 

also take a look here

https://community.bistudio.com/wiki/nearRoads

 

Link to comment
Share on other sites

  • 0
1 minute ago, juandayz said:

@ViktorReznov

not sure if works with roads.. but try execute this one at bottom of init.sqf


execVM "remove_roads.sqf";

remove_roads.sqf

  Hide contents


_target = [0,0,0];//change by your coords
_damage_ratio=150;


_server_roads= _target nearObjects ["Roads ids here", _damage_ratio];
{deletevehicle _x } forEach _server_roads;

 

 

also take a look here


https://community.bistudio.com/wiki/nearRoads

 

yes, one of my variables uses nearRoads, will try the function you suggest and get back to you!

Link to comment
Share on other sites

  • 0

my test script up there I wrote it to also remove the .p3d at the end of the string array, I havent been able to find too much information on what exactly that all means. Is it required in order to delete an object?

reference post I found with someone doing a similar function (a lot cleaner and nicer looking mind you) but seems to be old as dirt

http://www.ofpec.com/forum/index.php?topic=29713.0

Link to comment
Share on other sites

  • 0
Just now, ViktorReznov said:

my test script up there I wrote it to also remove the .p3d at the end of the string array, I havent been able to find too much information on what exactly that all means. Is it required in order to delete an object?

reference post I found with someone doing a similar function (a lot cleaner and nicer looking mind you) but seems to be old as dirt

http://www.ofpec.com/forum/index.php?topic=29713.0

i use this code in Z-IMS to get nearest forests-trees to make pee/poop see:


//////////////////////////////////FROM HERE
_findNearestTree = [];
{
	if (("" == typeOf _x) && {alive _x}) then {
		_objName = _x call fn_getModelName;
		// Exit since we found a tree
		if (_objName in dayz_trees) exitWith { _findNearestTree set [count _findNearestTree,_x]; };
	};
} count nearestObjects [getPosATL player, [], 20];


if (count _findNearestTree > 0) then {
	_tree = _findNearestTree select 0;
	_distance2d = [player, _tree] call BIS_fnc_distance2D;	
if (_distance2d < 5) exitWith {

//////////////////////TO HERE/////////////////////
                    
if (needpiss) then {
[player, "fillwater", 0, false, 5] call dayz_zombieSpeak;
player removeAction s_player_makepiss;
s_player_makepiss = -1;
needpiss = false;
};

if (needpoo) then {

 

Link to comment
Share on other sites

  • 0
On 10/3/2017 at 3:30 PM, juandayz said:

DAm! i wanna see players working on new roads being whipped.



 

ohh, dont you worry mate. This function has been added due to the possibiliteis of another mod already out and largely popular... im very close to being complete with these new set of scripts and am attempting to collaborate with the author. Bases with raods/airfileds/tracks are very near and upcoming feature!

Link to comment
Share on other sites

  • 0

The road deletion script is now complete. It will in fact only detect player spawned roads, not map spawned roads so this is good. Waiting on a response from some friends and will be released soon, one way or another. Road/runway/bridge construction is here. Also comes with ownership access so no random ppl removing your roads or vice versa

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