SryImAnooB Posted April 2, 2017 Report Share Posted April 2, 2017 Hey guys im trying to make a little script, which allows a player to delete a nearby Object. In that case a "Sr_border". First i did it like this: With Clickaction. removeBorder.sqf _nearBorder = nearestObject [player,"Sr_border"]; if (_nearBorder distance player < 5) then { {deleteVehicle _x} forEach nearestObjects [_player, ["Sr_border"], _range] } else { SystemChat "No Carspawn nearby!"; }; Worked pretty good, except for the problem, that after restart the border was back. I think thats because the {deleteVehicle _x} is exec. localy. So i tryed this: init.sqf "removecarspawn" addPublicVariableEventHandler { {deleteVehicle _x} forEach nearestObjects [_player, ["Sr_border"], _range] }; removeBorder.sqf _nearBorder = nearestObject [player,"Sr_border"]; _range = 5; _player = player; if (_nearBorder distance player < 5) then { publicVariable "removecarspawn"; } else { SystemChat "No Carspawn nearby!"; }; But its not working. Im a bit clueless, any tips for me? Link to comment Share on other sites More sharing options...
0 juandayz Posted April 2, 2017 Report Share Posted April 2, 2017 @SryImAnooB i use it in workshop to remove objects Spoiler private ["_playerPos","_nearRestr","_delobj","_objectID","_objectUID"]; _playerPos = getPosATL player; _nearRestr = count nearestObjects [_playerPos, ["Loudspeakers_EP1"], 25] > 0; player playActionNow "Medic"; [player,"repair",0,false,10] call dayz_zombieSpeak; [player,10,true,(getPosATL player)] spawn player_alertZombies; sleep 2; _delobj = nearestObject [player, "Loudspeakers_EP1"]; _objectID = _delobj getVariable["ObjectID","0"]; _objectUID = _delobj getVariable["ObjectUID","0"]; deleteVehicle _delobj; [_objectID,_objectUID] call server_deleteObj; deleteVehicle _delobj; PVDZ_obj_Destroy = [_objectID,_objectUID,_delobj]; publicVariableServer "PVDZ_obj_Destroy"; titleText ["Loudspeakers was removed", "PLAIN DOWN"];titleFadeOut 5; SryImAnooB 1 Link to comment Share on other sites More sharing options...
0 juandayz Posted April 2, 2017 Report Share Posted April 2, 2017 or see the noxicarius way using cursor target to remove anykind of object Spoiler private ["_obj","_objectID","_objectUID","_cnt","_locationPlayer","_player","_text"]; _obj = cursorTarget; _player = player; _locationPlayer = _player modeltoworld [0,0,0]; _cnt = 0; _text = ""; if(isNull _obj) exitWith{cutText ["No object selected","PLAIN UP"];}; _objectID = _obj getVariable["ObjectID","0"]; _objectUID = _obj getVariable["ObjectUID","0"]; _fnc_databaseremtimer = { _cnt = 5; for "_i" from 1 to 5 do { _text = getText (configFile >> "CfgVehicles" >> typeOf _obj >> "displayName"); cutText [format["!!!Deleting %1 from database in %2 seconds!!!\nMove from current position to cancel",_text,_cnt], "PLAIN DOWN",1]; if (player distance _locationPlayer > 0.2) then {cutText [format["Removal cancelled for %1, position of player moved",_text], "PLAIN DOWN",1]; breakOut "exit";}; sleep 1; _cnt = _cnt - 1; }; call _func_databaseremove; }; _func_databaseremove = { cutText ["Object deleted from database", "PLAIN DOWN",1]; PVDZ_obj_Destroy = [_objectID,_objectUID,(name player)]; publicVariableServer "PVDZ_obj_Destroy"; if (isServer) then { PVDZ_obj_Destroy call server_deleteObj; }; deletevehicle _obj; breakout "exit"; }; call _fnc_databaseremtimer; SryImAnooB 1 Link to comment Share on other sites More sharing options...
0 SryImAnooB Posted April 3, 2017 Author Report Share Posted April 3, 2017 19 hours ago, juandayz said: @SryImAnooB i use it in workshop to remove objects Hide contents private ["_playerPos","_nearRestr","_delobj","_objectID","_objectUID"]; _playerPos = getPosATL player; _nearRestr = count nearestObjects [_playerPos, ["Loudspeakers_EP1"], 25] > 0; player playActionNow "Medic"; [player,"repair",0,false,10] call dayz_zombieSpeak; [player,10,true,(getPosATL player)] spawn player_alertZombies; sleep 2; _delobj = nearestObject [player, "Loudspeakers_EP1"]; _objectID = _delobj getVariable["ObjectID","0"]; _objectUID = _delobj getVariable["ObjectUID","0"]; deleteVehicle _delobj; [_objectID,_objectUID] call server_deleteObj; deleteVehicle _delobj; PVDZ_obj_Destroy = [_objectID,_objectUID,_delobj]; publicVariableServer "PVDZ_obj_Destroy"; titleText ["Loudspeakers was removed", "PLAIN DOWN"];titleFadeOut 5; This works perfectly! Thank you! Link to comment Share on other sites More sharing options...
Question
SryImAnooB
Hey guys im trying to make a little script, which allows a player to delete a nearby Object. In that case a "Sr_border".
First i did it like this:
With Clickaction.
removeBorder.sqf
Worked pretty good, except for the problem, that after restart the border was back.
I think thats because the {deleteVehicle _x} is exec. localy.
So i tryed this:
init.sqf
"removecarspawn" addPublicVariableEventHandler { {deleteVehicle _x} forEach nearestObjects [_player, ["Sr_border"], _range] };
removeBorder.sqf
But its not working. Im a bit clueless, any tips for me?
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now