Home   Help Search Login Register  

Author Topic: Flare support script gives errors  (Read 2001 times)

0 Members and 1 Guest are viewing this topic.

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Flare support script gives errors
« on: 02 Jan 2006, 00:52:23 »
Hello, Triggerhappy helped me make this script but he had to go on vacation so cant help fix the errors.

It is suposed to use a trigger to detect the player and the script finds out which group detected him, and then a flare shoots up over the the group that detected the player and 2 or 3 support groups from a support array come the assist in hunting down the player.

Code: [Select]
;array for grup leaders of the detecting group
_aleaders=[(agl1),(agl2),(agl3)]

;array for available supporting groups
_support=[supg1,supg2,supg3,supg4]

;finds what group detected the player
_mindis = 999999
"?_x distance player < _mindis:_mindis = _x distance player;_x = _closest" foreach _aleaders
_flarepos = getpos _closest

;sends up a flare over the detecting group
_flare="Flare"camcreate [getpos _closest select 0, getpos _closest select 2, (getpos _closest select 2)+10]
_flare setvelocity[0,0,50]

;chooses 2-3 random groups out of support and sends them over to the flare position
_r = (random 1) + 2.5
_r = _r - (_r mod 1)

#loop
_r = _r - 1
_c = (count _support)
_i = (random _c)
_i = _i - (_i mod 1)
_grp = _support select _i
_grp move flareposition
_support = _support - [_grp]
?_r = 0:exit
goto "loop"

does anybody see anything that could be causing an error.

thanks

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re:Flare support script gives errors
« Reply #1 on: 02 Jan 2006, 01:58:25 »
Change
_x = _closest
by
_closest = _x

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:Flare support script gives errors
« Reply #2 on: 02 Jan 2006, 05:51:05 »
i still get an error

Code: [Select]
_flare="Flare"camcreate [getpos _closest select 0, getpos _closest select 2, (getpos _closest select 2)+10]|#| error type any expected number

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Flare support script gives errors
« Reply #3 on: 02 Jan 2006, 06:16:00 »
You have a typo there:

_flare="Flare"camcreate [getpos _closest select 0, getpos _closest select 2, (getpos _closest select 2)+10]

Should be 'select 1' I think.


Planck
I know a little about a lot, and a lot about a little.

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:Flare support script gives errors
« Reply #4 on: 02 Jan 2006, 20:05:12 »
oh, your right! thank il see if that fixes it.

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re:Flare support script gives errors
« Reply #5 on: 02 Jan 2006, 21:43:24 »
The typo should not return that error message. The mistake comes from that line :

Code: [Select]
"?_x distance player < _mindis:_mindis = _x distance player;_x = _closest" foreach _aleaders

I'm not sure what you want to do here, but _closest is a "scalar bool array string 0xfcffffef".


[edit]
The same will be true with _closest=_x
[/edit]
« Last Edit: 02 Jan 2006, 21:44:51 by Igor Drukov »

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:Flare support script gives errors
« Reply #6 on: 03 Jan 2006, 02:28:16 »
so what would I do to fix it.


that part detects what group leader is closest to the player.

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re:Flare support script gives errors
« Reply #7 on: 03 Jan 2006, 08:01:59 »
No time to explain this in detail right now, but what you have to do is store the different distances into an array, and then SortBubble them.

Let me know if this sounds too much like Chinese :P

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:Flare support script gives errors
« Reply #8 on: 08 Jan 2006, 23:30:36 »
I dont understand this. how do you work it

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Flare support script gives errors
« Reply #9 on: 09 Jan 2006, 05:24:21 »
Code: [Select]
_mindis = 999999
_i = (count _aleaders)
#loop
_i = _i - 1
_m = _aleaders select _i
?(_m distance player) < _mindis:_mindis = (_m distance player);_closest = _m
?_i > 0:goto "loop"

i thought it would work in a foreach, but i guess not
this will find it (just tested the code) its the same thing as the foreach, just in a loop
« Last Edit: 09 Jan 2006, 05:24:59 by Triggerhappy »

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Flare support script gives errors
« Reply #10 on: 09 Jan 2006, 07:39:36 »
i thought it would work in a foreach, but i guess not
this will find it (just tested the code) its the same thing as the foreach, just in a loop
Code: [Select]
_minDist = -1;
_closest = objNull;
{
    _distance = _x distance player;
    if ((_distance < _minDist) || (_minDist < 0)) then {
        _minDist = _distance;
        _closest = _x;
    };
} foreach _aleaders;
If this is for use in a script then collapse the contents of the foreach to one single line.

A value of _closest = null results if _aleaders was empty.
« Last Edit: 09 Jan 2006, 07:40:25 by Fragorl »

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Flare support script gives errors
« Reply #11 on: 09 Jan 2006, 22:35:57 »
if _mindist is -1 then nobody will ever be found because they have to be a closer distance than _mindist

but looking at your code, it seems as though the only thing you're doing different is defining _closest as a null obj before assigning it to the person in a loop, correct? if so, is that a bug in the foreach command? (normally you can define variable without initializing them (i.e. _unit = _this as opposed to _unit = objnull;_unit = _this) )
« Last Edit: 09 Jan 2006, 22:36:22 by Triggerhappy »

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:Flare support script gives errors
« Reply #12 on: 14 Jan 2006, 02:34:45 »
ok, so, what would I need to do to make it work.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Flare support script gives errors
« Reply #13 on: 14 Jan 2006, 03:35:53 »
my respone should work (post 9)
knowing frag his will probably work too but he hasn't answered about my questions so use mine for now

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:Flare support script gives errors
« Reply #14 on: 21 Jan 2006, 02:04:39 »
Get another error.

Code: [Select]
_m = _aleaders select _i

it says, error, zero divisor