Forum

> > CS2D > Scripts > Can't kill
Forums overviewCS2D overview Scripts overviewLog in to reply

English Can't kill

8 replies
To the start Previous 1 Next To the start

old Can't kill

Blacko
User Off Offline

Quote
Hello everybody !
I need your help !
I search a Script for my Server
It made a zone where nobody can make damage, kill other people. "A peace area"
Please, help !
Thanks you !
iDios

old Re: Can't kill

Danikah
User Off Offline

Quote
inb4theoneswhodontspeaknoobish

He wants a scipt which makes a zone, a "peace area" where you cannot hurt others, but outside it, you can. Similar to Tibia's safe zones.

old Re: Can't kill

Yasday
User Off Offline

Quote
1
2
3
4
5
6
7
8
area = { x1 = 0, y1 = 0, x2 = 100, y2 = 100 }

addhook([[hit]], [[area.hit]])
function area.hit(id, src, wpn)
if player(id, "tilex") >= area.x1 and player(id, "tiley") >= area.y1 and player(id, "tilex") <= area.x2 and player(id, "tiley") <= area.y2 then
return 1
end
end

old Re: Can't kill

Infinite Rain
Reviewer Off Offline

Quote
try this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function sa(id,x1,y1,x2,y2)
 return (player(id,'tilex')>x1 or player(id,'tilex')==x1) and (player(id,'tilex')<x2 or player(id,'tilex')==x2) and (player(id,'tiley')>y1 or player(id,'tiley')==y1) and (player(id,'tiley')<y2 or player(id,'tiley')==y2)
end

--DONT TOUCH THIS
peacearea={}
--NOW U CAN TOOUCH
peacearea[1]={x1=12,y1=32,x2=58,y2=64}

addhook('hit','nohit')
function nohit(id,source)
 for a=1,#peacearea do
  if sa(id,peacearea[a].x1,peacearea[a].y1,peacearea[a].x2,peaceare[a].y2) then
   msg2(source,'You cant attack on peaceful area!')
   return 1
  end
 end
end

Youcan make moreareas with my table a the top (peacerea[1])
x1 and y1 - X and Y from the left top corner (where starts area)
x2 and y2 - X and Y from the right bottom corner (where ends area)

old Re: Can't kill

Blacko
User Off Offline

Quote
Hello !
I try your, factis699, but he don't work.
LUA ERROR: sys/lua/main.lua:1615: attempt to index global 'peaceare' (a nil value)

old Re: Can't kill

Geez
GAME BANNED Off Offline

Quote
because peaceare don't exist.

you should change it to
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function sa(id,x1,y1,x2,y2)
return (player(id,'tilex')>x1 or player(id,'tilex')==x1) and (player(id,'tilex')<x2 or player(id,'tilex')==x2) and (player(id,'tiley')>y1 or player(id,'tiley')==y1) and (player(id,'tiley')<y2 or player(id,'tiley')==y2)
end

--DONT TOUCH THIS
peacearea={}
--NOW U CAN TOOUCH
peacearea[1]={x1=12,y1=32,x2=58,y2=64}

addhook('hit','nohit')
function nohit(id,source)
for a=1,#peacearea do
if sa(id,peacearea[a].x1,peacearea[a].y1,peacearea[a].x2,peacearea[a].y2) then
msg2(source,'You cant attack on peaceful area!')
return 1
end
end
end

Error was here:
if sa(id,peacearea[a].x1,peacearea[a].y1,peacearea[a].x2,peacearea[a].y2) then

old Re: Can't kill

Picias
BANNED Off Offline

Quote
your problem is done ??
if you need help again say it

old Re: Can't kill

Blacko
User Off Offline

Quote
It's ok for this Script.
But now, I search a Script who give Speedmod 50 to a Player when he go on a tile.
I don't know if you understand :S
I hope !
Thanks you
iDios
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview