OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: marcus3 on 07 Apr 2005, 19:07:34

Title: Check over and over again
Post by: marcus3 on 07 Apr 2005, 19:07:34
i have a script that needs to check a varible over and over again so i did it like this.

bla bla bla
?(thing>10) : goto "fun"
~10 < right here it waits i know but will it check the varible over and over?

well thats the prob and i need the ansir.

thanks in advance
Title: Re:Check over and over again
Post by: Planck on 07 Apr 2005, 19:17:35


?(thing>10) : goto "fun"

The thing is you have no #fun label for it to goto.

When you want to loop you need the label to loop from.

#loop
blablabla
~10
? blablabla : goto "loop"



Planck
Title: Re:Check over and over again
Post by: marcus3 on 07 Apr 2005, 19:33:16
#loop
guy setdammage 4
~10
?(blablabla>10) : goto "loop"

so if i want it to check the varible over and over again i put it after the wait thing?
Title: Re:Check over and over again
Post by: Planck on 07 Apr 2005, 19:47:41
In the above example it will keep looping as long as blablabla is greater than 10.

If blablabla equals 10 or becomes smaller than 10 the script will carry on by.


Planck
Title: Re:Check over and over again
Post by: RujiK on 07 Apr 2005, 20:39:24
Or you can just do:

Code: [Select]
@(Getdammage player > 0)
hint"Im Bleeding!! SAVE ME!"
exit

Note in the @ place there needs to be a condtion not an activation. However if you have like 50 of these in one map, it will become really jerky.
Just telling you this as I'm not sure how new you are.
Title: Re:Check over and over again
Post by: marcus3 on 08 Apr 2005, 09:44:56
well i cant get it to work let me just post the script.



#full
?(hunger == 40) : hunger = hunger -40
?(hunger == 30) : hunger = hunger -30
?(hunger == 20) : hunger = hunger -20
?(hunger == 10) : hunger = hunger -10

hunger = hunger +50
~180



hunger = hunger -10

~180
?(hunger>40) : goto "full2"

hunger = hunger -10

jason sidechat "i am hungry"

~180
?(hunger>30) : goto "full2"

hunger = hunger -10

jason sidechat "man i am hungry"

~180
?(hunger>20) : goto "full2"


hunger = hunger -10

jason sidechat "AHHHH!! i need food!"

~60
?(hunger>10) : goto "full2"

jason setdammage 0.9

jason sidechat "ahh i am dieing"
~5

jason setdammage 4


#full2

hunger = hunger -1

goto "full"



Title: Re:Check over and over again
Post by: Roni on 09 Apr 2005, 07:04:48
Hi marcus3

Try this -

; hunger.sqs

; Set starting energy and rations on hand
energy = 100
rations = 3

; start loop
#loop
energy = energy - 1

; display messages as jason slowly starves
? energy == 40 : jason sidechat "Maybe we should stop for a bite."
? energy == 20 : jason sidechat "I'm hungry !"
? energy == 10 : jason sidechat "Seriously, I'm REALLY hungry !!"
? energy == 0 : jason sidechat "I'm STARVING !!"
? energy < 0 : jason sidechat "so . . . hungry . . . "

? energy < 0 : jason setDammage ((getDammage jason) + 0.05)

~10
goto "loop"



The loop is pretty slow so it should have almost no effect on lag.

Note that once jason's energy goes below 0 he will display his hunger message every cycle of the loop, not just once.  He will also start to take damage until after about 3 minutes he dies from hunger.  Of course you can change these values to suit your mission.

Now to add to this all you have to do is give him the addAction

jason addAction ["Eat rations", "eatRations.sqs"]

and make up the script eatRations.sqs as follows -

; eatRations.sqs
? rations < 1 : jason sidechat "You're out of food !", exit

rations = rations - 1
energy = energy + 50



Note that the script hunger.sqs starts jason with 3 rations, again feel free to change this to suit your mission.

Finally, if you REALLY want to have some fun put the following addaction on some sort of object on the map -

this addAction ["Take Rations", "takeRations.sqs"]

; takeRations.sqs
rations = rations + 3
this removeAction 0



This should give jason three more rations and remove the addAction from the assigned object.  If you want more rations, again, just edit the script acordingly.

Hope this is of use !



roni