Jump to content
  • 0
Sign in to follow this  
SryImAnooB

Player remove nearby object

Question

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?

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

@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;

 

 

Share this post


Link to post
Share on other sites
  • 0

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;

 

 

Share this post


Link to post
Share on other sites
  • 0
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!

Share this post


Link to post
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
Sign in to follow this  

  • Similar Content

    • By JakeQue
      Usually it would state 
       
      "You cannot gut this animal without a knife"
       
      but now the scroll  action is dead and I don't get an error.
       
      Please help!
    • By xDUKEx
      * Sorry ... This should be ARMA 2 not ARMA 3 ... Not sure how I got myself into the wrong forum*
      I'm currently on Epoch 1.0.6.2 and I've been banging my head against the wall when it comes to getting my intro.ogg file to play when a  player connects to the server. 
      I've been using some of my old server scripts to try to build a new one, and I've been online searching for a current script ... but they all seem pretty old and I wonder if they are still working.  Everyone I have tried does nothing.  I've tried adding it to a welcome message/credits script and to a camera intro script but nothing happens.  Actually, I can't even seem to get my stock Server Rules .sqf to stop running.  It's getting really frustrating. 
      Then I found the server_playerLogin.sqf and I wondered if maybe I needed to script the code in here?
      If anyone knows of a current playsound / welcome credits / camera intro script, in any combination of the three or you know where I should be placing the script, I would GREATLY appreciate it.
       
      Thanks!
    • By harcosgoogle
      Hi!
       
      Ref to nonnetwork object 3c14f900# 984738: wf_barracks_east.p3d  
      Log generated /1 sec (lag generated)
       
      RPT log
    • By Schalldampfer
      https://github.com/andgregor/dayZ-AI-Bus-Route
      While testing this old script in Epoch 1.0.6.1, I got an issue:
      When I ride on the bus which an AI is driving, the bus start driving well.
      But after running about some ten or hundred meters away,
      the bus suddenly stop and damage me as if there's an invisible barrier in front of me, 
      and it starts bouncing like a football there.
       
      I want any idea to make the script works well.
      ---
      I have changed a part of init_bus.sqf from
      to
      to make it work in 1061, and player_axebus.qf to
      to make it work for any player skin.
    • By harcosgoogle
      Hi!
       
      How to fix Bug?
       
      The image is darkened,As if the character wanted to faint,darkens.
       
      Sometimes it happens,Random
       
      And: Tired of character, bad targeting too
       
      R3f?
       
      Thanks,Sorry NO SPEAK ENGLISH :)
  • Advertisement
  • Advertisement
  • Supporters
  • Advertisement
  • Discord

×