Forum

> > CS2D > Scripts > while | do.
Forums overviewCS2D overview Scripts overviewLog in to reply

English while | do.

7 replies
To the start Previous 1 Next To the start

old while | do.

THEMUD
User Off Offline

Quote
Hello everyone.
I'm making a script right now ,but i have a problem.
Please fix it.

1
2
3
4
5
6
7
8
if (txt == "yes")
then
while (true)
do
parse("setmaxhealth "..id.." 250")
parse("sethealth "..id.." 100"
end
end

The problem is ,when i start the script on the game.
The game Doesn't Responding.
And the game quit.
Help me !

THEMUD.

old Re: while | do.

TimeQuesT
User Off Offline

Quote
You're having an infinite loop in line 3.
1
2
3
4
if (txt == "yes") then
	parse("setmaxhealth "..id.." 250");
	parse("sethealth "..id.." 100");
end

Also tab your code.

while(true) simply means: execute the code block while true == true.

old Re: while | do.

THEMUD
User Off Offline

Quote
This code you give it to me isn't what i want.
And isn't a alway's parsing.
I want to do it with looping.

old Re: while | do.

eledah
User Off Offline

Quote
1
2
3
4
5
6
7
8
if (txt == "yes") then
	addhook("always", "always_hp")
end

function always_hp()
	parse("setmaxhealth "..id.." 250");
	parse("sethealth "..id.." 100");
end
edited 1×, last 13.11.14 04:45:49 pm

old Re: while | do.

VADemon
User Off Offline

Quote
while true is an infinite loop. What you want is either the hook "always" or "ms100"

old Re: while | do.

THEMUD
User Off Offline

Quote
@user eledah: Huh. i try it.but when i want to close it i mean to destroy this hook what can i do ?
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview