Forum

> > CS2D > Scripts > No Attack Zone
Forums overviewCS2D overview Scripts overviewLog in to reply

English No Attack Zone

7 replies
To the start Previous 1 Next To the start

old No Attack Zone

Bobakrome
User Off Offline

Quote
Hi all, i'm working on some server with school and i need something.

If you are in zones 3,3 to 44,27 ; 22,54 to 26,58 ; and others. I need really many because is school town etc. and others.

Oh yeah back to if you are in zones... then you cant get hurt, and you cant hurt people. i saw this thing in a AFK script.. Factis's AFK Protection

old Re: No Attack Zone

EngiN33R
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
zones = {
	{3,3,44,27},
	{22,54,26,58}
}

function checkInZone(id)
	for zn,zone in pairs(zones) do
		if player(id,"tilex")>=zone[1] and player(id,"tiley")>=zone[2] and player(id,"tilex")<=zone[3] and player(id,"tiley")<=zone[4] then
			return zn
		end
	end
	return nil
end

addhook("hit","safezones")
function safezones(id,src)
	if checkInZone(id) then
		return 1
	end
	if checkInZone(src) then
		return 1
	end
end

I think this would work.

@user Alistaire: That will allow players to toggle invincibility anywhere - he wants it to be in zones.

old Re: No Attack Zone

Bobakrome
User Off Offline

Quote
user EngiN33R has written
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
zones = {
	{3,3,44,27},
	{22,54,26,58}
}

function checkInZone(id)
	for zn,zone in pairs(zones) do
		if player(id,"tilex")>=zone[1] and player(id,"tiley")>=zone[2] and player(id,"tilex")<=zone[3] and player(id,"tiley")<=zone[4] then
			return zn
		end
	end
	return nil
end

addhook("hit","safezones")
function safezones(id,src)
	if checkInZone(id) then
		return 1
	end
	if checkInZone(src) then
		return 1
	end
end

I think this would work.

@user Alistaire: That will allow players to toggle invincibility anywhere - he wants it to be in zones.


Thanks, i really dont want school fights

old Re: No Attack Zone

LoaderFRA
User Off Offline

Quote
You must use the command: hudtxt2
http://www.cs2d.com/help.php?cat=server&cmd=hudtxt2#cmd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
zones = {
     {3,3,44,27},
     {22,54,26,58}
}

function checkInZone(id)
     for zn,zone in pairs(zones) do
          if player(id,"tilex")>=zone[1] and player(id,"tiley")>=zone[2] and player(id,"tilex")<=zone[3] and player(id,"tiley")<=zone[4] then
               return zn
          end
     end
     return nil
end

addhook("hit","safezones")
function safezones(id,src)
if checkInZone(id) then
parse('hudtxt2 '..id..' 5 "©000255255SAFE ZONE" 320 200')
return 1
end
     if checkInZone(src) then
          return 1
     end
end
PS:I think it's like that, i'm not expert in language lua
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview