Forum

> > CS2D > Maps/Editor > How to hurt once?
Forums overviewCS2D overview Maps/Editor overviewLog in to reply

English How to hurt once?

13 replies
To the start Previous 1 Next To the start

old How to hurt once?

-AngelOfDeath-
User Off Offline

Quote
Hello all, i have a question about map creating. Im going to make 35hp map but i cant do that what players would be hurted once, i tried to trigger entinies but nothing worked, maybe someone know how to do it or have ideas how to trigger it? Thanks for answers

old Re: How to hurt once?

DannyDeth
User Off Offline

Quote
1
2
3
4
5
6
addhook("startround","set_hp")
function set_hp()
	for i=1,32 do
		if(player(i,"exists") and player(i,"hp") > 0) then parse("sethealth "..i.." 35") end
	end
end

EDIT: I would just like to point out that I was extremely busy + tired when I wrote the original script.
edited 1×, last 01.08.11 04:41:59 pm

old Re: How to hurt once?

Alistaire
User Off Offline

Quote
Dude,

-Copy the code to a .txt file
-Call the file "35HP.lua" and save it in sys/lua
-Add this line to your server.lua file: dofile('sys/lua/35HP.lua')
-Try again!

old Re: How to hurt once?

-AngelOfDeath-
User Off Offline

Quote
im not a idiot, i do this, it wont work

PS. I created deticated server and it writes: LUA ERROR: sys/lua/35HP.lua:4: 'do' expected near 'if'
edited 1×, last 31.07.11 06:59:10 pm

old Re: How to hurt once?

Alistaire
User Off Offline

Quote
1
2
3
4
5
6
7
8
addhook("startround","set_hp")
	function set_hp()
		for i=1,32
			if(player(id,"exists")) and (player(id,"hp") > 0) 
				do parse("sethealth "..i.." 35")
			end
	end
end

Try again
edited 1×, last 31.07.11 07:13:25 pm

old Re: How to hurt once?

Starkkz
Moderator Off Offline

Quote
user Alistaire has written
Quote
addhook("startround","set_hp")
function set_hp()
          for i=1,32
               if(player(id,"exists")) and (player(id,"hp") > 0)
                    do parse("sethealth "..i.." 35")
               end
     end
end


Try again


The first time I saw it, I knew the bug. Btw, Danny was near.

old Re: How to hurt once?

Alistaire
User Off Offline

Quote
Hurr I didn't notice that.

1
2
3
4
5
6
7
8
addhook("startround","set_hp")
function set_hp()
          for id=1,32
               if(player(id,"exists")) and (player(id,"hp") > 0) 
                    do parse("sethealth "..id.." 35")
               end
     end
end

old Re: How to hurt once?

EngiN33R
Moderator Off Offline

Quote
1
2
3
4
5
6
7
addhook("startround","set_hp")
function set_hp()
for id=1,32 do
if(player(id,"exists")) and (player(id,"hp") > 0) then parse("sethealth "..id.." 35")
end
end
end

EDIT: Hold on, wait, does that actually work? What 2Fast4You wrote? I thought 'do' only goes after 'for'?

old Re: How to hurt once?

RAVENOUS
BANNED Off Offline

Quote
user EngiN33R has written
EDIT: Hold on, wait, does that actually work? What 2Fast4You wrote? I thought 'do' only goes after 'for'?


It does.

Actually, after using the if-condition, you have to use the marker "then" instead of "do".

old Re: How to hurt once?

Apache uwu
User Off Offline

Quote
Hm, potentially you could add a env_hurt for 1 second when the round starts. (env_hurt,delay)

However lua is easier.

1
2
3
4
5
6
7
addhook("startround","_startround")

function _startround()
	for _,id in ipairs(player(0,"tableliving")) do
		parse("sethealth "..id.." ".." 35")
	end
end

@2Fast4You happens to everyone once in a while, and when you know different languages it tends to happen a lot when you switch back and forth between languages.
To the start Previous 1 Next To the start
Log in to reply Maps/Editor overviewCS2D overviewForums overview