Jump to content
Sign in to follow this  
frosties

Help with a "IF" script

Recommended Posts

Hello,

I have a script that allows the player to deploy a tent, and it spawns a camounet over it.

However, if another player would like to put their tent under my net i need a IF.

Something like:

IF there is any camounetclass within 50 meters dont spawn a new one...

My spawn code looks like

gc_med_tent_tent_camou = "Land_CamoNetB_EAST_EP1" createvehicle [0,0,0];

How do i do to put a IF section before this?

Share this post


Link to post
Share on other sites

_nearTent = nearestObjects [player, ["Land_CamoNetB_EAST_EP1"], 50];
if (count _nearTent < 1) then {
   gc_med_tent_tent_camou = "Land_CamoNetB_EAST_EP1" createvehicle [0,0,0];
};

be aware that your createVehicle code creates the object at 0,0,0 coordinates and not on top of the tent. You will have to grab the position of the tent and pass it to this script.

Share this post


Link to post
Share on other sites

In the createVehicle command, use the CAN_COLLIDE switch to allow the tent and camp being created in the same place.

Share this post


Link to post
Share on other sites

EDITL Ninja'd.

Try this using nearestObject and isNull

//Find the nearest tent within 50m/
_nearestNet = nearestObject [[0,0,0], "Land_CamoNetB_EAST_EP1"]; // Enter position as desired.

// If there is NO net within 50m, then spawn a new net.
if (isNull _nearestNet) then
{
gc_med_tent_tent_camou = "Land_CamoNetB_EAST_EP1" createvehicle [0,0,0];
};

Edited by Loyalguard
Edit...removed ! from isNull

Share this post


Link to post
Share on other sites
_nearTent = nearestObjects [player, ["Land_CamoNetB_EAST_EP1"], 50];
if (count _nearTent < 1) then {
   gc_med_tent_tent_camou = "Land_CamoNetB_EAST_EP1" createvehicle [0,0,0];
};

be aware that your createVehicle code creates the object at 0,0,0 coordinates and not on top of the tent. You will have to grab the position of the tent and pass it to this script.

The tent is spawning on top of the tent, so that part is working.

The thing is that i dont want any other tent that is Deployed in the same area ALSO should deploy camounet since they can share the big one that spawns.

Shall look into the different suggestions.

Thanks guys!

EDIT:

The proposed script wont work.

How about if i add the option to manually deploy the tent?

I have a script on a humvee i tried but it complained about a missing ";" somewhere, but cant figure out where in the script it is:

gc_med_tent_act_id_pack_tent = gc_med_tent_tent this setVariable ["CamoDeployed", false, true];  this addAction ["Deploy camouflagenet", "scripts\camo.sqf", ["Deploy"], 51, false, true, "", "!(_target getVariable 'CamoDeployed') && !(_this in _target)"];  this addAction ["Stow camouflagenet", "scripts\camo.sqf", ["Stow"], 50, false, true, "", "(_target getVariable 'CamoDeployed') && !(_this in _target)"];

It is workin "as is" on the humvee, in the init of the vehicle.

Edited by Frosties

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  

×