Forum

> > Trash > SOLVED
Forums overviewTrash overviewLog in to reply

English SOLVED

12 replies
To the start Previous 1 Next To the start

closed moved SOLVED

sCy
User Off Offline

Quote
This is solved, thank you!
edited 2×, last 12.02.12 10:14:52 am

old Re: SOLVED

TimeQuesT
User Off Offline

Quote
You have to table all objects. Then loop through them and check the position. After getting equalitys in the players and objects position , force a teleport.

old Re: SOLVED

sCy
User Off Offline

Quote
Well, I dont understand what you said..
edited 1×, last 11.02.12 06:14:09 pm

old Re: SOLVED

Apache uwu
User Off Offline

Quote
Try this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
addhook("movetile","_movetile")

last_tile={}

function _movetile(id,x,y)
	if objectpos(x,y,"type")==2 then
		parse("setpos "..id.." "..(last_tile[id][1]*32+16).." "..(last_tile[id][2]*32+16))
	else
		last_tile[id]={x,y}
	end
end

function objectpos(x,y,value)
	for _,building in ipairs(object(0,"table")) do
		if object(building,"tilex")==x and object(building,"tiley")==y then
			return object(building,value)
		end
	end
	return false
end

old Re: SOLVED

sCy
User Off Offline

Quote
It works, thank you a lot
Your a lifesaver.

old Re: SOLVED

Apache uwu
User Off Offline

Quote
I tried the same concept with move, it looks much nicer. I used movetile because it's less server extensive.

old Re: SOLVED

sCy
User Off Offline

Quote
Hey as bonus question, can you customise the dmg what the wire gets (like survives more than 5 hits) and make the barbed wire dmg 0?

old Re: SOLVED

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
28
29
30
addhook("movetile","_movetile")
addhook("hit","_hit")

barbedHits=5
parse("mp_building_health \"Barbed Wire\" "..(barbedHits*60))

function _hit(id,source,weapon)
	if weapon==255 then
		return 1
	end
end

last_tile={}

function _movetile(id,x,y)
	if objectpos(x,y,"type")==2 then
		parse("setpos "..id.." "..(last_tile[id][1]*32+16).." "..(last_tile[id][2]*32+16))
	else
		last_tile[id]={x,y}
	end
end

function objectpos(x,y,value)
	for _,building in ipairs(object(0,"table")) do
		if object(building,"tilex")==x and object(building,"tiley")==y then
			return object(building,value)
		end
	end
	return false
end

Change barbedHits to how many hits you want barbed wires to survive for.

old Re: SOLVED

sCy
User Off Offline

Quote
The barbed still gives damage, what isnt the wanted thing.
Otherwise, your been a so big lifesaver that I cant even describe it.

old Re: SOLVED

Apache uwu
User Off Offline

Quote
No I just tested it, works fine, and when I comment return 1 it gives damage.

Make sure you do not have any conflicting hooks.

old Re: SOLVED

sCy
User Off Offline

Quote
I changed the hook names:
1
2
3
4
5
6
7
8
9
10
11
addhook("movetile","_movetile")
addhook("hit","_wirehit")

barbedHits=14
parse("mp_building_health \"Barbed Wire\" "..(barbedHits*60))

function _wirehit(id,source,weapon)
     if weapon==255 then
          return 1
     end
end
and it still doesnt work... What is rather odd.

old Re: SOLVED

Apache uwu
User Off Offline

Quote
...You still need to have the _movetile functions, last_tile array, and objectpos function.

Make sure you are not running this with another hit hook.

old Re: SOLVED

sCy
User Off Offline

Quote
Found the problem:

There was 2 hit hooks:

adding "nz_hit" to hit function
few lines later...
adding "_hit" to hit function

So, now it works, and thank you very much!
To the start Previous 1 Next To the start
Log in to replyTrash overviewForums overview