Forum

> > CS2D > Scripts > Barbed Wire Spawning
Forums overviewCS2D overview Scripts overviewLog in to reply

English Barbed Wire Spawning

5 replies
To the start Previous 1 Next To the start

old Barbed Wire Spawning

sCy
User Off Offline

Quote
Same topic, new problem:
I try to get the wire spawn back (and get the health of 100%) when pressing the use button next to it.
Problem is that it doesnt do it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function nz_use(id, event, data, x, y)
	if (player(id, "team") == 2) then
		if (event == 100) then
			-- repairing barbed wire
			if (entity(x, y, "trigger") == "barbedwire") then
				for _, v in ipairs(object(0, "table")) do
					if (object(v, "tilex") == x and object(v, "tiley") == y) then
						parse("killbuildings "..v)
						parse("spawnobject 2 "..x.." "..y.." 0 0 "..player(id,"team").." 0")
					end
				end
				
			end
		end
	end
end

Any idea what is the problem?

old Re: Barbed Wire Spawning

sCy
User Off Offline

Quote
No. I just need that if the wire has trigger "barbedwire" and you press E, it spawns the new wire.

old Re: Barbed Wire Spawning

sCy
User Off Offline

Quote
Heres the fixed code:

1
2
3
4
5
6
7
8
9
10
11
addhook("usebutton","nz_wire")
function nz_wire(id,x,y)
	if entity(x,y,"name")=="barb" then
		for _,p in ipairs(object(0,"table")) do
		if object(p,"tilex") == x and object(p,"tiley") == y then
			parse("killobject "..p)
		end
		end
	parse("spawnobject 2 "..x.." "..y)
	end
end

NOTE: You must place trigger_use named barb to this to work!
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview