Forum

> > CS2D > Maps/Editor > Health in trigger_if
Forums overviewCS2D overview Maps/Editor overviewLog in to reply

English Health in trigger_if

5 replies
To the start Previous 1 Next To the start

old Health in trigger_if

Qater
User Off Offline

Quote
How I can do something with health in trigger_if ?
I want to create map, in which are have zombies 255 HP.
Thanks for advice.

old Re: Health in trigger_if

DC
Admin Off Offline

Quote
trigger_if is not made for this. Create a Lua script / Lua map script instead.

Are you talking about player zombies or NPC zombies? For NPC zombies you can also simply change the health in the NPC entity.

old Re: Health in trigger_if

DC
Admin Off Offline

Quote
player('1,health') is a piece of code with wrong syntax.

1
value = player(1,"health")
would set the variable "value" to the current health value of the player with id 1.

Use cs2d cmd sethealth and/or cs2d cmd setmaxhealth to change the heath (in this example for player with id 1):
1
parse("setmaxhealth 1 255")

old Re: Health in trigger_if

Rainoth
Moderator Off Offline

Quote
This is not an RBG code so the maximum is 250,though. I'm quite sure it'll set to 250 anyway.

old Re: Health in trigger_if

Accurator
User Off Offline

Quote
I made a little piece of code:

1
2
3
4
5
6
7
8
9
10
11
addhook("usebutton","This_happens_if_a_button_is_pressed")

function This_happens_if_a_button_is_pressed(id,x,y)
	local your button x position= --Put it here!
	local your button y position= --Put it here!
	if button("x")=="your button x position" and button("y")=="your button y position"
		if team(id,"team")==1 then -- The player's team will be defined. If it's the terrorist (zombie) team, then...
			setmaxhealth(id,250) -- The player's health will be set to 250. It is NOT possible to go over the limit of 250 max health.
		end
	end
end

Untested, and it can be made simpler, but I made it so you could understand it more. Note: "your button x position" and "your button y position" are strings. Strings can hold a value.
1
2
local your button x position= --Put it here!
local your button y position= --Put it here!
sets your strings' values to the inserted number.
1
if button("x")=="your button x position" and button("y")=="your button y position"
checks if the button's x and y position match the strings' value.

More >
edited 2×, last 17.04.14 09:28:42 pm
To the start Previous 1 Next To the start
Log in to reply Maps/Editor overviewCS2D overviewForums overview