Home   Help Search Login Register  

Author Topic: Check over and over again  (Read 650 times)

0 Members and 1 Guest are viewing this topic.

marcus3

  • Guest
Check over and over again
« 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

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Check over and over again
« Reply #1 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
I know a little about a lot, and a lot about a little.

marcus3

  • Guest
Re:Check over and over again
« Reply #2 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?

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Check over and over again
« Reply #3 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
« Last Edit: 07 Apr 2005, 19:48:04 by Planck »
I know a little about a lot, and a lot about a little.

Offline RujiK

  • Members
  • *
  • KoKo Puh-Fizzles!
Re:Check over and over again
« Reply #4 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.
I like your approach, lets see your departure.
Download the New Flashlight Script!

marcus3

  • Guest
Re:Check over and over again
« Reply #5 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"




Offline Roni

  • Members
  • *
  • Play the Game !
Re:Check over and over again
« Reply #6 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