Forum

> > CS2D > Scripts > If player shot then kill him
Forums overviewCS2D overview Scripts overviewLog in to reply

English If player shot then kill him

13 replies
To the start Previous 1 Next To the start

old Re: If player shot then kill him

Apache uwu
User Off Offline

Quote
Like this?

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

old Re: If player shot then kill him

Cereal Guy
User Off Offline

Quote
And how to add multiple zones? something like :
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
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
And if you can make a hud txt to appear in that zone [Do not attack in this zone]

old Re: If player shot then kill him

michal16202
User Off Offline

Quote
I don't known how to configure positions, I want the script to include 11|6 - 30|37 and 30|13 - 48|25 and I'd like to just after the third shot, a player dies
edited 2×, last 12.08.12 11:55:21 am

old Re: If player shot then kill him

Happy eyes
User 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
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?

old Re: If player shot then kill him

michal16202
User Off Offline

Quote
Quote
safezone = {
{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
parse('hudtxt2 '..id..' 1 \"Do not attack in this zone\" 300 300')
does not vanish

old Re: If player shot then kill him

Happy eyes
User Off Offline

Quote
What an awful mistake at line 13 in my script. Sorry for that. This script works great for me, already tested

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
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

old Re: If player shot then kill him

SkullzOrig
User Off Offline

Quote
I been noticing that when you shoot the corner of a wall, the bulllet goes through it every 5-9 shots. This could possibly be a problem while using your script

old Re: If player shot then kill him

Divine
User Off Offline

Quote
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.

old Re: If player shot then kill him

Divine
User Off Offline

Quote
user Xirot has written
lol there's a lot of X,Y.
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

old Re: If player shot then kill him

Ahmad
User Off Offline

Quote
user 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.

old Re: If player shot then kill him

Marcell
Super User On Online

Quote
Tested and works! √
• Just one times you press attack you die

Spoiler >
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview