Home   Help Search Login Register  

Author Topic: MY first script!!!! : ) problem though  (Read 685 times)

0 Members and 1 Guest are viewing this topic.

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
MY first script!!!! : ) problem though
« on: 01 Dec 2004, 01:36:06 »
hello,
this i a very happy day for me as ive started writing my first script : )

ive run into a prob though, i cant get it to work?
does anybody see anything that might be wrong.

as this is my first script i am completly ready for any critisism that anybody has. i would not be any less happy even if you say" this is the shityist script ive ever seen"

there is one thing though. i do not want anybody to say "you dont need to make this, its already been done"*link* "check here"
 that would upset me.

anyways here it is, anybody see the problem im all ears, er eyes i mean.

Code: [Select]
tgt = _this select 0
man = _this select 1
shooter = _this select 2
weap = _this select 3

; start the target loop
Target loop#:
tgt setpos getpos man +1.5
~2
goto"Target loop#"

;start the suppress loop
Suppress loop#:
shooter dotarget tgt
shooter dofire "Full Auto,weap"
~1
man sidechat"Under heavy fire!"
~1
man setunitpos"DOWN"
man set combatMode"BLUE"
~10
man setunitpos"AUTO"
man setcombatMode"YELLOW"
goto"Suppress loop#"

the purpose of this script is to cause units to duck down and not be able to return fire because they are being suppresed by a heavy weapon. it uses an invs target addon which is setposed above them as it is ment for units behind cover.
it will work well on d-day missions to make the player think he is about to die and bullets are chasing him and make him not get hit but think he will be(then il take out the setcombat mod type stuff of course.)

where weap is in the syntax u are suposed to put a MG name that the shooter is carying.

as i said before im all eyes, so any sugjestions to improve the script would be aprieciated much.

thanks
My newest mission "Atomic Halo" coming soon

Offline Pilot

  • Contributing Member
  • **
Re:MY first script!!!! : ) problem though
« Reply #1 on: 01 Dec 2004, 03:14:59 »
Ok, I see two problems

Problem 1.
Quote
; start the target loop
Target loop#:
tgt setpos getpos man +1.5
~2
goto"Target loop#"

It should be:
Code: [Select]
; start the target loop
#Target loop
tgt setpos getpos man +1.5
~2
goto"Target loop"

The "#" needs to come before Target Loop, and when you call Target Loop you do not put in the "#"
Also, do not add the : after #Target Loop

The same applies to Suppress Loop.
I hope this is clear.

Problem 2.
Code: [Select]
goto"Target loop"When you use this command, the script jumps back up to Target Loop, and keeps repeating the process.  As a result, Suppress Loop will never be called.  The only solution I can think of is to divide this script into two scripts.

I hope that helps!

« Last Edit: 01 Dec 2004, 03:27:26 by Student Pilot »

Offline Pilot

  • Contributing Member
  • **
Re:MY first script!!!! : ) problem though
« Reply #2 on: 01 Dec 2004, 03:18:56 »
Something else I found:
Quote
tgt = _this select 0
man = _this select 1
shooter = _this select 2
weap = _this select 3

Should be:
Code: [Select]
_tgt = _this select 0
_man = _this select 1
_shooter = _this select 2
_weap = _this select 3

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:MY first script!!!! : ) problem though
« Reply #3 on: 01 Dec 2004, 03:57:06 »
thanks i will fix it and remember that in the future
anybody else?

Offline Blanco

  • Former Staff
  • ****
Re:MY first script!!!! : ) problem though
« Reply #4 on: 01 Dec 2004, 04:01:49 »
And dont forget to change the other tgt,man, shooter and weap variables in the script into local ones.  ;)



Search or search or search before you ask.

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:MY first script!!!! : ) problem though
« Reply #5 on: 01 Dec 2004, 06:08:07 »
explain please, i dont understand.
sry i have ver limited scripting knowledge

Uldics

  • Guest
Re:MY first script!!!! : ) problem though
« Reply #6 on: 01 Dec 2004, 06:53:29 »
A variable is local, when the first letter of it is underline. Local just means, that if outside the script (scope) is another variable with the same name, it will not show your local one outside and make a collision with the other. Your local variable doesnt exist outside your script.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:MY first script!!!! : ) problem though
« Reply #7 on: 02 Dec 2004, 12:36:14 »
_var is a local variable, which works only inside the script

var is a global variable, which works anywhere in the mission

Varibles starting with two underscores __var are reserved and should never be used.

See the comref Scripting Topics section for more detail.
Plenty of reviewed ArmA missions for you to play