Jump to content
Sign in to follow this  
Cronan

Activate trigger with object created using addWeaponCargo

Recommended Posts

Hi all,

Firstly, thanks to the community (especially the regulars) for providing a depth of information about these games which is unrivaled. Also, I apoligise if this has been asked but I have searched extensively.

I am spawning EvMoney through a trigger and I want to name the money to enable a trigger to be activated once it has been placed in an area. I have no issue creating the object, but then can not seem to name it in order to activate the second trigger. So far, the first trigger's onAct reads like this:

money1 = "weaponHolder" createVehicle (position placeholder); money1 addWeaponCargo ["EvMoney", 1];
//where "placeholder" is a a small tin can.  I have tried to name the money using setVehicleVarName but I'm assuming this has not worked as EvMoney is not a vehicle?

money1 = "weaponHolder" createVehicle (position placeholder); money1 addWeaponCargo ["EvMoney", 1]; money1 setVehicleVarName "money01";

My next trigger's condition is set to "anybody" and "present" and reads:

isServer && EvMoney in thisList;
// I have also tried using what I have named the object ("money01") but this does not work.

isServer && money01 in thisList;

Any input as to where I am going wrong (if my idea is even possible) would be greatly appreciated.

Share this post


Link to post
Share on other sites

A trigger won't detect an object unless it's grouped to that object. Some items can't be grouped to a triggers and I have a feeling weaponholder may be one of them.

So I would suggest just using a distance check

isServer && money1 distance  thistrigger < 10

also any reason your using money1 for the weapon holder and money01 in the trigger?

Share this post


Link to post
Share on other sites

Also EvMoney isn't a weapon, it is a vehicle. Therefore it cannot be used via addWeaponCargo.

Share this post


Link to post
Share on other sites

Thanks for the replies. I changed the trigger to a distance check as you suggested F2k sel, but it did not activate. The reason why I tried naming the money "money01" was to see if I could activate the other trigger once the money was moved into it's area over the other side of the map. But I removed this line as I know it wont function because of the fact that EvMoney is not a vehicle.

I tested the function of the trigger by placing a single EvMoney through the editor (Empty/Objects(small)/Evidence (money)) and named it "money01". The second trigger is set to "Anybody" present activation, the type set to "switch" and the condition reads:

isServer && money01 in thisList;

This detects the object, but the issue is there is no option to pick-up the money (it's just a static object). I know there are scripts around to collect evidence and/or add actions to objects so I'll have to check it out.

Maybe the solution is to place the money in the editor well off the map and have it moved to that point once the first trigger is activated using setPos. The whole point is that I want anybody to be able to pick up the money, but I only want the money to spawn if and when a particular individual enters the trigger area. The money then needs to be delivered to another location (where the second trigger is).

Share this post


Link to post
Share on other sites

I see whats wrong, when you take the money it gets the name removed when dropped again.

You are going to have to use addactions but check to see what scripts you can find.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

FYI, I tested it and it worked for me. By that I mean, the money was created at the location and the trigger detected it, then I was able to pick it up.

As for delivering it to another location, I tried using nearestObjects etc to detect when the money is dropped but it is not detected. The money is a weird case because it seems the gear item has the same name as the static object, but it is the only one of the evidence items that appears as a model when you drop it. The other items, map and notebook etc, appear as a satchel when you drop them, like ammo. It would be easier to do if you had to 'deliver' the item into a crate or a vehicle or something, because then you could simply check for the item in cargo.

But adding an action to the static money object and then having an action to drop it would work just as well.

Share this post


Link to post
Share on other sites

It suddenly dawned on me to check for the item you need to look in the weaponholder.

create your money

money1 = "weaponHolder" createVehicle (position placeholder); money1 addWeaponCargo ["EvMoney", 1];

in the trigger

10 10 size

anybody present

repeating

cond

round (time %1) == 1 and player in thislist

on act

things=nearestobjects [thistrigger,["weaponholder"],10] select 0;
actualthing = ((getWeaponCargo things) select 0)select 0;
if (actualthing == "EvMoney") then {hint "found it"}

How practical this is who knows but for a simple one off object it works.

Share this post


Link to post
Share on other sites

Thanks for the replies. F2k Sel, I'll give your code a try but what I have ended up with is something similar to what 2nd Ranger suggested.

--------------------------------------------------------------------------------

Firstly, I place an empty ammo box (ACE transport box) and named it "moneybox1".

I then placed a trigger (6*8 rectangle) which is grouped to the individual and set to "present", "switch". It reads:

Condition

isServer && this;

On Act.

moneybox1 addWeaponCargo ["EvMoney", 4];

This way the EvMoney will only appear once the designated individual is within the trigger area, after which it can be picked up by anybody.

----------------------------------------------------------------------------

I then placed a second empty ammo box and named it "moneybox2".

Initialization:

this addAction ["Secure crate","secure.sqf"]; crateUser = objNull

---------------------------------------------------------------------------

I then place a trigger (0*0) with Activation set to "None" and type set to "End 6".

Condition

isServer && crateUser in thisList;

-----------------------------------------------------------------------------

The secure.sqf reads as:

private ["_ammoBox"];
if (isServer) then
{

//Get the crate parameter given
_ammoBox = moneybox2;

//Empty crate of stock items - clear any items placed in the crate
clearMagazineCargo _ammoBox;
clearWeaponCargo _ammoBox;

//Secure - delete - the crate
deleteVehicle moneybox2;

};

So the idea is that the players fill the second ammo box with the cash and then "secure" it, which deletes the crate and prevents the opposition from gaining access to the money.

----------------------------------------------------------------------------------------------------

Finally, I just have a trigger grouped to "moneybox2" with it set to "Not Present" and "Switch".

Condition

isServer && this;

On Act.

if (side player == resistance) then {hint "The money has been delivered.  It better be all there!.";};

It is for an in-house mission so it does not have to be as highly polished as it would need to be if we were playing with strangers. The above set-up seems to work fine, although anybody can "secure" the crate at any time.

P.S.

2nd Ranger - I have attempted to detect whether the EvMoney has been placed in the second ammo box using hasWeaponCargo but it does not seem to detect it. It may be my scripting (although no errors are coming up) or it could be that EvMoney is just an oddity in ArmA - part weapon, part object...

Edited by Cronan

Share this post


Link to post
Share on other sites

If you were going to go the original route then I'd use F2k sel's solution, but for the crate thing you can check for cargo like this:

(Variable moneyDelivered must be declared false somewhere if you want to use it)

_nul = [] spawn { 
   while {!moneyDelivered} do {
       for "_i" from 0 to (count ((getWeaponCargo moneybox2) select 0) - 1) do { 
           if ( ((getWeaponCargo moneybox2) select 0) select _i == "EvMoney" AND ((getWeaponCargo moneybox2) select 1) select _i == [color="#FF0000"]1[/color]) then {moneyDelivered=true; publicVariable "moneyDelivered"} else {false} 
       };
   sleep 0.5;
   }; 

sleep 0.5;
hint "Money delivered!";

};

That's for one lot of money, change the highlighted value to detect more.

Share this post


Link to post
Share on other sites

If you were going to go the original route then I'd use F2k sel's solution, but for the crate thing you can check for cargo like this:

(Variable moneyDelivered must be declared false somewhere if you want to use it)

Where would you consider the best place to declare it false? Should I include it in moneybox2 init? And should I just use your code as a script and execute it from moneybox2?

Thanks again for your help guys...

Share this post


Link to post
Share on other sites

This has worked a treat. Thank you!

Just to clean up the thread - here's what I did:

1. Placed an (empty) ammo box down and named in "moneybox1".

2. Placed a trigger down, grouped it to the particular individual I want to be able to activate it, set it to "Present" and "Switch", and had the following:

Condition

isServer && this;

On Act

moneybox1 addWeaponCargo ["EvMoney", 4];

3. Placed another (empty) ammo box down and named it "moneybox2".

In the init field I have:

moneyDelivered = false; nul = [cache] execVM "money.sqf"; 

4. "money.sqf" includes the following script from 2nd Ranger:

_nul = [] spawn { 
   while {!moneyDelivered} do {
       for "_i" from 0 to (count ((getWeaponCargo moneybox2) select 0) - 1) do { 
           if ( ((getWeaponCargo moneybox2) select 0) select _i == "EvMoney" AND ((getWeaponCargo moneybox2) select 1) select _i == 4) then {moneyDelivered=true; publicVariable "moneyDelivered"} else {false} 
       };
   sleep 0.5;
   }; 

sleep 0.5;
hint "Money delivered!";

sleep 3;
deleteVehicle moneybox2

};

So, when moneybox2 is filled with 4 EvMoney (select _i == 4) it provides a hint to all players that the money has been delivered. I then added a 3 second sleep before it is deleted.

The amount of money can be altered through changing the number in (select _i == 4).

That seems like a simple way to include money in your missions.

Edited by Cronan
typo

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  

×