Jump to content
Sign in to follow this  
iceman11a

Running scripts from a trigger

Recommended Posts

What I been trying to do. Is run a script from a trigger. That way when a group or unit enters the trigger. A chain of events start. Can some one tell me how to do that.

In a trigger, when hummer1 enters the trigger. tr1 and tr2 I need to move to another location or point on the map. This is where I'm having the problems at. tr1 and tr2 are supply trucks. In the trigger. It only allows for BluFOR or OPFor. I didn't see an option for just one unit or a unit by name.

does any one have some ideas on what to do,

Iceman11a

Share this post


Link to post
Share on other sites

Use the search here, use google:

http://forums.bistudio.com/showthread.php?t=93846

As for the triggers, if I understand you correctly you want them move to another location on activation. That should be doable with just a TriggerName setPos [x,y,z] in the 'on activation' field and an activation setting of 'repeatedly'.

Edited by Weirdo10o4

Share this post


Link to post
Share on other sites

Iceman, if you use the Group tool (F2) and group the Hummer with the trigger, there will then be an option in the trigger activation for 'Vehicle Present'. Now when that particular vehicle is in the trigger, you can run your script.

Share this post


Link to post
Share on other sites

Well I got the group thing to work. Just where do I add in the name of the script that I want to run. I don't see an option for that nor can I add it in the other fields.

Share this post


Link to post
Share on other sites
Use the search here, use google:

http://forums.bistudio.com/showthread.php?t=93846

As for the triggers, if I understand you correctly you want them move to another location on activation. That should be doable with just a TriggerName setPos [x,y,z] in the 'on activation' field and an activation setting of 'repeatedly'.

You are close. See the idea is that this is in the script. see when

? m1 //Means if true and it does when hummer1 is in that trigger

tr1 move position to_something //I need then to go to another way point

tr2 move position to_something // or to_something

right now I just need to find out where I enter the script name so that it runs the script.

Share this post


Link to post
Share on other sites

Remember if you run a script from a trigger it'll run on all clients, and the server, so if you're spawning something and not limiting which client runs it you'll run with a lot of extra spawns for example.

Share this post


Link to post
Share on other sites
Remember if you run a script from a trigger it'll run on all clients, and the server, so if you're spawning something and not limiting which client runs it you'll run with a lot of extra spawns for example.

Oh I know I ran into the problem in the OA demo. :D I just wanted to spawn a few guerillas in the camp, but we ended up being massacred since we I had like 10 playing.

Share this post


Link to post
Share on other sites

Nope. It's for a single player mission. I just want to be able to do some thing like I have in the passed with other games that I mapped for. The idea is to get them to go to some thing. How ever what?. I can't get them to go to a waypoint. So any ideas from any one would be great..

oh and I will need to know how to use the if statement

Edited by iceman11a
forgot some thing

Share this post


Link to post
Share on other sites

@iceman11a

You cant expect to be able to do everything at first without researching on your own.

for example if statements can be found on wiki with thorough explanation.

also look at other peoples scripts, together with looking up the commands used on wiki.

dont skip basic effort just because you dont want it, it will simply not work.

And put in an effort in search before posting, btw that is a forum rule.

Share this post


Link to post
Share on other sites

Dude, searching the forums section and google is not every ones dream, Why, because we don't want to have to look threw 100's of pages just to find one pc of information. Your using Vbulletin. why don't you setup an Articles or Knowledge base and put all this crap in there. Make it easy to find. Make categories for every thing and then add them. I can tell you right now. I spend more time searching in google.com then I play games. And when I do a search in the forums section. It gives me every thing related to my search. So if I do "arma 2 if statement". It will give me 100's of pages on Arma 2 and nothing about what I'm looking for.

Just make it easy for us. I'm new at this and so are 1000's of others too.

Share this post


Link to post
Share on other sites

It's just the nature of the beast mate. I've been doing this for many years and still look stuff up everyday. You are not going to get away from that.

Yes... it can be extremely frustrating.... we've all been there and so understand your pain. Don't be too ambitious, start with baby steps and if you stick with it... you'll get there.

Experiment in the editor and with code. Break your problem down.... maybe make a separate mission just to sort out your problem and then integrate that code into what you are working on.

I don't think I have ever asked a question in these forums.... not once... and have found out everything I need to know by searching, reading and trying hard to understand.

Learning how to use "if", "while" etc. is not hard if you examine other peoples code. It will take ten minutes of your time.

Here again is a link to all the commands... I say again because this link is everywhere in these forums. Scripting Commands.

Don't mean to be harsh.... but if you can't grasp the basics then maybe Arma 2 scripting is not for you.

Share this post


Link to post
Share on other sites

Have actually been able to call the script yet the answer was in post 11.

but if all your after is to make two trucks move to a position when the hummer is within a trigger the script could look like this.

Place a gamelogic on the map and name it pos1

place this in the on act of the trigger

null=[tr1,pos1] execvm "move_truck.sqf";

save the script as move_truck.sqf

_unit = _this select 0;// this will be the truck
_pos = _this select 1;// this is the position it will move to

_unit domove getpos _pos; 

That will move one truck, you should be able to work out how to do more..

Edited by F2k Sel

Share this post


Link to post
Share on other sites

F2k, Thanks..

1) Yes I fount out how to use the if statements. I had to go threw 100 + pages to find it. and it does work. A question. So I take it. I can't domove to a waypoint I guess, Right.

2) I all so fount out how you option works. That is a cool idea. It's just the convoy doesn't act like a convoy. It looks like 3 guys who don't know how to drive. There has to be some way to keep then in line.

I hope I can find a sample of a convoy, It's just they all are using a map I don't have.

---------- Post added at 12:11 AM ---------- Previous post was Yesterday at 11:02 PM ----------

Guys if any of you are still watching this post. How do I get the bomb to go bomb.

hint "What the hell..";

sleep 5;

_bg1 addmagazine "pipebomb";

_bg1 fire ["pipebombmuzzle"];

_bg1 action ["TOUCHOFF", _bg1];

the doc's say this is right and it doesn't work.

Edited by iceman11a

Share this post


Link to post
Share on other sites

Give it time.

// null=[bomber] execvm "boom.sqf";
_bg1 = _this select 0;

_bg1 addmagazine "pipebomb";
sleep 1;
_bg1 fire ["pipebombmuzzle"];
sleep 1;
_bg1 action ["TOUCHOFF", _bg1];

Share this post


Link to post
Share on other sites

F2k, does it matter who sets the pipebomb and who fires it. It doesn't work. That's why I'm asking. or is there a limit to what I can put in here null=[bomber,?,?,?,?] execvm "boom.sqf";

Share this post


Link to post
Share on other sites

Bomber is the name of the unit you want to plant and set off the bomb. In Sel's example, the script is executed from somewhere like a trigger with this line null=[bomber] execvm "boom.sqf"; Seriously dude, not trying to be an ass but you really need to do some reading about scripts. Your original script doesn't work because _bg1 is not the name of a unit, it is a variable name (unless you knew that already :o) . To simply make a named unit plant the bomb you need to do NameOfUnit fire ["pipebombmuzzle"]; etc.

Edited by 2nd Ranger

Share this post


Link to post
Share on other sites

No, I'm sorry but _bg1

it is the name of the unit. I add a unit and gave the unit the name of bg1.

Here's my code from top to bottom.

//null = [tr1,pos1,tr2,pos2,bg1] execVM "script_m1.sqf";
_unit1 = _this select 0;// this will be the truck 1
_pos1 = _this select 1;// this is the position it will move to
_unit2 = _this select 2;// this will be the truck 2
_pos2 = _this select 3; // This is the position of 2nd truck will move too
_bg1 = _this select 4; //The enemy

hint "Locals a head";

if (h1) then {

_unit1 setVelocity [25, 0, 0];
_unit2 setVelocity [25, 0, 0];

_unit1 domove getpos _pos1;
_unit2 domove getpos _pos2;

sleep 30;

hint "What the hell..";
sleep 5;

_bg1 addmagazine "pipebomb";
sleep 1;
_bg1 fire ["pipebombmuzzle"];
sleep 1;
_bg1 action ["TOUCHOFF", _bg1];

};


And like I was saying before. That I haven't come a crossed any thing yet that explains scripts. Just samples on how to use them. The link I got before has all the scripts codes and samples. How ever it doesn't explain how to use the code. Any limits if any and so on. SO until I can find some thing that will teach me what I need to know. I'll be posting again.

Share this post


Link to post
Share on other sites

Unless h1 has been set to true it will never execute the main body of the code other than that it works.

I don't see the need for H1 though and why the velocity command?

You placed some object or gamlogics and named then pos1,pos2 so they can move.

As for tutorials are a few in the listed in the sticky threads at the top of the forum, I will say that som of the more in depth ones are a little out of date as they are written for OFP and explain how to script in sqs rather than sqf but a lot of it is still valid.

I would say that all that script could be done in the editor when you know how to make full use of it.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Ok, let me explain this to you. See the h1. is set to true in the trigger. When the hummer1 hits the trigger. h1 is true and the script runs.

and the if (h1) then {

makes sure that the hummer1 is where it should be. and the velocity is some thing I was trying to get the hummer1 and tr1 and tr2 to move better, with out the need to start and stop all the time. That just looks crappy when I see the Hummer and Trucks moving like that

and Yes the gamlogic's are in place and they do work. So far. I was about to try again

Share this post


Link to post
Share on other sites

if the hummer enters the trigger you and null = [tr1,pos1,tr2,pos2,bg1] execVM "script_m1.sqf"; is in the on act of the trigger h1 is't needed.

If you place the call code in the a units init it still won't work as you want, it would run the code and see h1 was false and end.

For that you would need to use waituntil {h1};

Share this post


Link to post
Share on other sites

Thanks. I took the h1 out and all I do is run the script. Now I can't get the tr1 and tr2 to go to the positions like I want them too. So I'm confused.

See the idea is that when the hummer reaches the trigger. The hummer blows up and all hell breaks lose.

This is at the air port. When the hummer blows up. So do some planes and so on. Then 1 A-10 fighter bomb the units and tanks coming in on the air field. The player and other units have to stop foot patrols from entering the air field that try and take over.

Share this post


Link to post
Share on other sites
Try this see if it works, timings not right but it does work. you have got a thirty second delay.

http://www.sendspace.com/file/jcyhs0

well since you map is not what I have, and the setup is not the same. I desided to send it to you. This will give you a better idea of what I'm trying to do. When the helo's land. Watch for the convoy.

http://www.mediafire.com/?23vccxjo53tdqht

Share this post


Link to post
Share on other sites
well since you map is not what I have, and the setup is not the same. I desided to send it to you. This will give you a better idea of what I'm trying to do. When the helo's land. Watch for the convoy.

http://www.mediafire.com/?23vccxjo53tdqht

Tested it and there were a few minor problems.

1. the trucks need a little more space around the choppers or they won't complete the move.

2. You don't need in thislist when grouping the trigger to the hummer1

3. You can't use the pipebomb inside the hummer, I assumed he was outside.

I'll take a better look tonight as some things could be made simpler.

http://www.sendspace.com/file/f40l87

Updated version less triggers and code and no need for bg1 to exit the hummer.

I removed velocity as it's not doing what you think.

You don't need to set every waypoint to safe, they will stay that way until told to change.

http://www.sendspace.com/file/k40r12

Edited by F2k Sel

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  

×