OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: _hammy_ 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:
? (Bury == 0):goto "next"
i dont get any errors, it wont work i hope you could understand what i said :-\
-
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 ;)
-
hmmm, it works, but i cant select the action:
#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"
-
bah, someone help me please
-
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
-
Bury is a variable
-
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
-
Yes, but that only contains Unit addaction [FORMAT["Bury Bomb"],"bury.sqs"]
yep :)
Unit is a global variable
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?
:)
-
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
-
btw, its not _bury, its Bury :)
i really dont understand what u are saying, so can you tell me in code?
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
-
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
-
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 ;)