Jump to content
Sign in to follow this  
KingN

Activating by gun fire

Recommended Posts

How can I make so that a trigger activates if a unit fires with a weapon?

Share this post


Link to post
Share on other sites

I dont know if you can but you can try to use the "knowabout" command

Share this post


Link to post
Share on other sites

make a trigger the size of the map and group it with the unit.

put this in a script

#start

~1

_ammo = (put the number of bullets you are wanting the player to have here)

?(_ammo == _ammo - 1):goto "start"

hint (gun fired)

Then in the onactivation field use

[] exec "nameofscript.sqs"

Where the name of the script is the name you gave it...

this will keep repeating until the unit has fired a shot.

Share this post


Link to post
Share on other sites

Rob where did you learn this, i want to know stuff like that to.

I want to make nuke's and big explosion(my own explosion)ect.

where can i find tutorials for that???

Share this post


Link to post
Share on other sites

hehe that was my script i made just a min ago, but it is real easy to learn, i didn't use any tutorials or i just learned from looking at scritps and seeing what they do.

RED

Share this post


Link to post
Share on other sites

ok,

so where should i start, what do you suggest.

Share this post


Link to post
Share on other sites

Well if you want to do some thing really easy just make a sqs. file ( by just typing the code out in note pad and saving as .sqs instead as .txt) and put the following in

~2 //(this waits 2 seconds)

hint "blah"

and all that will do is wait 2 seconds then say blah in a hint box.

You activate it by putting in a trigger's o nactivation feild, [] exec "nameofscript.sqs"

and make it activate by radio alpha.

RED

Share this post


Link to post
Share on other sites

thanx ,but im a little further than that.

well... i can only make cutscene's yet.

Share this post


Link to post
Share on other sites

You should be able to do most stuff now just get ideas from the command ref if you need them.

RED

Share this post


Link to post
Share on other sites

Like RED said its incredibly easy to make scripts once you have then idea of how they work...

Here i will make a loop for you.

_c1= _this select 0

endmove = 0

#move

c1 switchmove "fxstandtodip"

~5

? (endmove==0): goto "move"

exit

First we start of giving the unit that is going to preform the action a class which is select 0.

Then the next part is there to give a starting point like when giving a trigger "triggera=1". Its basically when one gets triggered it waits for the other before moving on.

#move is where we want to direct the script to look after it has finished its task.

We then give c1 a movement which is press ups. after 5 secs

The script checks to see if the endmove has been trigured by using a question mark... Then if endmove ==0 then go back to move so the unit repeats it all over again and again... then give the script an exit...

simple enough but thats jack shit comared to some of the scripts out there. even i aint caught on yet .lol

hope you learnt something!

biggrin.gif

Share this post


Link to post
Share on other sites

You guy's are alway's showing off...

Share this post


Link to post
Share on other sites

Thanks, that should do it! smile.gif

Share this post


Link to post
Share on other sites

If you want to learn to script, try the Mission Editing section of this site and links to other sites.

Lots of tutorials and script snippets to download are only a click away.

Share this post


Link to post
Share on other sites

Another way to count the number of ammos fired is via trigger. You will need to set up a variable with the number of ammos at the beginning of the mission, in the init.sqs, for example. Lets say the variable will be nbAmmo, in init.sqs, put

nbAmmo = unitName ammo "M16"

Then, create a trigger activated by your unit, repeatidely, with a condition field like :

(unitName ammo "M16") != nbAmmo

and in the activation field :

nbAmmo=unitName ammo "M16"; hint "Fired! Or reloaded"

I suspect triggers to be less CPU consuming than inifinite looping scripts (I'm perhaps wrong, but...), so if you have to create only one of these counters, use triggers. If you want to reuse the counter for more than one unit, the script technique is better, cause you can use parameters (in this case, the unit you want to count). The downside is : more units -> more CPU used....

Whis'

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Rob @ Jan. 05 2002,14:36)</td></tr><tr><td id="QUOTE">?(_ammo == _ammo - 1):goto "start"

hint (gun fired)<span id='postcolor'>

wow.gif

BTW: (_x == _x -1) never comes true.... unless there is something REALLY wrong with this OFP

Share this post


Link to post
Share on other sites

Wow talk about digging up the past (this thread was ages ago I think)

bn880, You are right that will not happen it was just a mistake in the post.

RED

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  

×