Forum
CS2D Scripts If player shot then kill himIf player shot then kill him
13 replies 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
addhook("attack","_attack") addhook("spawn","_spawn") attacked={} position={ 	x=20, 	y=20, 	width=5, 	height=5 } function _attack(id) 	for x=position.x,position.x+position.width do 		for y=position.y,position.y+position.height do 			if player(id,"tilex")==x and player(id,"tiley")==y then 				attacked[id]=attacked[id]+1 				if attacked[id]==3 then 					parse("killplayer "..id) 				end 			end 		end 	end end function _spawn(id) 	attacked[id]=0 end
Try changing the position's array so that it matches with your map.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
addhook("attack","_attack") addhook("spawn","_spawn") attacked={} position={ x=20, y=20, width=5, height=5 position={ x=52, y=35, width=4, height=6 position ETC and so on.... } function _attack(id) for x=position.x,position.x+position.width do for y=position.y,position.y+position.height do if player(id,"tilex")==x and player(id,"tiley")==y then attacked[id]=attacked[id]+1 if attacked[id]==3 then parse("killplayer "..id) end end end end end function _spawn(id) attacked[id]=0 end
edited 2×, last 12.08.12 11:55:21 am
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
safezone = { 	{11,6,30,37}, --add as much zones as you need 	{30,13,48,25}, 	{x1,y1,x2,y2}, } attacked = {} function insafezone(id) 	for n,w in pairs (safezone) do 		local tilex=player(id,"tilex") 		local tiley=player(id,"tiley") 		if tilex>=w[1] and tilex <=w[3] and tiley >= 6 and tiley <= 37 then 			return true 		end 	end 	return false end addhook('movetile','movetile') function movetile(id,tilex,tiley) 	if insafezone(id) then 		parse('hudtxt2 '..id..' 1 \"Do not attack in this zone\" 300 300') 	else 		parse('hudtxt2 '..id..' 1') 	end end addhook('attack','attack') function attack(id) 	if insafezone(id) then 		if attacked[id] < 3 then 			attacked[id] = attacked[id] + 1 		else 			parse('customkill '..id..' safezone '..id) 		end 	end end addhook('spawn','spawn') function spawn(id) 	attacked[id]=0 end
How about this code?
Quote
safezone = {
{11,6,30,37}, --add as much zones as you need
{30,13,48,25},
{x1,y1,x2,y2},
}
{11,6,30,37}, --add as much zones as you need
{30,13,48,25},
{x1,y1,x2,y2},
}
does't work because instead of doing separate fields of anti attacks creates one with the dimensions 11|6 to 48|25 and
Quote
does not vanish parse('hudtxt2 '..id..' 1 \"Do not attack in this zone\" 300 300')
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
safezone = { {11,6,30,37}, {30,13,48,25}, } attacked = {} function insafezone(id) for n,w in pairs (safezone) do local tilex=player(id,"tilex") local tiley=player(id,"tiley") if tilex>=w[1] and tilex <=w[3] and tiley >= w[2] and tiley <= w[4] then return true end end return false end addhook('movetile','movetile') function movetile(id,tilex,tiley) if insafezone(id) then parse('hudtxt2 '..id..' 1 \"Do not attack in this zone\" 300 300') else parse('hudtxt2 '..id..' 1') end end addhook('attack','attack') function attack(id) if insafezone(id) then if attacked[id] < 3 then attacked[id] = attacked[id] + 1 else parse('customkill '..id..' safezone '..id) end end end addhook('spawn','spawn') function spawn(id) attacked[id]=0 end
I need to choose it floor by floor ?
Xirot has written
lol there's a lot of X,Y.
I need to choose it floor by floor ?
I need to choose it floor by floor ?
Just use math skills or a calculator. Each tile is 32x32 so just use insane math skillz
Divine has written
A very simple way of doing 3 shot kill is to edit all of the weapon damages to match 100 hp :P, but this is if you have no other option and you can't script/get help.
Read again -.-',he wants the player to be punished when shooting while being in a certain area of the map.So just pressing the shooting button 3 times kills you.
E.G: Shop in HappyTown servers.
Just one times you press attack you die
1