Jump to content
Sign in to follow this  
MadMonk

Trouble with a script for a deployable sensor

Recommended Posts

Hello folks, Im new to scripting and have been playing with a few ideas but this one has really got me stumped.

I've been experimenting with a script for a deployable sensor. From my current understanding, I am trying to create an in game trigger that is activated when I select ‘Enable Sensor’ from sensors actions menu, this trigger is to fire when anyone is in range and currently displays a text message about its state(I hope to have a localized audible). At the moment I'm using a satellite radio briefcase , a friend is creating a proper model for this .

The situation is, I can pick up the case, move it and drop it, then enable the sensor. Doing this, the trigger is permanently activated, no matter where I am in relation to the case. If I go over and pick up the case doing nothing else, the trigger then functions as I would expect and if I enter the zone where the case was, it triggers and deactivates when I leave the zone.

What I would like to do is be able to drop the case, activate and deactivate the sensor. The next step is to have multiple sensors triggerable in an internet hosed game.

I have added the following script to the objects (satellite radio) initialization section.//Actions - Initialization of sensor

take=0;

act1 = this addaction ["Take Sensor","Carry.sqf","",1,false,true,""];

act2 = this addaction ["Enable Sensor","sensorBallON.sqf","",2,false,true,""];

act3 = this addaction ["Disable Sensor","sensorBallOFF.sqf","",3,false,true,""];

This is the drop and pickup script copied form another post on the forum

//Carry.SQF

switch (take) do

{

case 0:

{

_scase = _this select 0;

_man = _this select 1;

_scase attachto [_man, [0.035,-.055,-0.22], "LeftHandMiddle1"];

_scase setdir 90;

_scase removeAction act1;

act1 = _man addaction ["Drop Sensor","carry.sqf","",1,false,true,""];

take=1;scase = _scase;

};

case 1:

{

_man = _this select 0;

detach scase;

detach _scase;

scase setvelocity[0,0,-.3];

_man removeAction act1;

act1 = scase addaction ["Take Sensor","carry.sqf","",1,false,true,""];

take=0;

scase = _scase;

};

};

//SensorBallOff.SQF (Deletes the trigger)

hint "SensorBall Off";

deleteVehicle trg;

This creates the trigger ( I have assigned markerobj variable to the player position by creating a copy of the variable because I thought that directly referring to player pos meant that the trigger position would continually update with the player position. My understanding of this is limited at the moment.

//SensorBallON.SQF

markerobj = +getpos Player;

deletevehicle trg;

trg=createTrigger["EmptyDetector",markerobj];

trg setTriggerArea[10,10,0,false];

trg setTriggerActivation["Any","PRESENT",True];

//trg setTriggerTimeout [5, 5, 5, false];

trg setTriggerStatements["this", "hint 'Alarm'", "hint 'Clear'"];

Share this post


Link to post
Share on other sites

markerobj = +getpos Player; there's no need for the plus sign.

The trigger would need to be attached to the player and you would need to exclude the player from the trigger.

I'd use something like this, it will return the units found in the hint excluding the player and it will move with him that is if you want it to move with the player. If not just move markerobj = getpos player; to ouside the while.

If you do want to detect the player just remove - (nearestobjects [markerobj,["man"],1])

You could use a simple true/false variable called through sensorBallOFF.sqf to turn it off.

sensor = off;

save as sensorBallON.sqf

sensor = true; // on by default
while {sensor} do {
markerobj = getpos player;
_who = (nearestobjects [markerobj,["man"],50 ]) - (nearestobjects [markerobj,["man"],1]);
hintsilent format["%1",_who];
sleep 0.5;
};

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Thanks F2K, I've just tried this and it works great. My friend has finished the sensor now so it looks like we're nearly done.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×