Home   Help Search Login Register  

Author Topic: if unit already has that action then....  (Read 2037 times)

0 Members and 1 Guest are viewing this topic.

_hammy_

  • Guest
if unit already has that action then....
« on: 12 Sep 2002, 01:13:40 »
im making a script where they use the action menu, and i need to how to detect if a unit already has that action then it will skip that line where it tells OFP to give the player the action. short version of what i said: i want to skip the line if the unit already has the action. the action is named is Bury, i have tryed:

Code: [Select]
? (Bury == 0):goto "next"
i dont get any errors, it wont work i hope you could understand what i said :-\

Offline Black_Feather

  • Former Staff
  • ****
  • I'll never forget you Daisey.
Re:if unit already has that action then....
« Reply #1 on: 12 Sep 2002, 02:10:26 »
hmm I'd just remove the action first then add it again

player removeaction bury
bury = player addaction["bury whatever","script.sqs"]

there's probably a proper way though  ;)

_hammy_

  • Guest
Re:if unit already has that action then....
« Reply #2 on: 12 Sep 2002, 03:44:23 »
hmmm, it works, but i cant select the action:

Code: [Select]
#bury
Unit removeaction Bury
~0.01
?(Unit distance Pipey < 4):goto "buryaction"
?(Unit distance Pipey > 4):goto "exit2"
goto "bury"

#buryaction
Bury = Unit addaction [FORMAT["Bury Bomb"],"bury.sqs"]
goto "bury"

_hammy_

  • Guest
Re:if unit already has that action then....
« Reply #3 on: 13 Sep 2002, 05:59:43 »
bah, someone help me please

Gameer_77

  • Guest
Re:if unit already has that action then....
« Reply #4 on: 13 Sep 2002, 23:30:36 »
I don't exactly know the ins and outs of your mission or action but could you put a variable in the same line as the addaction then check if that variable is true.

Tell us more please.  :-*

 8)PEACE

_hammy_

  • Guest
Re:if unit already has that action then....
« Reply #5 on: 14 Sep 2002, 00:43:28 »
Bury is a variable

Gameer_77

  • Guest
Re:if unit already has that action then....
« Reply #6 on: 14 Sep 2002, 00:59:35 »
Yes, but that only contains Unit addaction [FORMAT["Bury Bomb"],"bury.sqs"]

Quick Q: Who is unit? I think Unit may be a global variable. Probably not though.

What use is that in checking if its been run? Id use a seperate variable with true and false.

 8)PEACE
« Last Edit: 14 Sep 2002, 01:01:06 by Gameer_77 »

_hammy_

  • Guest
Re:if unit already has that action then....
« Reply #7 on: 15 Sep 2002, 00:15:34 »
Quote
Yes, but that only contains Unit addaction [FORMAT["Bury Bomb"],"bury.sqs"]
yep :)

Unit is a global variable

Quote
What use is that in checking if its been run? Id use a seperate variable with true and false.

what are you even talking about?
:)

Gameer_77

  • Guest
Re:if unit already has that action then....
« Reply #8 on: 15 Sep 2002, 00:19:38 »
How can you use the _bury variable to check whether the player ahs used the action? If you use a variable containing false and true then you can do it easily. Thats what i mean.

 8)PEACE

_hammy_

  • Guest
Re:if unit already has that action then....
« Reply #9 on: 15 Sep 2002, 01:56:50 »
btw, its not _bury, its Bury :)
i really dont understand what u are saying, so can you tell me in code?

Quote
How can you use the _bury variable to check whether the player ahs used the action?
I was trying things to get it to work :P

Gameer_77

  • Guest
Re:if unit already has that action then....
« Reply #10 on: 15 Sep 2002, 12:46:15 »
Ok:

If you wanted to check whether a unit has an action, then i would do the following. Put this piece of code into the same onactivation or line of script as the addaction is:

Gotaction=true

So it would look like this:

Unit addaction [FORMAT["Bury Bomb"],"bury.sqs"];gotaction=true

Then, when you want to check whether or not the unit has been given the action already, do this:

?gotaction:goto "Skipgiveaction"

But if the player has been given the action, then he uses it and it disappears, he wont get it. If you want him to get the action even after hes used it origanally, and the script has removed it from him, then put this line of code (WTF!!!  ::)):

gotaction=false

Put this after the removeaction bury command.

As i said i dont know the ins and outs of your mission so this may or may not work.

 8)PEACE

Bremmer

  • Guest
Re:if unit already has that action then....
« Reply #11 on: 15 Sep 2002, 13:16:18 »
Why not use a repeating trigger:

Condition: Unit distance Pipey < 4
On Activation: Unit addaction ["Bury Bomb", "bury.sqs"]
On Deactivation: Unit removeaction Bury


Scripting isn't always the best solution  ;)
« Last Edit: 15 Sep 2002, 13:18:22 by Bremmer »