Forum

> > CS2D > Scripts > Spawn BarbWires and Replace
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Spawn BarbWires and Replace

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Spawn BarbWires and Replace

Jynxxx
User Off Offline

Zitieren
In this code i was trying to spawn a barbwire on the trigger_use, everything works but i want to remove the barbwire from the tile it is on and replace it with a new one. Please Help me, Thank You.

1
2
3
4
5
6
7
8
addhook("usebutton","barbiredwire")
function barbiredwire(id,x,y)
	if entity(x,y,"name")=="barb" then
		it = player(id,"team")
		parse("killobject "..id")
		parse("spawnobject 2 "..x.." "..y.." 0 0 "..it.." "..id)
	end
end

alt Re: Spawn BarbWires and Replace

MikuAuahDark
User Off Offline

Zitieren
you don't need lua script to do this!
just do this in editor:
Put Trigger_Use, name: <empty> trigger: wire
then put Env_Building, name: wire building: 2 - BarbedWire
and it's done!

alt Re: Spawn BarbWires and Replace

White_12E_456_789
BANNED Off Offline

Zitieren
@user MikuAuahDark: yeah But if the button is inside you will press it right if you start it in the trigger it will go INVISIBLE right. thats why we need lua script so if the building is start then press the button and then the building will not go VISIBLE!!

alt Re: Spawn BarbWires and Replace

Jynxxx
User Off Offline

Zitieren
ok i got it ill post it here to save everyone the trouble
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
addhook("usebutton","barbiredwire")
function barbiredwire(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


addhook("movetile","Barbed_knockBack")
function Barbed_knockBack(id,x,y)
	local state = true
	for _,p in ipairs(object(0,"table")) do
		if object(p,"tilex") == x and object(p,"tiley") == y and object(p,"typename") == "Barbed Wire" then
			parse("setpos "..id.." "..((KnockBackPos[id][1]*32)+16).." "..((KnockBackPos[id][2]*32)+16))
			state = false
		end
	end	
	if state then
		KnockBackPos[id] = {x,y}
	end
end
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht