English Health in trigger_if

5 replies
Goto Page
To the start Previous 1 Next To the start
17.04.14 07:59:19 pm
Up
Qater
User
Offline Off
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.
Actions speak louder than words.
17.04.14 08:24:02 pm
Up
DC
Admin
Offline Off
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.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
17.04.14 08:32:06 pm
Up
Qater
User
Offline Off
Okay.
But what is player('1,health') ?
Actions speak louder than words.
17.04.14 08:39:51 pm
Up
DC
Admin
Offline Off
player('1,health') is a piece of code with wrong syntax.

Code:
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):
Code:
1
parse("setmaxhealth 1 255")
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
17.04.14 09:00:50 pm
Up
Rainoth
Moderator
Offline Off
This is not an RBG code so the maximum is 250,though. I'm quite sure it'll set to 250 anyway.
17.04.14 09:06:12 pm
Up
Accurator
User
Offline Off
I made a little piece of code:

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.
Code:
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.
Code:
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