Zlin 10 Posted September 19, 2013 Need some help please. In a mission I am working on, I spawn a radio tower as part of an assigned task via script: tower = "Land_TTowerBig_1_F" createVehicle (getMarkerPos "cAmkr13"),0; _VarName="tower"; tower SetVehicleVarName _VarName; tower Call Compile Format ["%1=_This ; PublicVariable ""%1""",_VarName]; I have an addaction that allows the players to cancel the task if they desire. When a player cancels the task, I remove the radio tower with: deleteVehicle tower; The tower is immediately removed from the map. The task is to destroy the tower. If a player actually destroys the tower, the tower collapses on itself and the task is completed. My issue is that after the tower is destroyed, I can't remove it from the map. I have the same command to remove the tower "deleteVehicle tower;" but if the tower is destroyed, the deleteVehicle no longer works and the tower remains on the map. Can someone please tell me why it works this way and how I can remove the destroyed tower via a script? Thanks in advance. Z Share this post Link to post Share on other sites
Gekkibi 11 Posted September 19, 2013 Why do you need to destroy the tower when you can use condition (8th parameter, probably "damage tower < 0.5") in addAction? Do you just want to remove the action in the action menu, or do you really have to delete the rubble? Share this post Link to post Share on other sites
Tajin 349 Posted September 19, 2013 That is because the ruins of your tower are a new object and do not keep the original varname. You should be able to delete the ruins by saving the position of the tower and using the nearestObject command with its classname. https://community.bistudio.com/wiki/nearestObject Share this post Link to post Share on other sites
Zlin 10 Posted September 19, 2013 @Gekkibi The mission I am running runs as a persistent mission, and is all task driven. It is designed for a small group (2 - 4 players) and is focused on specific tasks. Players can request a task via radio command. The tasks are like "clear area of insurgents", "clear area of vehicles', "clear area of boats". A new task I am trying to add is for destroying specific objects, ex: Destroy insurgent radio tower near marker "X". The tasks are picked at random from an array. So, if a player requests a task and gets a "Destroy Radio Tower" task, I use a spawn vehicle script command to place an object on the map at a specified marker. No, if the player decides he does not want to play that task, he can use a radio command to cancel the task. If the player cancels the task, I want the spawned object to be removed as the task is not longer in play. So, I can remove the undamaged radio tower just fine with the deleteVehicle command but... if the player actually plays the task out and destroys the tower, I want the tower rubble to be removed after a period of time, so if lets say after another hour of playing, users get the same task again (as a randomly selected task) there wont' be a radio tower already in rubble on the same spot that the spanwed tower is going to be spawned at. ---------- Post added at 15:39 ---------- Previous post was at 15:38 ---------- @Tajin Oooohhh... I understand now. I didn't not realize the destroyed object had a new name. Thank you very much for your assistance. Z Share this post Link to post Share on other sites
kylania 568 Posted September 19, 2013 (edited) I didn't not realize the destroyed object had a new name. It doesn't. (oh, it's creating a new object wreck instead of everything else in the world not doing that.) If you delete it quick enough it won't leave a wrecked version. _tower = createVehicle ["Land_TTowerBig_1_F", getMarkerPos "mrkTower", [], 0, "CAN_COLLIDE"]; missionNamespace setVariable ["tower",_tower]; publicVariable "tower"; waitUntil {!alive tower}; hint "tower is destroyed!"; sleep 5; // give the wreck time to exist _wreck = getMarkerPos "mrkTower" nearestObject "Land_TTowerBig_1_ruins_F"; missionNamespace setVariable ["sillyWreck",_wreck]; publicVariable "sillyWreck"; // Run these from another script or from here: deleteVehicle tower; deletevehicle sillyWreck; Edited September 19, 2013 by kylania Fixed code Share this post Link to post Share on other sites
Zlin 10 Posted September 19, 2013 It doesn't. _tower = createVehicle ["Land_TTowerBig_1_F", getMarkerPos "mrkTower", [], 0, "CAN_COLLIDE"]; missionNamespace setVariable ["tower", _tower]; publicVariable "tower"; waitUntil {!alive tower}; sleep 10; deleteVehicle tower; @kylania Thanks for your reply. I just tried your example and it did not work. The tower rubble remains. Share this post Link to post Share on other sites
kylania 568 Posted September 19, 2013 I edited that code, try the new stuff. :) Share this post Link to post Share on other sites
Zlin 10 Posted September 19, 2013 It doesn't. (oh, it's creating a new object wreck instead of everything else in the world not doing that.) If you delete it quick enough it won't leave a wrecked version. _tower = createVehicle ["Land_TTowerBig_1_F", getMarkerPos "mrkTower", [], 0, "CAN_COLLIDE"]; missionNamespace setVariable ["tower",_tower]; publicVariable "tower"; waitUntil {!alive tower}; hint "tower is destroyed!"; sleep 5; // give the wreck time to exist _wreck = getMarkerPos "mrkTower" nearestObject "Land_TTowerBig_1_ruins_F"; missionNamespace setVariable ["sillyWreck",_wreck]; publicVariable "sillyWreck"; // Run these from another script or from here: deleteVehicle tower; deletevehicle sillyWreck; @Kylania Thank you very much sir!!!! Works perfectly now!! Z Share this post Link to post Share on other sites
kylania 568 Posted September 19, 2013 It was tajin's idea. :) Share this post Link to post Share on other sites