Forum

> > CS2D > Scripts > LUA question - Undestroyable glitch
Forums overviewCS2D overview Scripts overviewLog in to reply

English LUA question - Undestroyable glitch

6 replies
To the start Previous 1 Next To the start

old LUA question - Undestroyable glitch

Infinite Rain
Reviewer Off Offline

Quote
Hello guys I start making script, but when I try to hit buiding, I dont make damage to building
W - T - F ?!

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
function area(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

function spawnbuild(id,x,y,t)
	parse('spawnobject '..t..' '..x..' '..y..' 0 0 '..player(id, 'team')..' '..id)
end

function array(m)
	local array = {}
	for i = 1, 32 do
		array[i] = 0
	end
return array
end

block = {}

addhook('build', 'mc_build')
function mc_build(id, type, x, y, mode, objectid)
	block[objectid]. image = image("gfx/blood.bmp", x*32, y*32, 1)
end


addhook('objectkill', 'mc_blockdestroy')
function mc_blockdestroy(id, player)
	freeimage(block[id]. block)
end
There is no errors!

old Re: LUA question - Undestroyable glitch

mafia_man
User Off Offline

Quote
Yea he's right i discovered this bug when i making gmod 12, He freeimage objectid
That's makes building like wall

Try this code:
1
2
3
4
addhook('build', 'mc_build')
function mc_build(id, type, x, y, mode, objectid)
     freeimage( objectid)
end

PS. You don't need use build hook you can make it fast build.

Part of my code that return real objid
1
2
3
4
5
6
7
8
9
addhook( "buildattempt", "obj_build")
function obj_build( id, t, x, y)
	parse( 'spawnobject '.. t ..' '.. x ..' '.. y ..' '.. player( id, "rot") ..' 0 '.. player( id, "team") ..' '.. id)
	for _, j in ipairs( object( 0, "table")) do
		if object( j, "tilex") == x and object( j, "tiley") == y then
			objid = j
			break
		end
	end

you won't make good minecraft with arrays, use metatables
edited 1×, last 02.05.11 09:57:08 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview