Home   Help Search Login Register  

Author Topic: My first script  (Read 1450 times)

0 Members and 1 Guest are viewing this topic.

greg_t

  • Guest
My first script
« on: 10 Dec 2002, 15:12:07 »
It's a modified FlareTrap.sqs from Chris's Script Editor. I've tried to make it loop through all west soldiers in the area and spawn a flare above them. It works but spews back an error and I can't stand things not working 100% so here I am.

The error is " _flare = _type CamCreate _posFlare" l#l error type any, expected number.
The trigger is "west detected by east, repeatedly"
This is the script:

; Get the parameters given
_trigger = _this Select 0
_color = _this Select 1
_height = _this Select 2

; Find targets to light up
_targetList = List _trigger
_numTargets = Count _targetList
_targetNum = 0

; Get the position of the targets
#List
?(_targetNum > _numTargets): Goto "Exit"
_postarget = GetPos (_targetList Select _targetNum)

; Create the position for the flare to drop (Z + 150 m)
_x = _posTarget Select 0
_y = _posTarget Select 1
_z = (_posTarget Select 2) + _height
_posFlare = [_x, _y, _z]

_targetNum = _targetNum + 1

; Create the flare
?(_color == "WHITE"): _color = ""
_type = "Flare" + _color
_flare = _type CamCreate _posFlare
CamDestroy _flare
Goto "List"

#Exit
Exit

;***********

« Last Edit: 10 Dec 2002, 15:22:13 by greg_t »

Offline Ranger

  • Members
  • *
  • Hoo-ah!
Re:My first script
« Reply #1 on: 10 Dec 2002, 19:07:26 »
I'm not 100% certain, but I think that _x, _y, and _z are reserved variables.  Try changing those variable names to see if that solves your problem.
Ranger

greg_t

  • Guest
Re:My first script
« Reply #2 on: 11 Dec 2002, 14:53:46 »
nope it appears there is something else at work, i've also found that if the flare is too low then snipers that are found get killed by the flare. is there a way to make the flare drop in a random position within "x" distance of the players?

Offline Ranger

  • Members
  • *
  • Hoo-ah!
Re:My first script
« Reply #3 on: 11 Dec 2002, 19:04:08 »
I'm not sure what's causing your error message, but to answer your latest question, use the random command.

_x = (_posTarget Select 0) + random(10) - 5
_y = (_posTarget Select 1) + random(10) - 5

This will place the flare within a random square up to +/- 5 meters from the unit's location.
Ranger

greg_t

  • Guest
Re:My first script
« Reply #4 on: 13 Dec 2002, 15:08:10 »
what is the minimum value of the random function?