Forum

> > CS2D > Scripts > Not killable if x y
Forums overviewCS2D overview Scripts overviewLog in to reply

English Not killable if x y

8 replies
To the start Previous 1 Next To the start

old Not killable if x y

Draft
User Off Offline

Quote
If x;y are

1
2
3
4
5
{2,120},{13,131}
{2,139},{10,145}
{24,124},{32,145}

More to add, hope i can add how many i can.

If the x;y are that ones then you cant be hurt.

old Re: Not killable if x y

DannyDeth
User Off Offline

Quote
You will have to store them in another array:
1
2
3
4
5
position_array = {
	{2,120},
	{13,131}
	-- etc etc etc
}
Then loop through them when a player is hit, I would reccomend using pairs, and reject the hit if the players coords are inside the position array:
1
2
3
4
5
for _, v in pairs(position_array) do
	if( player(id,"tilex") == v[0] and player(id,"tiley") == v[1]) then
		return 1 -- Do not allow damage
	end
end

old Re: Not killable if x y

Draft
User Off Offline

Quote
If i mind it should be like this:

1
2
3
4
5
6
7
8
9
10
11
12
position_array = {
     {{2,120},{13,131}},
     {{2,139},{10,145}},
     {{24,124},{32,145}},
     -- etc etc etc
}

for _, v in pairs(position_array) do
     if( player(id,"tilex") == v[0] and player(id,"tiley") == v[1]) then
          return 1 -- Do not allow damage
     end
end


When i saw the positions i think it wont work.

Don't work!

I think this would do.

old Re: Not killable if x y

DannyDeth
User Off Offline

Quote
I specifically said "when a player is hit!" You need to put it in a hit hook, and I am not wasting anymore of my time on dimwits.

old Re: Not killable if x y

Starkkz
Moderator Off Offline

Quote
user DannyDeth has written
1
2
3
4
5
for _, v in pairs(position_array) do
	if( player(id,"tilex") == v[0] and player(id,"tiley") == v[1]) then
		return 1 -- Do not allow damage
	end
end


BTW, index in lua tables is 1, not 0.

old Re: Not killable if x y

DannyDeth
User Off Offline

Quote
*sigh* I can tell.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
position_array = {
{2,120},{13,131},
{2,139},{10,145},
{24,124},{32,145},
-- etc etc etc
}
addhook("hit","check_hit")
function check_hit(id)
	for _, v in pairs(position_array) do
		if( player(id,"tilex") == v[1] and player(id,"tiley") ==v[2]) then
		return 1 -- Do not allow damage
		end
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview