Forum

> > CS2D > Scripts > while | do.
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch while | do.

7 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt while | do.

THEMUD
User Off Offline

Zitieren
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.

alt Re: while | do.

TimeQuesT
User Off Offline

Zitieren
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.

alt Re: while | do.

THEMUD
User Off Offline

Zitieren
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.

alt Re: while | do.

eledah
User Off Offline

Zitieren
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
1× editiert, zuletzt 13.11.14 16:45:49

alt Re: while | do.

VADemon
User Off Offline

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

alt Re: while | do.

THEMUD
User Off Offline

Zitieren
@user eledah: Huh. i try it.but when i want to close it i mean to destroy this hook what can i do ?
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht