Forum

> > CS2D > Scripts > how to not get the 2000 money after every round?
Forums overviewCS2D overview Scripts overviewLog in to reply

English how to not get the 2000 money after every round?

4 replies
To the start Previous 1 Next To the start

old Re: how to not get the 2000 money after every round?

Bowlinghead
User Off Offline

Quote
You can delete it in the same second!
1
2
3
4
5
6
addhook("endround","er")
function er()
	for _, id in ipairs(player(0,"tableliving")) do
		parse("setmoney "..id.." "..(player(id,"money")-2000))
	end
end

You probably need more use-cases because the winner team is probably going to get more money than the loosing team. Also it depends on the exact win condition I think (which gamemode; wether bomb planted/defused or all enemys killed; wins in a row; etc)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
addhook("endround","er")
function er(m)
	if (m==1) then -- TT wins
		-- Reduce money for all Terrors
		for _, id in ipairs(player(0,"team1living")) do
			parse("setmoney "..id.." "..(player(id,"money")-2200)) -- TTs loose more
		end
		-- Reduce all money for all Counter-Terrors
		for _, id in ipairs(player(0,"team12living")) do
			parse("setmoney "..id.." "..(player(id,"money")-1800)) -- CTs less
		end
	elseif (m==2) then -- CT wins

	elseif (...) then
	
	...
	
	end
end

cs2d lua cmd player
cs2d lua hook endround
edited 1×, last 05.12.21 09:32:40 am

old Re: how to not get the 2000 money after every round?

Bowlinghead
User Off Offline

Quote
Ok, thanks for the hint @user mrc

Here is the way easier script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
--untested
local playerMoneyzz = {}

addhook("endround","OnEndround")
function OnEndround()
	playerMoneyzz = {}; -- reset table
	for _, id in ipairs(player(0,"table")) do
		playerMoneyzz[id] = player(id,"money");
	end

end


addhook("startround","OnStartround")
function OnStartround()
	for id,euros in pairs(playerMoneyzz) do
		parse("setmoney "..id.." "..euros)
	end
end

addhook("leave","OnLeave")
function OnLeave(id)
	playerMoneyzz[id] = nil; -- delete money value if someone leaves
end

Note that this only works because the endround money is given to you at the start of the next round!
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview