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
addhook("join","_join") --Loads user data from rankfolder
addhook("kill","_kill") --Adds 1 to the users table, and if the rank is different after adding 1 it will message indicating the new rank
addhook("leave","_leave") --Saves user data to rankfolder
addhook("team","_team") --Indicates rank
addhook("spawn","_spawn") --Spawning Weapons
addhook("die","_die") --No Death Drop
rankfolder="sys/lua/ranks/" --Where kills are saved
tRanks={ --ranks
["Small jobs man"]=0,
["Handgun owner/user"]=10,
["Terrorist Ground Force"]=20,
["Mac owner/user"]=30,
["Galil owner/user"]=50,
["AK 45 owner/user"]=100,
["Sniper owner/user"]=150,
["Explosive Expert"]=300,
["Terrorist Kindral"]=400,
["Terrorist General"]=600,
--["Name of Rank"]=Number of Kills--
}
ctRanks={ --ranks
["Private"]=0,
["Private 2"]=10,
["Private First Class"]=20,
["Specialist"]=30,
["Corporal"]=40,
["Sergeant"]=50,
["Staff Sergeant"]=60,
["Sergeant First Class"]=70,
["Master Sergeant"]=80,
["First Sergeant"]=90,
["Sergeant Major"]=100,
["Command Sergeant Major"]=120,
["Sergeant Major of the Army"]=150,
["Warrant Officer"]=200,
["Chief Warrant Officer 2"]=250,
["Chief Warrant Officer 3"]=320,
["Chief Warrant Officer 4"]=350,
["Chief Warrant Officer 5"]=400,
["Second Lieutenant"]=520,
["First Lieutenant"]=750,
["Captain"]=900,
["Major"]=1000,
["Lieutenant Colonel"]=1200,
["Colonel"]=1500,
["Brigadier General"]=2000,
["Major General"]=3000,
["Lieutenant General"]=5000,
["General"]=10000,
["General of the Army"]=20000,
--["Name of Rank"]=Number of Kills--
}
classWpns={ --weapons
["Small jobs man"]={51,52,53,2},
["Handgun owner/user"]={51,52,53,3,41},
["Terrorist Ground Force"]={51,52,53,3},
["Mac owner/user"]={51,52,53,23,22},
["Galil owner/user"]={51,52,53,38,3},
["AK 45 owner/user"]={51,52,53,3,30},
["Sniper owner/user"]={51,52,53,3,35},
["Explosive Expert"]={51,52,53,3,47},
["Terrorist Kindral"]={51,52,53,3,48},
["Terrorist General"]={51,52,53,3,45},
--["Name of Rank"]={Weapon1,Weapon2,Weapon3}--
}
teams={
"T.O.W", --Terrorist
"U.S Army", --Counter-Terrorist
}
users={} --users[id] is the number of kills
function _join(id) --Loads user data from rankfolder
if player(id,"usgn")~=0 then --Only if you have a usgn
users[id]=tonumber(loaddata(rankfolder..player(id,"usgn")..".txt")) or 0 --If you don't have data, place your kill start to 0
end
end
function _kill(killer,victim) --Adds 1 to the users table, and if the rank is different after adding 1 it will message indicating the new rank
if player(killer,"usgn")~=0 then --Only if you have a usgn
users[killer]=users[killer]+1 --add 1 kill
if torank(users[killer]-1,player(killer,"team"))~=torank(users[killer],player(killer,"team")) then --if you rank is different
msg(string.char(169).."255255255"..player(killer,"name").." is now rank: "..torank(users[killer],player(killer,"team")).."!") --show the message
end
end
end
function _leave(id) --Saves user data to rankfolder
if player(id,"usgn")~=0 then --Only if you have a usgn
savedata(rankfolder..player(id,"usgn")..".txt",users[id]) --save function
end
end
function _team(id,team) --Indicates rank
if player(id,"usgn")~=0 then --Only if you have a usgn
if torank(users[id],team) then --If the rank is not nil or false
msg(string.char(169).."255255255Player ("..player(id,"name")..") ("..torank(users[id],team)..") JOINS ("..teams[team]..")") --show the rank
end
end
end
function savedata(path,data) --simple save function
file=io.open(path,"w") --open the path
file:write(data) --write data
file:close() --close path
end
function loaddata(path) --simple load function
file=io.open(path,"r") --read path
if not file then return false end --if path does not exist return false
local data=file:read("*all") --set data as the read data
file:close() --close path
return data --return the loaded file data
end
function torank(kills,team) --turn the number of kills to the rank
if team==1 then
ranks=tRanks
else
ranks=ctRanks
end
local final=false --if a rank is not found, false is returned
local kill=-1 --the rank is accumulative, so the best rank is returned
for rankname,rank in pairs(ranks) do --loop through all the ranks
if kills>=rank and rank>kill then --if you have more kills than the rank, and the rank is better than your current rank
kill=rank --set your current rank
final=rankname --set your final rank
end
end
return final --return it
end
function _spawn(id) --Spawning Weapons
local weapons=classWpns[torank(id)] --get number or table
if weapons~=nil then --if the rank is set
if type(weapons)=="table" then --if it's more than 1 weapon
for _,weapon in pairs(weapons) do --loop through all the weapons
parse("equip "..id.." "..weapon) --equip it
end
else --only 1 weapon
parse("equip "..id.." "..weapon) --equip that 1 weapon
end
end
end
function _die(id) --No Deathdrop
return 1 --by returning 1
end