Forum

> > CS2D > Scripts > If player shot then kill him
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch If player shot then kill him

13 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Re: If player shot then kill him

Apache uwu
User Off Offline

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

alt Re: If player shot then kill him

Cereal Guy
User Off Offline

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

alt Re: If player shot then kill him

michal16202
User Off Offline

Zitieren
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
2× editiert, zuletzt 12.08.12 11:55:21

alt Re: If player shot then kill him

Happy eyes
User Off Offline

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

alt Re: If player shot then kill him

michal16202
User Off Offline

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

alt Re: If player shot then kill him

Happy eyes
User Off Offline

Zitieren
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

alt Re: If player shot then kill him

SkullzOrig
User Off Offline

Zitieren
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

alt Re: If player shot then kill him

Divine
User Off Offline

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

alt Re: If player shot then kill him

Divine
User Off Offline

Zitieren
user Xirot hat geschrieben
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

alt Re: If player shot then kill him

Ahmad
User Off Offline

Zitieren
user Divine hat geschrieben
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.

alt Re: If player shot then kill him

Marcell
Super User Off Offline

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

Spoiler >
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht