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
--Achievements
	if ach == nil then ach={} end
function toTable(t,match)
	local cmd = {}
	if not match then match = "[^%s]+" end
		for word in string.gmatch(t, match) do
		table.insert(cmd, word)
	end
	return cmd
end
function hook_spawn_ach(i)
	hook_join_ach(i)
end
function hook_join_ach(i)
usgn = player(i,"usgn")
	if player(i,"exists") then
		if player(i,"usgn") > 0 then
files = io.open("sys/lua/Test4Lua/"..usgn..".txt","r")
if(files~=nil) then
	msg2(p,"©050255000 Usgn found. Usgn: "..usgn.." Achievments found.")
for line in io.lines("sys/lua/Test4Lua/"..usgn..".cfg","r") do
local parses = toTable(line)
if (tonumber(parses[1])==usgn) then
ach.quickfeet[i] = tonumber(parses[2])
ach.kills[i] = tonumber(parses[3])
ach.deaths[i] = tonumber(parses[4])
ach.knife[i] = tonumber(parses[5])
break
end
end
else
		msg2(p,"©000255050 Usgn: 0 No Achievements found.@C")
	ach.quickfeet[i] = 0
	ach.kills[i] = 0
	ach.deaths[i] = 0
	ach.knife[i] = 0
			end
		end
	end
end
function hook_move_quickfeet(i)
	ach.quickfeet[i] = ach.quickfeet[i] + 1
	if ach.quickfeet[i] == 100 then
		msg2(i,"©200020100Achievement: Walking.@C")
		msg2(i,"©200050050Earned by Slowly Walking 100 steps.@C")
	end
	if ach.quickfeet[i] == 1000 then
		msg2(i,"©200020100Achievement: SpeedWalking.@C")
		msg2(i,"©200050050Earned by Walking 1000 steps.@C")
	end
	if ach.quickfeet[i] == 10000 then
		msg2(i,"©200020100Achievement: Track Runner.@C")
		msg2(i,"©200050050Earned by Running 10000 steps.@C")
	end
	if ach.quickfeet[i] == 100000 then
		msg2(i,"©200020100Achievement: Track Star.@C")
		msg2(i,"©200050050Earned by Walking 100000 steps.@C")
	end
	if ach.quickfeet[i] == 1000000 then
		msg2(i,"©200020100Achievement: World Record Holder.@C")
		msg2(i,"©200050050Earned by Running 1000000 steps.@C")
	end
	if ach.quickfeet[i] == 10000000 then
		msg2(i,"©200020100Achievement: Running Faster than Usain Bolt.@C")
		msg2(i,"©200050050Earned by Running 10000000 steps.@C")
	end
end
function hook_kill_kills(i,v,w)
	if w ~= 50 then
		ach.kills[i] = ach.kills[i] + 1
	else
		ach.knife[i] = ach.knife[i] + 1
	end
	if ach.kills[i] == 1 then
		msg2(i,"©200020100Achievement: First Blood@C")
		msg2(i,"©200050050Earned by Killing your First Victim.@C")
	end
	if ach.kills[i] == 10 then
		msg2(i,"©200020100Achievement: Gunman@C")
		msg2(i,"©200050050Earned by Killing 10 people.@C")
	end
	if ach.kills[i] == 100 then
		msg2(i,"©200020100Achievement: Marksman@C")
		msg2(i,"©200050050Earned by Killing 100 people.@C")
	end
	if ach.kills[i] == 1000 then
		msg2(i,"©200020100Achievement: Master Assassin@C")
		msg2(i,"©200050050Earned by Killing 1000 people.@C")
	end
	if ach.knife[i] == 1 then
		msg2(i,"©200020100Achievement: Knife Accident@C")
		msg2(i,"©200050050Earned by Killing Someone with a Knife.@C")
	end
	if ach.knife[i] == 10 then
		msg2(i,"©200020100Achievement: Stickup Kid@C")
		msg2(i,"©200050050Earned by Killing with a Knife 10 times.@C")
	end
	if ach.knife[i] == 100 then
		msg2(i,"©200020100Achievement: Butcher@C")
		msg2(i,"©200050050Earned by Killing with a Knife 100 times.@C")
	end
	if ach.knife[i] == 1000 then
		msg2(i,"©200020100Achievement: Master Knifer@C")
		msg2(i,"©200050050Earned by Killing with a Knife 1000 times.@C")
	end
end
function hook_die_deaths(i,k,w)
	ach.deaths[i] = ach.deaths[i]+1
	if ach.deaths[i] == 1 then
		msg2(i,"©200020100Achievement: First Death@C")
		msg2(i,"©200050050Earned by Dieing once.@C")
	end
	if ach.deaths[i] == 10 then
		msg2(i,"©200020100Achievement: Weak Suicide-Bomber@C")
		msg2(i,"©200050050Earned by Dieing 10 times.@C")
	end
	if ach.deaths[i] == 100 then
		msg2(i,"©200020100Achievement: Crackhead@C")
		msg2(i,"©200050050Earned by Dieing 100 times.@C")
	end
	if ach.deaths[i] == 1000 then
		msg2(i,"©200020100Achievement: Crazy Suicide-Bomber@C")
		msg2(i,"©200050050Earned by Dieing 1000 times.@C")
	end
	if ach.deaths[i] == 10000 then
		msg2(i,"©200020100Achievement: Death@C")
		msg2(i,"©200050050Earned by Dieing 10000 times.@C")
	end
end
function hook_menu_ach(i,title,button)
	if (title=="Achievements") then
		menu(i,'Achievements,Quickfeet:|'..ach.quickfeet[i]..',Kills:|'..ach.kills[i]..',Deaths:|'..ach.deaths[i]..',Knife-Kills:|'..ach.knife[i]..',.')
	end
end
function hook_serveraction_acha(i,act)
	if (act==1) then
		menu(i,'Achievements,Quickfeet:|'..ach.quickfeet[i]..',Kills:|'..ach.kills[i]..',Deaths:|'..ach.deaths[i]..',Knife-Kills:|'..ach.knife[i]..',.')
	end
end
function hook_leave_acha(i)
local usgn = player(i, "usgn")
if usgn > 0 then
	 if not player(i,"bot") then
local ach = usgn.." "..ach.quickfeet[i].." "..ach.kills[i].." "..ach.deaths[i].." "..ach.knife[i]
file = assert(io.open("sys/lua/Test4Lua/"..usgn..".cfg","w"))
file:write(ach)
file:close()
		end
	end
end
addhook("serveraction","hook_serveraction_acha")
addhook("leave","hook_leave_acha")
addhook("menu","hook_menu_ach")
addhook("die","hook_die_deaths")
addhook("kill","hook_kill_kills")
addhook("move","hook_move_quickfeet")
addhook("join","hook_join_ach")
addhook("spawn","hook_spawn_ach")