Forum

> > CS2D > Scripts > Fix Script Please
Forums overviewCS2D overview Scripts overviewLog in to reply

English Fix Script Please

1 reply
To the start Previous 1 Next To the start

old Fix Script Please

Obviously Exactly Myself
User Off Offline

Quote
How do I make on Terrorists can buy? I don't know how to script a lua.

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
if bm == nil then bm = {} end
bm.item = {}
bm.id = {}

bm.price_factor = 1.0

bm.item[1] = {58,800,'Kevlar & Helmet'}
bm.item[2] = {52,700,'Flashbang'}
bm.item[3] = {73,1200,'Molotov Cocktail'}
bm.item[4] = {85,2500,'Chainsaw'}
bm.item[5] = {77,3200,'Mines'}
bm.item[6] = {82,8000,'Medic Armor'}
bm.item[7] = {84,7500,'Stealth Suit'}
bm.item[8] = {41,4500,'Tactical Shield'}
bm.item[9] = {72,1100,'Gas Grenade'}
bm.item[10] = {88,12000,'Portal Gun'}
bm.item[11] = {3,1300,'Deagle'}
bm.item[12] = {61,400,'Weapon Ammo'}
bm.item[13] = {62,200,'Pistol Ammo'}
bm.item[14] = {64,300,'Health'}

for i = 1,14 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

addhook('buy','bm.buymenu')
addhook('serveraction','bm.actionmenu')
addhook('menu','bm.menuselect')

function bm.buymenu(id)
sel_page[id] = 1
bm.menu(id,1)
return 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] > 2 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] = 2 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.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]..',Click For More!,Click For More!')
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 have not enough money!')
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview