Jump to content
Sign in to follow this  
leop

Whats wrong with this script

Recommended Posts

Whats wrong with this script. I took it from here:

http://www.ofpec.com/editors/faq_search.php

And type: bombs

This is it:

; *** Bombing.sqs by Mike Schell ***

;

; A small script that will detonate bombs around a passed object at a given radius

;

; Usage:

;

;Syntax: [posobject, numberofbombs, timespacing, radius] Exec "bombing.sqs"

;

; posobject: The object the script will center the bombs around

;numberofbombs: number of bombs to detonate

;timespacing: delay (in seconds) between bomb blasts

;radius: maximum deviation from the center of posobject

;

; Example: To create 5 bombs that go off around the player (MyGuy) every half second

; at a distance no greater than 40 meters:

;

;[MyGuy, 5, .5, 40] Exec "bombing.sqs"

;

; Get's variables from 'EXEC' line

_marker = _this select 0

_maxbombs = _this select 1

_intervals = _this select 2

_radius = _this select 3

; Sets bomb counter to zero

_counter = 0

; Main loop

#Update

; Set up positioning for bombs

_xm = getpos _marker select 0

_ym = getpos _marker select 1

_xm = _xm + (random(_radius) - (_radius/2))

_ym = _ym + (random(_radius) - (_radius/2))

; Make explosion

_boom = "shell125" camcreate [_xm, _ym, getpos _marker select 2]

; Wait a given amount of time between blasts

~_intervals

; Increase bomb count, end if all bombs have been detonated

_counter = _counter +1

? (_counter == _maxbombs) : goto "AllDone"

; Loop it for next bomb

goto "Update"

; End script

#AllDone

exit

This is what i write to activate [name, 15, .5, 15] exec "bombing.sqs"

and when it should happen this error occurs:

exit/#l\fo\fs20\par

I'm new to scripts, but this one is made already. Whats going wrong.

Share this post


Link to post
Share on other sites

Well the script could be improved but it is not clear to me what is causing your error. When you say you call it with:

[name, 15, .5, 15] exec "bombing.sqs"

Is that exactly what you have in your mission?  If so then I think the problem is in using name.

name is an OFP command.  Look here:

http://www.ofpec.com/editors/comref.php?letter=N#name

Give the object a different name - or select a bush, get its ID and call with:  

[object xxxx, 15, .5, 15] exec "bombing.sqs"

where xxxx is the id of the bush

You should note also that the code refers to a _marker.  But you must not pass a marker name into the script because the script uses the getPos command and not the getMarkerPos command

Note also that although the script refers to the radius of where the bombs will fall:

1. the script will not drop in a circle but in a square

2. the value set for radius is actually the length of the side of the square.  So for example if radius is set to 15 (in your case) then the bombs will fall in a 15x15 square centred on the object you provide.  From the name radius you might have expected the bombs to fall 15 meters either side of the object, in other words in a 30x30 square

Have a look here for ways of selecting random locations of the map for things such as this:

http://www.ofpec.com/editors/faq_view.php?id=409

Share this post


Link to post
Share on other sites

I still learning editing, what i'm doing is putting an object like an invisible helipad or a soldier and putting its name in place of the "name" part. I'm not sure how to get an objects id or to find its position if thats even what you said. I finding it a bit hard to understand it plus those links are not working for me.

Share this post


Link to post
Share on other sites

The ofpec site is currently down that is why the links are not working. To find the ID of an object, say a bush. Go into the Mission Editor. Over on the right hand side is a button called: Show IDs (or something like that). Press the button then zoom into the map and you will see a lot of numbers. These numbers are the object IDs. Find a bush or building that is to be the centre of the bombing area note down its number. You can then refer to that object using:

object XXXX

where XXXX is the number you found

Share this post


Link to post
Share on other sites

Its still not working, I put [object 11017 , 15, .5, 15] exec "bomb.sqs" in the activation field on a vehicles waypoint and it still gives me the same error. Thanks for helping but if you can can you try to see if the script works and give me exactly the details of how you did it.

Its hard to simulate this script in another way like getting enemy units to fire shells and miss all without being detected by my side. I need this effect for my mission.

Share this post


Link to post
Share on other sites

I have had another look through the script and can't see a problem I will try and ruin it when I get home tonight

Share this post


Link to post
Share on other sites

If your getting this as an error:

Quote[/b] ]exit/#l\fo\fs20\par

Then it looks like you have some extra characters at the end of your script?

What are you using to edit the script file. Notepad or something else?

Share this post


Link to post
Share on other sites

I copied and pasted the script from the post above and ran it from the activation field of a waypoint - and it worked perfectly.

I would check UNN's suggestion. Do you have any characters after the exit?

Share this post


Link to post
Share on other sites
If your getting this as an error:
Quote[/b] ]exit/#l\fo\fs20\par

Then it looks like you have some extra characters at the end of your script?

What are you using to edit the script file. Notepad or something else?

I used wordpad but i didn't edit it i just copied+paste it in there.

That is exactly the error i'm getting.

Share this post


Link to post
Share on other sites

Thanks heaps guys, i caught on and used notepad and it works( it blew me to bits). I didn't know you couldn't use wordpad. confused_o.gif

Thanks again, for the tips and everything. wink_o.gif

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  

×