English Not killable if x y

8 replies
Goto Page
To the start Previous 1 Next To the start
28.01.12 12:19:38 pm
Up
Draft
User
Offline Off
If x;y are

Code:
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.
IMG:http://samlancashire.com/quiz/creeper/generated2/33.png
28.01.12 12:27:53 pm
Up
DannyDeth
User
Offline Off
You will have to store them in another array:
Code:
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:
Code:
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
28.01.12 12:35:26 pm
Up
Draft
User
Offline Off
If i mind it should be like this:

Code:
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.
IMG:http://samlancashire.com/quiz/creeper/generated2/33.png
28.01.12 12:47:54 pm
Up
DannyDeth
User
Offline Off
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.
28.01.12 01:00:05 pm
Up
Draft
User
Offline Off
I'm **** at lua..
IMG:http://samlancashire.com/quiz/creeper/generated2/33.png
28.01.12 01:09:18 pm
Up
Starkkz
Moderator
Offline Off
user DannyDeth has written:
Code:
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.
lol
28.01.12 01:09:41 pm
Up
DannyDeth
User
Offline Off
*sigh* I can tell.
Code:
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
28.01.12 02:19:21 pm
Up
EngiN33R
Moderator
Offline Off
Danny! Tables in Lua start from index 1 and not 0!
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
28.01.12 02:20:50 pm
Up
DannyDeth
User
Offline Off
You're a moderator, edit it for me, I'm going out.

Admin/mod comment:

Arrogant bastard.
To the start Previous 1 Next To the start