Home   Help Search Login Register  

Author Topic: in thislist script, exec only for soldiers?  (Read 1267 times)

0 Members and 1 Guest are viewing this topic.

Offline Bracks

  • Members
  • *
in thislist script, exec only for soldiers?
« on: 15 Apr 2008, 03:47:45 »
Hello,
I have created a very basic sound ai script for mods which don't work with ecp which just makes units says things randomly according to their behaviour.

I exec it with the code
Code: [Select]
{[_x] exec "snds.sqs"}foreach thislist in the onactivation of a trigger with condition east present which covers the map.

Now the problem is that, vehicles with units in them exec the code as well.  So for instance, after I killed all the members of a UAZ I would still be able to hear someone shouting near by... aka the UAZ. 

I have tried afew things like using
?(typeof _unit=="UAZ"):exit; but this makes it exit on everyone in that vehicle, so i'm wondering if there is another way I can easily exec it without having to do alot of extra things like movecargos after the mission starts?

Any suggestions or advice much appreciated.  :)


« Last Edit: 15 Apr 2008, 03:50:47 by Bracks »

Offline Loyalguard

  • Former Staff
  • ****
Re: in thislist script, exec only for soldiers?
« Reply #1 on: 15 Apr 2008, 10:06:22 »
This is untested but it should work or at least get us moving in the right direction:

Code: [Select]
{{[_x] exec "snds.sqs"} forEach (crew vehicle _x)} forEach thisList;
This is a nested forEach loop.  For every iteration of _x (any unit, vehicle or person) in thisList it exec's the script for crew members of that unit if it is a vehicle and if not a vehicle the unit itself.  It should not exec the code for actual vehicles, only their crew.

Offline Bracks

  • Members
  • *
Re: in thislist script, exec only for soldiers?
« Reply #2 on: 15 Apr 2008, 13:19:06 »
Thanks for the suggestion Loyalgaurd,
At this stage however I get the error
Code: [Select]
type nothing, expected bool.
But as you say, it has given me a direction to investigate, so thanks again for that. :)

I will post here if I figure it out, if you have any other ideas/fixes feel free to add them.

Edit:thanks Loyalguard, sorry -h  :D
« Last Edit: 15 Apr 2008, 14:05:25 by Bracks »

Offline Rommel92

  • Members
  • *
Re: in thislist script, exec only for soldiers?
« Reply #3 on: 15 Apr 2008, 13:36:31 »
Where does it say the error is located?


Pssst.... watchout, h- will get you for quoting the previous post...

Offline Loyalguard

  • Former Staff
  • ****
Re: in thislist script, exec only for soldiers?
« Reply #4 on: 15 Apr 2008, 13:55:07 »
Oh my, I am off my game today...I didn't realize that this was the OFP subforum :P ...I'm sorry... Make sure you remove the ";" at the end of the code I gave....I imagine that is (at least part of) the problem.  I think the rest is proper SQS syntax.

Offline Bracks

  • Members
  • *
Re: in thislist script, exec only for soldiers?
« Reply #5 on: 15 Apr 2008, 14:03:43 »
Opps sorry, I think at the front.. atleast it moves the cursor to that postion.  Hope that is what you mean.

But I found something I don't understand..
See I just put that code into a script to try get the error location and it worked perfect with the code; no errors, could hear the voices and cars didn't talk.
Code: [Select]
?(true):{{[_x] exec "snds.sqs"} forEach (crew vehicle _x)} forEach list trignameSo the only thing that changed was that instead of thislist I put list trigname because I had too.
Now here comes the real confusing bit (for me atleast), when I put that same code into the triggers condition field (using the triggers name again), it gives me the same error as before and points the cursor at the start?  ???

Well regardless, the problem is solved as I can just launch it from the init so thanks again for your help and interest guys, but if anyone knows why this is working in a script but not a trigger it would be really helpful if you could inform as to why this is happening (probably a stupid mistake I overlooked but I did try alot of testing).

Edit: No your on your game Loyal, just i'm not :)
Turns out if I add the ";" onto the end it works.  I have never used one of them in a condition field in the past, so didn't think twice about it.
That also explains why it would work in a sqs script  :yes:

This topic is solved now, thanks very much I learned alot!
« Last Edit: 15 Apr 2008, 14:12:56 by Bracks »