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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
--tested
-- http://www.cs2d.com/entities.php
mc = {}
mc.costsT = 400
mc.costsCT = 600
mc.molotovId = 73
mc.buyTime = 510 -- buytime in seconds (510 = 15 sec. in-game [for 30 sec. change to 1020 and so on])
mc.timerBuy = 0 -- counter from startround
mc.player = {} -- [id] = true/false ; did player buy molotov already?
-- BUY TIMER
parse("mp_buytime "..mc.buyTime)
addhook("startround", "mc.startround")
function mc.startround()
addhook("serveraction","mc.serveraction")
addhook("second","mc.second")
parse("mp_buytime "..mc.buyTime/60)
mc.timerBuy = 0
mc.player = {} -- delete old buy status
end
function mc.second()
	 for id = 1,32 do
		 mc.timerBuy = mc.timerBuy + 1
		 if (mc.timerBuy >= mc.buyTime) then
		 freehook("serveraction", "mc.serveraction")
		 freehook("second", "mc.second")
		 end
	 end
end
-- MOLOTOV BUY
function mc.serveraction(id, b)
	if (b==2) then
		if player(id,"team") == 1 then
		mc.doStuff(id, 0) -- entity 0 = tt spawn
		else
		mc.doStuff(id, 1) -- entity 1 = ct spawn
		end
	end
end
function mc.doStuff(id, team)
	if player(id,"team") == 1 then
		if (player(id,"money") >= mc.costsT) then
			if (mc.player[id] ~= true) then
				if (inentityzone(player(id,"tilex"), player(id,"tiley"), team) == true) then
					parse("setmoney "..id.." "..player(id,"money") - mc.costsT)
					parse("equip "..id.." "..mc.molotovId)
					parse("setweapon "..id.." "..mc.molotovId)
					parse('sv_soundpos "/items/pickup.wav" '..player(id,'x')..' '..player(id,'y')..'')
					mc.player[id] = true
				else
				msg2(id,"\169255000000You are not in a buyzone@C")
				end
			else
			msg2(id,"\169255000000Grenade rebuying is not allowed on this server@C")	
			end
		else
		msg2(id,"\169255000000You have insufficient funds@C")
		end
	else
		if (player(id,"money") >= mc.costsCT) then
			if (mc.player[id] ~= true) then
				if (inentityzone(player(id,"tilex"), player(id,"tiley"), team) == true) then
				parse("setmoney "..id.." "..player(id,"money") - mc.costsCT)
				parse("equip "..id.." "..mc.molotovId)
				parse("setweapon "..id.." "..mc.molotovId)
				parse('sv_soundpos "/items/pickup.wav" '..player(id,'x')..' '..player(id,'y')..'')
				mc.player[id] = true
				else
				msg2(id,"\169255000000You are not in a buyzone@C")
				end
			else
			msg2(id,"\169255000000Grenade rebuying is not allowed on this server@C")	
			end
		else
		msg2(id,"\169255000000You have insufficient funds@C")
		end
	end
end