Forum

> > CS2D > Scripts > Fast build and Turret
Forums overviewCS2D overview Scripts overviewLog in to reply

English Fast build and Turret

9 replies
To the start Previous 1 Next To the start

old Fast build and Turret

francis007
BANNED Off Offline

Quote
Hey us!

Can somebody make that this script doesn't working for turrets?

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
local pie = {}
pie[1]  = { price = 300 }
pie[2]  = { price = 500 }
pie[3]  = { price = 1000 }
pie[4]  = { price = 2000 }
pie[5]  = { price = 3000 }
pie[6]  = { price = 1500 }
pie[7]  = { price = 5000 }
pie[8]  = pie[7]
pie[9]  = pie[7]
pie[13] = pie[5]
pie[14] = pie[5]

function build_hook(id, type, x, y)
  if not pie[type] then
    return 0
  end

  parse("spawnobject " ..type.. " " ..x.. " " ..y.. " 90 1 " ..player(id, "team").. " " ..id)

  local capitalism = player(id,"money") - pie[type]["price"]
  parse("setmoney " ..id.. " " ..capitalism)

  return 1
end

addhook("build","build_hook")

Thanks!

old Re: Fast build and Turret

DC
Admin Off Offline

Quote
Not sure what you mean. Do you want to make turrets unbuildable via script?

Based on your script take a look at
cs2d lua hook build and http://www.cs2d.com/img/ref_dynamicobjects.png

(level 1) turrets have the type 8.
Your script returns 0 for every building type which is not in the table
pie
. Returning 0 in the build hook cancels building.

So it should be enough to simple remove line 9 (
pie[8]  = pie[7]
) from your script.

old Re: Fast build and Turret

Mami Tomoe
User Off Offline

Quote
Maybe this is what you want:

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
local pie = {}
pie[1]  = { price = 300 }
pie[2]  = { price = 500 }
pie[3]  = { price = 1000 }
pie[4]  = { price = 2000 }
pie[5]  = { price = 3000 }
pie[6]  = { price = 1500 }
pie[7]  = { price = 5000 }
pie[8]  = pie[7]
pie[9]  = pie[7]
pie[13] = pie[5]
pie[14] = pie[5]

addhook("build","build_hook")
function build_hook(id, type, x, y)
	if not type == 8 and not type == 11 and not type == 12 then
		if not pie[type] then
			return 0
		end
		parse("spawnobject " ..type.. " " ..x.. " " ..y.. " 90 1 " ..player(id, "team").. " " ..id)
		local capitalism = player(id,"money") - pie[type]["price"]
		parse("setmoney " ..id.. " " ..capitalism)
		return 1
	end
end
edited 1×, last 13.12.16 06:55:08 pm

old Re: Fast build and Turret

DC
Admin Off Offline

Quote
What does the fastbuild script look like? I assume that both are using the cs2d lua hook build hook. It's probably a priority / return value thing.

old Re: Fast build and Turret

GeoB99
Moderator Off Offline

Quote
Just use cs2d cmd mp_building_limit and set the value limit for turret building as 0. Less hassle and no scripts involved in this.
mp_building_limit "Turret" 0

As soon as you add this setting under // More title through server.cfg and save the file, the changes will take effect.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview