OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: 456820 on 26 Oct 2005, 10:31:36
-
okay i downloaded a script it was at a beta stage but it also worked
but i keep getting an error at the start of my mission from this part of the script
_list = _this
_count = count _list
_i=0
#loop
(_list select _i) addEventHandler ["fired",{_this exec "fired.sqs"}]
_i = _i + 1
?(_i < _count ):goto"loop"
that should add an event handler to every unit in game to load a script called fired.sqs which sets a different velocity to each round they fire making more realistic rifles
but i get some error about this line
(_list select _i) addEventHandler ["fired",{_this exec "fired.sqs"}]
i never had it in the demo mission so why should i have it now ? i copied all triggers and everything from the demo mission into my mission but i get an error
is there something wrong with the syntax and if so why did it not work with my mission but does in the demo mission
thanks
-
(_list select _i) addEventHandler ["fired",{_this exec "fired.sqs"}]
I believe that it should be
...{this exec "fired.sqs"}...
Not sure though. :-\
-
I guess you're executing the script with the required values in a wrong format or just the wrong values.
But I would like to know your line that calls the script and the error message. - Try to shorten the line to getdir (_list select _i) or something so you can read more of the message.
-
i think i may of fixed it
it said error zero divisor i removed the space so it said this
(_list select _i) addEventHandler["fired",{_this exec "fired.sqs"}]
instead of
(_list select _i) addEventHandler ["fired",{_this exec "fired.sqs"}]
and its got rid of the error but im not sure if the scipts actually running
-
How are you calling the script?
-Pilot
-
im calling it from a trigger in game which is anybody present once
condtion this
activation
thislist exec"init_event.sqs"
thats it it should add an event handler to every unit in the game
-
You do have brackets around thislist, right? eg,
[thislist] exec "init_event.sqs"
Also, in the script, try something like:
_list = _this select 0
That's the way I always do it and it always works for me, unless calling arrays uses a different format.
-Pilot
-
nope no brackets thats how it came in the demo mission and it worked fine there
its exactly how its shown
ill have ago your way
-
You do have brackets around thislist, right? eg,
[thislist] exec "init_event.sqs"
Also, in the script, try something like:
_list = _this select 0
That's the way I always do it and it always works for me, unless calling arrays uses a different format.
-Pilot
No need for an array if you only have one argument. That's what the brackets do, they give you an array. Array of one variable is kind of pointless...? Of course an array variable can also be "one argument".
:P
If you use brackets for one argument, OFP has to create an array to hold the one argument, then OFP passes the array to the script and then you need to force OFP to pick the only item from the newly-created array by using select. Sounds like an overkill for just one argument.
Just a hint to reduce typing when you write your scripts... and OFP likes it too when your script statements are shorter.
:)
-
i think i may of fixed it
it said error zero divisor i removed the space so it said this
(_list select _i) addEventHandler["fired",{_this exec "fired.sqs"}]
instead of
(_list select _i) addEventHandler ["fired",{_this exec "fired.sqs"}]
and its got rid of the error but im not sure if the scipts actually running
You could try (_list select _i) fire (primary weapon (_list select _i)) or something similar to find out.
I've got the feeling the removed space only creates an unknown/not wrong situation for the debug messages.
Does the # mark the error at _list? Your script call looks good, but this error is likely for situations were the script doesn't find the array the user expected. To have a look at the actual array, execute the test line hint format ["%1",_list] in your script. - It should display the array content in a hint. If your OFP crashes to desktop, make the size of the trigger smaller for this test.
Maybe the real problem is located in filling the thislist array with unit names, because of not working trigger settings.
-
@Baddo
That's interesting, I never would have though of that. Very interesting...
Thanks for the clarification :-*
-Pilot
-
Does your trigger cover the entire map?
--Ben
-
yep
x and y axis are both 99999
thats hwat i do with all my triggers which need to cover the whole map and they seem to work
a way of getting this to work easier is there away of just one line to add an event handler to every unit with in
allunit
as in
allunit = thislist
in the activation of a trigger i could put that in the init.sqs to run the event handlers it would save all this on the script
cheers