Forum

> > CS2D > Scripts > Check how many buildings by Player X
Forums overviewCS2D overview Scripts overviewLog in to reply

English Check how many buildings by Player X

2 replies
To the start Previous 1 Next To the start

old Check how many buildings by Player X

Sarinoo
User Off Offline

Quote
Hello
How can I check how many buildings are on map from Player X (for example: Player 3 or Player 4).

I dont care about building type^^ just about count

Thanks

old Re: Check how many buildings by Player X

DC
Admin Off Offline

Quote
Use cs2d lua cmd object

Untested:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function getBuildingCount(player)
	local count = 0
	local objectlist = object(0,"table")
	for _,id in pairs(objectlist) do
		-- only count building types
		if (object(id, "type") < 20) then
			-- only count buildings belonging to the player
			if (object(id, "player") == player) then
				count = count + 1
			end
		end
	end
	return count
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview