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
function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end
dh.credits = initArray(32)
dh.expcred = initArray(32)
function credits(id)
parse('hudtxt2 '..id..' 1 "©255125000Credits: '..dh.credits[id]..'" 450 425')
end
addhook("kill","dh.getcred")
function dh.getcred(id,victim,weapon,y,x)
		dh.credits[id]=dh.credits[id]+1
	end
addhook("spawn","dh.spawn")
function dh.spawn(id)
credits(id)
end
addhook("menu","dh.menu")
function dh.menu(id,men,sel)
	if (men=="Buy Menu") then
		if (sel==0) then
		end
		if (sel==1) then
			if dh.credits[id] >= 4 then
				dh.credits[id]=dh.credits[id]-4
				parse("sethealth "..id.." 250")
				credits(id)
			else
				msg2(id,"©255000000Not enough Credits!@C")
			end
		end
		if (sel==2) then
			if dh.credits[id] >= 17 then
					dh.credits[id]=dh.credits[id]-17
					parse("equip "..id.." 87")
					credits(id)
				else
					msg2(id,"©255000000Not enough Credits!@C")
			end
		end
		if (sel==3) then
			if dh.credits[id] >= 17 then
					dh.credits[id]=dh.credits[id]-17
					parse("equip "..id.." 32")
					credits(id)
				else
					msg2(id,"©255000000Not enough Credits!@C")
			end
		end
		if (sel==4) then
			if dh.credits[id] >= 20 then
					dh.credits[id]=dh.credits[id]-20
					parse("equip "..id.." 47")
					credits(id)
				else
					msg2(id,"©255000000Not enough Credits!@C")
			end
		end
		if (sel==5) then
			if dh.credits[id] >= 17 then
					dh.credits[id]=dh.credits[id]-17
					parse("equip "..id.." 79")
					credits(id)
				else
					msg2(id,"©255000000Not enough Credits!@C")
			end
		end
		if (sel==6) then
			if dh.credits[id] >= 10 then
					dh.credits[id]=dh.credits[id]-10
					parse("equip "..id.." 80")
					credits(id)
				else
					msg2(id,"©255000000Not enough Credits!@C")
			end
		end
		if (sel==7) then
			if dh.credits[id] >= 25 then
					dh.credits[id]=dh.credits[id]-25
					parse("equip "..id.." 82")
					credits(id)
				else
					msg2(id,"©255000000Not enough Credits!@C")
			end
		end
	end
	if (men=="Commands Menu") then
		if (sel<=0) then
		end
		if (sel==3) then
		msg2(id,"©000255000dh_give_credits <id> <credits>@C")
		end
	end
end
function dh.buymenu(id)
menu(id,"Buy Menu,HP remake|4 Credits,Laser mines|17 Credits,M4A1|17 Credits,RPG|20 Credits,Light armor|17 Credits,USP|10 Credits,Laser|25 Credits")
end
addhook("serveraction","dh.sa")
function dh.sa(id,act)
	if (act<=1) then
	dh.buymenu(id)
end
end
function string.split(t,b)
	local cmd = {}
	local match = "[^%s]+"
	if type(b) == "string" then match = "[^"..b.."]+" end
	for word in string.gmatch(t, match) do table.insert(cmd, word) end
	return cmd
end
function save(id)
usgn = player(id,"usgn")
if (usgn > 0) then
save_data = dh.credits[id]
file = assert(io.open("sys/lua/dh/"..usgn..".txt","w")) -- edit the sys/lua/bf3/data to the file when the player save
file:write(save_data)
file:close()
msg2(id,"©000255000Save Succesfull!@C")
else
msg2(id,"©255000000Failed to Save!@C")
msg2(id,"©255000000Login Your U.S.G.N First!@C")
end
end
function load(id)
local usgn = player(id,"usgn")
if usgn > 0 then
files = io.open("sys/lua/dh/"..usgn..".txt","r")
if files then
msg2(id,"©160160255Your U.S.G.N ID: "..usgn.."@C")
msg2(id,"©000255000Your Save file found!@C")
parse('hudtxt2 '..id..' 49 "©000255000Login as: '..usgn..'" 40 415')
local parses = totable(files:read("*a"))
dh.credits = tonumber(parses[1])
else
msg2(id,"©255000000Failed to load save!@C")
msg2(id,"©255000000Please check your U.S.G.N account settings!@C")
parse('hudtxt2 '..id..' 49 "©255000000Failed to Load Save" 40 415')
end
files:close()
else
parse('hudtxt2 '..id..' 49 "©255000000Failed to Login!" 40 415')
msg2(id,"©255000000Please check your U.S.G.N account settings!@C")
end
end
addhook("join","wata")
function wata(id)
load(id)
end
addhook("leave","sekunda")
function sekunda(id)
save(id)
end
Let's get to work lol.