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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
----------------------------------------------------------
-- Advanced Buying Menu
-- Script by FastLine Advance
-- June 2010
----------------------------------------------------------
if bm == nil then bm = {} end
bm.item = {}
bm.id = {}
----------------------------------------
-- Example to add item to menu:
-- bm.item[1] = {id,price,name}
-- bm.item[2] = {id,price,name}
-- ...etc
-- Maximum items is 252
----------------------------------------
bm.price_factor = 1.0
bm.item[1] = {1,itemtype(1,'price'),itemtype(1,'name')}
bm.item[2] = {2,itemtype(2,'price'),itemtype(2,'name')}
bm.item[3] = {3,itemtype(3,'price'),itemtype(3,'name')}
bm.item[4] = {4,itemtype(4,'price'),itemtype(4,'name')}
bm.item[5] = {5,itemtype(5,'price'),itemtype(5,'name')}
bm.item[6] = {6,itemtype(6,'price'),itemtype(6,'name')}
bm.item[7] = {10,itemtype(10,'price'),itemtype(10,'name')}
bm.item[8] = {11,itemtype(11,'price'),itemtype(11,'name')}
bm.item[9] = {20,itemtype(20,'price'),itemtype(20,'name')}
bm.item[10] = {21,itemtype(21,'price'),itemtype(21,'name')}
bm.item[11] = {22,itemtype(22,'price'),itemtype(22,'name')}
bm.item[12] = {23,itemtype(23,'price'),itemtype(23,'name')}
bm.item[13] = {24,itemtype(24,'price'),itemtype(24,'name')}
bm.item[14] = {30,itemtype(30,'price'),itemtype(30,'name')}
bm.item[15] = {31,itemtype(31,'price'),itemtype(31,'name')}
bm.item[16] = {32,itemtype(32,'price'),itemtype(32,'name')}
bm.item[17] = {33,itemtype(33,'price'),itemtype(33,'name')}
bm.item[18] = {34,itemtype(34,'price'),itemtype(34,'name')}
bm.item[19] = {35,itemtype(35,'price'),itemtype(35,'name')}
bm.item[20] = {36,itemtype(36,'price'),itemtype(36,'name')}
bm.item[21] = {37,itemtype(37,'price'),itemtype(37,'name')}
bm.item[22] = {38,itemtype(38,'price'),itemtype(38,'name')}
bm.item[23] = {39,itemtype(39,'price'),itemtype(39,'name')}
bm.item[24] = {40,itemtype(40,'price'),itemtype(40,'name')}
bm.item[25] = {57,650,'Kevlar'}
bm.item[26] = {58,1000,'Kevlar + Helm'}
bm.item[27] = {51,300,'HE Grenade'}
bm.item[28] = {52,400,'2 Flashbangs'}
bm.item[29] = {53,300,'Smoke Grenade'}
bm.item[30] = {54,200,'Flare'}
bm.item[31] = {72,950,'Gas Grenade'}
bm.item[32] = {73,800,'Molotov Coctail'}
bm.item[33] = {76,1050,'Airstrike'}
bm.item[34] = {46,9000,'Flamethrower'}
bm.item[35] = {48,13000,'Rocket Launcher'}
bm.item[36] = {49,6500,'Grenade Launcher'}
bm.item[37] = {69,1000,'Machete'}
bm.item[38] = {85,1800,'Chainsaw'}
bm.item[39] = {77,5000,'Mines'}
bm.item[40] = {87,8000,'Laser Mines'}
bm.item[41] = {79,1350,'Light Armor'}
bm.item[42] = {80,4000,'Medium Armor'}
bm.item[43] = {81,8500,'Heavy Armor'}
bm.item[44] = {82,6000,'Medic Armor'}
bm.item[45] = {84,4800,'Stealth Suit'}
-----------------------------------------------------------
-- To call buying menu player should
-- press 3rd serveraction button
-- (F4 by default)
-----------------------------------------------------------
addhook("startround","bm.strt")
function bm.strt()
for i=1,#player(0,"table") do
	msg2(i,"©125175190PUNG CHEW!@C")
end
end
-- Say Commands
-- !buy <id> <id2> <id3> <id4> <id5>
-- Players can buy 5 items by means of this say command
-- Example: !buy 7 3 27 - it is M3, Deagle and HE
-----------------------------------------------------------
for i = 1,255 do
if bm.item[i] ~= nil then
bm.item[i][2] = bm.item[i][2] * bm.price_factor
bm.item[i][2] = math.floor(bm.item[i][2])
end
end
function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
function toTable(t,match)
local cmd = {}
if not match then
match = "[^%s]+"
else
match = "[^"..match.."]+"
end
for word in string.gmatch(t, match) do
table.insert(cmd, word)
end
return cmd
end
sel_page = initArray(32)
buy_item = initArray(32)
for i = 1,255 do
if bm.item[i] ~= nil then
bm.id[i] = '$['..i..'] '..bm.item[i][3]..' | '..bm.item[i][2]..''
else
bm.id[i] = ''
end
end
function bm.menu(id,page)
idnum = page * 7
menu(id,'Buying Menu - '..page..','..bm.id[idnum - 6]..','..bm.id[idnum - 5]..','..bm.id[idnum - 4]..','..bm.id[idnum - 3]..','..bm.id[idnum - 2]..','..bm.id[idnum - 1]..','..bm.id[idnum]..',==> NEXT ==>,<== BACK <==')
end
addhook('buy','bm.buymenu')
addhook('serveraction','bm.actionmenu')
addhook('menu','bm.menuselect')
addhook('spawn','bm.buymenuonspawn')
addhook('say','bm.say')
function bm.buymenu(id)
sel_page[id] = 1
bm.menu(id,1)
return 1
end
function bm.buymenuonspawn(id)
sel_page[id] = 1
bm.menu(id,1)
end
function bm.actionmenu(id,a)
if a == 3 then
sel_page[id] = 1
bm.menu(id,1)
end
end
function bm.menuselect(id,title,select)
if string.find(title,'Buying Menu - ') ~= nil then
if select == 8 then
sel_page[id] = sel_page[id] + 1
if sel_page[id] > 36 then sel_page[id] = 1 end
bm.menu(id,sel_page[id])
end
if select == 9 then
sel_page[id] = sel_page[id] - 1
if sel_page[id] < 1 then sel_page[id] = 36 end
bm.menu(id,sel_page[id])
end
for i = 1,7 do
if select == i then
if i == 1 then ie = 6 end
if i == 2 then ie = 5 end
if i == 3 then ie = 4 end
if i == 4 then ie = 3 end
if i == 5 then ie = 2 end
if i == 6 then ie = 1 end
if i == 7 then ie = 0 end
buy_item_p = bm.item[sel_page[id] * 7 - ie]
bm.buy(id,buy_item_p)
end
end
end
end
function bm.say(id,txt)
local text = toTable(txt)
local num = text[2]
local num2 = text[3]
local num3 = text[4]
local num4 = text[5]
local num5 = text[6]
if text[1] == '!buy' then
if num ~= nil then
buy_item_p = bm.item[tonumber(num)]
bm.buy(id,buy_item_p)
end
if num2 ~= nil then
buy_item_p = bm.item[tonumber(num2)]
bm.buy(id,buy_item_p)
end
if num3 ~= nil then
buy_item_p = bm.item[tonumber(num3)]
bm.buy(id,buy_item_p)
end
if num4 ~= nil then
buy_item_p = bm.item[tonumber(num4)]
bm.buy(id,buy_item_p)
end
if num5 ~= nil then
buy_item_p = bm.item[tonumber(num5)]
bm.buy(id,buy_item_p)
end
end
end
function bm.buy(id,buy_item_p)
local item = buy_item_p
local price = item[2]
local name = item[3]
local item_id = item[1]
local money = player(id,'money')
if money >= price then
parse('equip '..id..' '..item_id)
parse('setmoney '..id..' '..money - price)
msg2(id,'You have bought '..name..' for '..price..'$')
else
msg2(id,'You do not have enough money fool!') --Sounds way better
end
end