· 8 years ago · Jan 07, 2018, 10:44 PM
1-- In-Game Stats
2-- By «§H»Kennan{Leader}
3-- With lots of help from Nuggets.
4
5-- Xfire : kenster789
6
7-- This script is an in-game stats script. Will keep track of many things about a player and how they play.
8
9-- Version 1.00 (Beta)
10
11-- TESTERS, PLEASE PUSH IT AS HARD AS YOU CAN, DO WEIRD THINGS AND JUST TEST IT, FEEL FREE TO MESSAGE ME WITH ANY QUESTIONS OR SMALL PROBLEMS YOU MIGHT HAVE FOUND.
12
13
14send_kill_messages = true -- Send the message telling the player/server how a player died?
15
16
17killing_spree_notifications = true -- Notify the server when someone is on a killing spree?
18 -- They do get credits for killing sprees. If this is not enabled they will not receive credits for it?
19
20multi_gametypes = true -- Is your server running multiple gametypes? Will disable and enable stats for each gametype (Fags captured, Time in the Hill, Laps Completed, etc.)
21
22
23
24over_write_score_at_game_end = true -- Do you want to override the player's real score with how many credits they have at the end of the match?
25
26
27
28use_ping_kick = true -- Use the ping kick that is included in this script?
29 pingkick_timeout = 5 -- After this many mintues forget the number of times the script has warned a player. Used for ping kick.
30 warn_server = true -- Tell the server if someone gets kicked for high ping?
31 max_ping = 500 -- max_ping that a player should have.
32
33-- Need to do :
34--
35-- Need to test :
36-- Ping Kick
37
38-- Do the people want :
39-- Accuracy
40------------------------- DON'T TOUCH UNLESS YOU KNOW WHAT YOU ARE DOING. ------------------------------------
41last_damage = {} -- Declare last_damage. Used for kill messages.
42Version_Number = "1.00(Beta)" -- Declare the version number of this script.
43Release_Date = "Date here" -- Declare the release date of this script.
44gametype_base = 0x671340 -- Declare gametype_base. Used to return the "type" of gametype that is loaded.
45oddball_globals = 0x639E58 -- Declare oddball_globals. Used for Multi Gametype Stats.
46koth_globals = 0x639BD0 -- Declare koth_globals. Used for Multi Gametype Stats.
47stat_globals = 0x63989E -- Declare stat_globals. Used for Multi Gametype Stats.
48slayer_globals = 0x63A0E8 -- Declare slayer_globals. Used to over write the player's score.
49jointime = {} -- Declare jointime. Used for a player's time in server.
50time = {} -- Declare time. Used for player's time in server.
51xcoords = {} -- Declare xcoords. Used for distance traveled.
52ycoords = {} -- Declare ycoords. Used for distance traveled.
53zcoords = {} -- Declare zcoords. Used for distance traveled.
54revenge = {} -- Declare revenge. Used for Jack of all Trades medal.
55kills = {} -- Declare kills. Used for Jack of all Trades medal.
56avenge = {} -- Declare avenge. Used for Jack of all Trades medal.
57match = {} -- Declare match. Used to keep track of player's credits for each match.
58done = {} -- Declare done. Used to keep track of the medals a player has completed.
59medals = {} -- Declare medals. Used to keep track of the player's medals.
60warned = {} -- Declare warned. Used to keep track of how many times a player has been warned for their high ping.
61-- Below is for Nugget's hprint function.
62console = {}
63console.__index = console
64registertimer(100, "ConsoleTimer")
65math.inf = 1 / 0
66-- Above is for Nugget's hprint function.
67-----------------------------------------------------------------------------------------------------------------
68
69
70
71
72
73-- Comment for GetRequiredVersion : Required Version of Phasor for this script to be ran.
74function GetRequiredVersion()
75
76 return 10057
77end
78-- Comment for OnScriptLoad : Called when this script is loaded.
79function OnScriptLoad(process)
80
81 weapons = table.load("WeaponKills.txt") -- Load the weapons table from 'WeaponKills.txt' file.
82 stats = table.load("PlayerStats.txt") -- load the stats table from 'PlayerStats.txt' file.
83 medals = table.load("PlayerMedals.txt") -- Lad the medals table from 'PlayerMedals.txt' file.
84 done = table.load("PlayerComplete.txt") -- Load the done table from 'PlayerComplete.txt' file.
85 sprees = table.load("PlayerSprees.txt") -- Load the sprees table from 'PlayerSprees.txt' file.
86
87 if multi_gametypes == true then -- Check to see if multi_gametypes is turned on.
88 gametype = table.load("GametypeStats.txt") -- Load the gametype table from 'GametypeStats.txt' file.
89 end
90
91 if send_kill_messages == true then -- If send_kills_messages is true.
92 kill_message = "Enabled" -- Declare kill_message.
93 else -- If send_kill_messages is not true.
94 kill_message = "Disabled" -- Declare kill_message.
95 end
96
97 if killing_spree_notifications == true then -- If killing_spree_notifications is true.
98 spree_notify = "Enabled" -- Declare spree_notify..
99 else -- If killing_spree_notifications is not true.
100 spree_notify = "Disabled" -- Declare spree_notify.
101 end
102
103 if multi_gametypes == true then -- If multi_gametypes is true.
104 more_gametypes = "Enabled" -- Declare more_gametypes.
105 else -- If multi_gametypes is not true.
106 more_gametypes = "Disabled" -- Declare more_gametypes.
107 end
108
109 profilepath = getprofilepath() -- Get the profile path of the server, used to store changelog.
110
111 local file = io.open(profilepath .. "\\StatsChangeLog.txt", "r") -- Open the changelog File in read only mode.
112 if file then -- Make sure the file exist
113 change_log_wrote = "Yes"
114 else -- If the file does not exist.
115 change_log_wrote = "No"
116 WriteChangeLog() -- Write and make the changelog.
117 end
118
119 if change_log_wrote == "Yes" then -- If change_log_wrote is Yes
120 wrote_log = "The StatsChangeLog.txt is already saved!" -- Declare wrote_log
121 else -- If change_log_wrote does not equal "Yes"
122 wrote_log = "The StatsChangeLog.txt is now saved!" -- Declare wrote_log
123 end
124
125 if over_write_score_at_game_end == true then -- If over_write_score_at_game_end is true.
126 over_ride = "Enabled" -- Declear that it is enabled.
127 else -- If over_write_score_at_game_end is not true.
128 over_ride = "Disabled" -- Declear that it is disabled.
129
130
131 hprintf("---------- Stats Script has been loaded ----------") -- Print info to console when script is loaded.
132 hprintf("---------- Stats Script by Kennan ----------") -- Print info to console when script is loaded.
133 hprintf("---------- Version : " .. Version_Number .. " ----------") -- Print info to console when script is loaded.
134 hprintf("---------------------------------------------------") -- Print info to console when script is loaded.
135 hprintf("Kill Messages : " .. kill_message) -- Print info to console when script is loaded.
136 hprintf("---------------------------------------------------") -- Print info to console when script is loaded.
137 hprintf("Killing Spree Notifictions : " .. spree_notify) -- Print info to console when script is loaded.
138 hprintf("---------------------------------------------------") -- Print info to console when script is loaded.
139 hprintf("Multiple Gametype Stats : " .. more_gametypes) -- Print info to console when script is loaded.
140 hprintf("---------------------------------------------------") -- Print info to console when script is loaded.
141 hprintf(wrote_log) -- Print info to console when script is loaded.
142 hprintf("---------------------------------------------------") -- Print info to console when script is loaded.
143 hprintf("Score Override : " .. over_ride) -- Printf info to the console when the script is loaded.
144 hprintf("---------------------------------------------------") -- Print info to the console when the script is loaded.
145
146 registertimer(18000, "PKTimer") -- Create the ping kick timer.
147 registertimer(pingkick_timeout * 60000, "PTimeout") -- Create the ping timeout timer.
148
149
150
151end
152-- Comment for OnScriptUnload : Called when this script is unloaded.
153function OnScriptUnload()
154
155 table.save(weapons, "WeaponKills.txt") -- Save the weapons table to the 'WeaponKills.txt' file.
156 table.save(stats, "PlayerStats.txt") -- Save the stats table to the "PlayerStats.txt" file.
157
158 if multi_gametypes == true then -- Check to see if multi_gametypes is turned on.
159 table.save(gametype, "GametypeStats.txt") -- Save the gametype table to the "GametypeStats.txt" file.
160 end
161
162 table.save(medals, "PlayerMedals.txt") -- Save the medals table to the "PlayerMedals.txt" file.
163 table.save(done, "PlayerComplete.txt") -- Save the done table to the "PlayerComplete.txt" file.
164 table.save(sprees, "PlayerSprees.txt") -- Save the spees table to the "PlayerSprees.txt" file.
165
166
167end
168-- Comment for OnNewMap : Called when a map begins. No players are in yet.
169function OnNewGame(map)
170
171end
172-- Comment for OnGameEnd : Called when a game is finished. Called 3 times.
173function OnGameEnd(mode)
174 -- Mode 1 : The game just ended (F1 scorecard is being displayed).
175 -- Mode 2 : The post game scorecard is displayed.
176 -- Mode 3 : Players can quit via the post game scorecard.
177
178 if mode == 1 then -- If the mode is 1.
179 registertimer(10, "AssistDelay") -- Create the timer so we can give the player his credits for assist.
180
181 for i = 0, 15 do -- Make a loop for all the players
182 local hash = gethash(i) -- Get the player's hash.
183 if hash then -- If there is a hash.
184 stats[hash].total.gamesplayed = stats[hash].total.gamesplayed + 1 -- Add one to their gamesplayed count.
185 local hash = gethash(i) -- Get the player's hash.
186 time = os.time() - jointime[hash] -- Declare how long their were in the server.
187 stats[hash].total.timeinserver = stats[hash].total.timeinserver + time -- Add their time in this match to their total.
188 end
189 end
190
191 if multi_gametypes == true then -- If multi_gametypes is true.
192 if GetGametype() == "CTF" then -- If the gametype is CTF
193 for i = 0,15 do -- Create a loop for all the players.
194 local m_player = getplayer(i) -- Get the player ID.
195 local captured = readword(m_player, 0xC8) -- Get the player's captured flags. (Flag Scores)
196 local returns = readword(m_player, 0xC6) -- Get the player's returned flags.
197 local grabs = readword(m_player, 0xC4) -- Get the player's grabed flags.
198 if captured and returns and grabs then -- Make sure captured, returns and grabs are not nil. (Does exist)
199 local hash = gethash(i) -- Get the hash of the player.
200 gametype[hash].ctf.grabs = gametype[hash].ctf.grabs + grabs -- Add their grabs to their total amount.
201 gametype[hash].ctf.scores = gametype[hash].ctf.scores + captured -- Add their captured to their total amount.
202 gametype[hash].ctf.returned = gametype[hash].ctf.returned + returns -- Add their returns to their total amount.
203 local credits = (grabs * 2) + (captured * 10) + (returns * 5) -- 2 Credits for flag grabs, 10 credits for flags captured and 5 credits for flags returned.
204 if credits ~= 0 then -- If their credits is not 0.
205 hprint(i, "+" .. credits .. " cR - " .. grabs .. " Flag(s) Grabbed, " .. captured .. " Flag(s) Captured, " .. returns .. " Flag(s) Returned", 5) -- Tell them how many credits they got.
206 match[hash] = match[hash] + credits -- Add credits to their match total.
207 stats[hash].total.credits = stats[hash].total.credits + credits -- Add credits to their total.
208 end
209 end
210 end
211
212 elseif GetGametype() == "FFA Race" then -- If the gametype is Free For All Race.
213 for i = 0,15 do -- Create a loop for all the players.
214 local m_player = getplayer(i) -- Get the player ID.
215 local laps = readword(m_player, 0xC6) -- Get the player's laps.
216 if laps then -- Make sure laps is not nil. (Does exist)
217 local hash = gethash(i) -- Get the player's hash.
218 gametype[hash].race.ffalaps = gametype[hash].race.ffalaps + laps -- Add their laps to their total ffalaps amount.
219 local credits = (laps * 10) -- 10 credits for every completed lap.
220 if credits ~= 0 then -- If their credits is not 0.
221 if laps == 1 then -- If their laps is one.
222 hprint(i, "+" .. credits .. " cR - " .. laps .. " Lap Completed", 5) -- Tell them what they earned.
223 else -- If their laps is not 1.
224 hprint(i, "+" .. credits .. " cR - " .. laps .. " Laps Completed", 5) -- Tell them what they earned.
225 end
226 match[hash] = match[hash] + credits -- Add credits to their match total.
227 stats[hash].total.credits = stats[hash].total.credits + credits -- Add credits to their total.
228 end
229 end
230 end
231
232 elseif GetGametype() == "Team Race" then -- If the gametype is Team Race.
233 for i = 0,15 do -- Create a loop for all the players.
234 local m_player = getplayer(i) -- Get the player ID.
235 local laps = readword(m_player, 0xC6) -- Get the player's laps.
236 if laps then -- Make sure laps is not nil. (Does exist)
237 local hash = gethash(i) -- Get the player's hash.
238 gametype[hash].race.teamlaps = gametype[hash].race.teamlaps + laps -- Add their laps to their total teamlaps amount.
239 local credits = (laps * 10) -- 10 credits for every completed lap.
240 if credits ~= 0 then -- If their credits is not 0.
241 if laps == 1 then -- If their laps is one.
242 hprint(i, "+" .. credits .. " cR - " .. laps .. " Lap Completed", 5) -- Tell them what they earned.
243 else -- If their laps is not 1.
244 hprint(i, "+" .. credits .. " cR - " .. laps .. " Laps Completed", 5) -- Tell them what they earned.
245 end
246 match[hash] = match[hash] + credits -- Add credits to their match total.
247 stats[hash].total.credits = stats[hash].total.credits + credits -- Add credits to their total.
248 end
249 end
250 end
251
252 elseif GetGametype() == "FFA Slayer" then -- If the gametype is Free For All Slayer.
253 for i = 0,15 do -- Create a loop for all the players.
254 local m_player = getplayer(i) -- Get the player ID.
255 local kills = readword(m_player, 0x9C) -- Get the player's kills.
256 if kills then -- Make sure kills is not nil. (Does exist)
257 local hash = gethash(i) -- Get the player's hash.
258 gametype[hash].slayer.ffakills = gametype[hash].slayer.ffakills + kills -- Add their kills to their total ffakills amount.
259 end
260 end
261
262 elseif GetGametype() == "Team Slayer" then -- If the gametype is Team Slayer.
263 for i = 0,15 do -- Create a loop for all the players.
264 local m_player = getplayer(i) -- Get the player ID.
265 local kills = readword(m_player, 0x9C) -- Get the player's kills.
266 if kills then -- Make sure kills is not nil. (Does exist)
267 local hash = gethash(i) -- Get the player's hash.
268 gametype[hash].slayer.teamkills = gametype[hash].slayer.teamkills + kills -- Add their kills to their total teamkills amount.
269 end
270 end
271
272 elseif GetGametype() == "FFA Oddball" then -- If the gametype is FFA Oddball.
273 for i = 0,15 do -- Create a loop for all the players.
274 if getplayer(i) then -- Make sure the player exist.
275 local oddball_real_time = readdword(oddball_globals + i*4, 0x44) -- Get the player's time with the Oddball.
276 if oddball_real_time then -- Make sure oddball_real_time is not nil. (Does exist)
277 local time = oddball_real_time/30 -- Get the total time in seconds.
278 local rounded_time = math.round(time, 0) -- Round the time.
279 if time then -- Make sure time is not nil. (Does exist)
280 local hash = gethash(i) -- Get the player's hash.
281 gametype[hash].oddball.ffatime = gametype[hash].oddball.ffatime + time -- Add their time to their total ffatime amount.
282 local t = math.round(time, 0) -- Round the time.
283 local credits = (t * 2) -- Give them 2 credits for every second they have the oddball.
284 if credits ~= 0 then
285 if time == 1 then -- If their time in the hill is 1.
286 hprint(i, "+" .. credits .. " cR - " .. rounded_time .. " second with the Oddball", 5) -- Make the grammar correct.
287 else -- If their time is not 1.
288 hprint(i, "+" .. credits .. " cR - " .. rounded_time .. " seconds with the Oddball", 5) -- Make the grammar correct.
289 end
290 end
291 match[hash] = match[hash] + credits -- Add credits to their match total.
292 stats[hash].total.credits = stats[hash].total.credits + credits -- Add credits to their total.
293 end
294 end
295 end
296 end
297
298 elseif GetGametype() == "Team Oddball" then -- If the gametype is Team Oddball.
299 for i = 0,15 do -- Create a loop for all the players.
300 if getplayer(i) then -- Make sure the player exist.
301 local oddball_real_time = readdword(oddball_globals + i*4, 0x44) -- Get the player's time with the Oddball.
302 if oddball_real_time then -- Make sure oddball_real_time is not nil. (Does exist)
303 local time = oddball_real_time/30 -- Get the total time in seconds.
304 local rounded_time = math.round(time, 0) -- Round the time.
305 if time then -- Make sure time is not nil. (Does exist)
306 local hash = gethash(i) -- Get the player's hash.
307 gametype[hash].oddball.teamtime = gametype[hash].oddball.teamtime + time -- Add their time to their total ffatime amount.
308 local t = math.round(time, 0) -- Round the time.
309 local credits = (t * 2) -- Give them 2 credits for every second they have the oddball.
310 if credits ~= 0 then -- If their credits is not 0.
311 if time == 1 then -- If their time in the hill is 1.
312 hprint(i, "+" .. credits .. " cR - " .. rounded_time .. " second with the Oddball", 5) -- Make the grammar correct.
313 else -- If their time is not 1.
314 hprint(i, "+" .. credits .. " cR - " .. rounded_time .. " seconds with the Oddball", 5) -- Make the grammar correct.
315 end
316 match[hash] = match[hash] + credits -- Add credits to their match total.
317 stats[hash].total.credits = stats[hash].total.credits + credits -- Add credits to their total.
318 end
319 end
320 end
321 end
322 end
323
324 elseif GetGametype() == "FFA KOTH" then -- If the gametype is Free For All King of the Hill.
325 for i = 0,15 do -- Create a loop for all the players.
326 local m_player = getplayer(i) -- Get the player ID.
327 local king_real_time = readword(m_player, 0xC4) -- Get the player's time in the hill.
328 if king_real_time then -- Make sure king_real_time is not nil. (Does exist)
329 local time = king_real_time/30 -- Get the total time in seconds.
330 local rounded_time = math.round(time, 0) -- Round the time.
331 if time then -- Make sure time is not nil. (Does exist)
332 local hash = gethash(i) -- Get the player's hash.
333 gametype[hash].koth.ffatime = gametype[hash].koth.ffatime + time -- Add their time to their total ffatime amount.
334 local t = math.round(t, 0) -- Round the time.
335 local credits = (time * 2) -- Give them 2 credits for ever second they are in the hill.
336 if credits ~= 0 then -- If their credits is not 0.
337 if time == 1 then -- If their time is 1.
338 hprint(i, "+" .. credits .. " cR - " .. rounded_time .. " second in the Hill", 5) -- Make the grammar correct.
339 else -- If their time is not 1.
340 hprint(i, "+" .. credits .. " cR - " .. rounded_time .. " seconds in the Hill", 5) -- Make the grammar correct.
341 end
342 match[hash] = match[hash] + credits -- Add credits to their match total.
343 stats[hash].total.credits = stats[hash].total.credits + credits -- Add credits to their total.
344 end
345 end
346 end
347 end
348
349 elseif GetGametype() == "Team KOTH" then -- If the gametype is Team King of the Hill.
350 for i = 0,15 do -- Create a loop for all the players.
351 local m_player = getplayer(i) -- Get the player ID.
352 local king_real_time = readword(m_player, 0xC4) -- Get the player's time in the hill.
353 if king_real_time then -- Make sure king_real_time is not nil. (Does exist)
354 local time = king_real_time/30 -- Get the total time in seconds.
355 local rounded_time = math.round(time, 0) -- Round the time.
356 if time then -- Make sure time is not nil. (Does exist)
357 local hash = gethash(i) -- Get the player's hash.
358 gametype[hash].koth.teamtime = gametype[hash].koth.teamtime + time -- Add their time to their total teamtime amount.
359 local t = math.round(time, 0) -- Round the time.
360 local credits = (t * 2) -- Give them 2 credits for ever second they are in the hill.
361 if credits ~= 0 then -- If their credits is not 0.
362 if time == 1 then -- If their time is 1.
363 hprint(i, "+" .. credits .. " cR - " .. rounded_time .. " second in the Hill", 5) -- Make the grammar correct.
364 else -- If their time is not 1.
365 hprint(i, "+" .. credits .. " cR - " .. rounded_time .. " seconds in the Hill", 5) -- Make the grammar correct.
366 end
367 match[hash] = match[hash] + credits -- Add credits to their match total.
368 stats[hash].total.credits = stats[hash].total.credits + credits -- Add credits to their total.
369 end
370 end
371 end
372 end
373 end
374 end
375 end
376
377 if over_write_score_at_game_end == true then -- If over_write_score_at_game_end is true
378 if mode == 3 then -- If the mode is 3.
379 for i = 0,15 do -- Create a loop for the players.
380 local hash = gethash(i) -- Get the player's hash.
381 if match[hash] ~= nil then -- If match[hash] (the number of credits the player has this match) is not nil (Does exist)
382 EditScore(i, match[hash], "=") -- Over Write their score.
383 end
384 end
385 say("Player's scores have been changed to match their total credits for this match.")-- Tell the server what happened.
386 end
387 end
388end
389-- Comment for OnServerChat : Called when a player tries to send a message through chat.
390function OnServerChat(player, chattype, message)
391
392 local Message = string.lower(message) -- Make everything in the string "message" lowercase. Leave other characters alone.
393 local hash = gethash(player) -- Get the hash of the player.
394
395 local t = {} -- Create a table.
396 local count = gettokencount(Message, " ") -- Count how many words are in the string.
397
398 for i = 0,count do -- Create a loop.
399 local word = getcmdtoken(Message, i) -- Declare what word is.
400 table.insert(t, word) -- Insert the word into the table.
401 end
402
403 if t[1] == "@weapons" and t[2] == nil then -- If the first 'word' in the table is "@weapons".
404 privatesay(player, "--------------------")
405 privatesay(player, "Assault Rifle : " .. weapons[hash].count.assaultrifle .. " | Banshee : " .. weapons[hash].count.banshee .. " | Banshee Fuel Rod : " .. weapons[hash].count.bansheefuelrod .. " | Chain Hog : " .. weapons[hash].count.chainhog .. " | EMP Blast : " .. weapons[hash].count.empblast) -- Send the player his weapon stats.
406 privatesay(player, "Fall Damage : " .. weapons[hash].count.falldamage .. " | Flag Melee : " .. weapons[hash].count.flagmelee .. " | Flamethrower : " .. weapons[hash].count.flamethrower .. " | Frag Grenade : " .. weapons[hash].count.fragnade .. " | Fuel Rod : " .. weapons[hash].count.fuelrod) -- Send the player his weapon stats.
407 privatesay(player, "Ghost : " .. weapons[hash].count.ghost .. " | Melee : " .. weapons[hash].count.melee .. " | Needler : " .. weapons[hash].count.needler .. " | Oddball Melee : " .. weapons[hash].count.oddballmelee .. " | Pistol : " .. weapons[hash].count.pistol .. " | Plasma Grenade : " .. weapons[hash].count.plasmanade .. " | Plasma Rilfe : " .. weapons[hash].count.plasmarifle) -- Send the player his weapon stats.
408 privatesay(player, "Plasma Pistol : " .. weapons[hash].count.plasmapistol .. " | Rocket Hog : " .. weapons[hash].count.rockethog .. " | Rocket Launcher : " .. weapons[hash].count.rocketlauncher .. " | Shotgun : " .. weapons[hash].count.shotgun .. " | Sniper Rifle : " .. weapons[hash].count.sniper) -- Send the player his weapon stats.
409 privatesay(player, "Stuck Plasma Grenade : " .. weapons[hash].count.splasmanade .. " | Splatter : " .. weapons[hash].count.splatter .. " | Tank Machine Gun : " .. weapons[hash].count.tankmachinegun .. " | Tank Shell : " .. weapons[hash].count.tankshell .. " | Turret : " .. weapons[hash].count.turret) -- Send the player his weapon stats.
410 privatesay(player, "--------------------")
411 return 0 -- Block the message from being sent to the server.
412 end
413
414
415 if t[1] == "@weapons" then -- If the first 'word' is @weapons.
416 if t[2] then -- If there is a 2nd 'word'
417 local rcon_id = tonumber(t[2]) -- It should be a number, change it to a number so the script can read it as a number.
418 local Player = rresolveplayer(rcon_id) -- Resolve their memory ID from their rcon id.
419 local hash = gethash(Player) -- Get the hash of the Player.
420 if hash then -- If there is a hash.
421 privatesay(player, getname(Player) .. "'s Weapon Stats") -- Send them the Player's name.
422 privatesay(player, "--------------------")
423 privatesay(player, "Assault Rifle : " .. weapons[hash].count.assaultrifle .. " | Banshee : " .. weapons[hash].count.banshee .. " | Banshee Fuel Rod : " .. weapons[hash].count.bansheefuelrod .. " | Chain Hog : " .. weapons[hash].count.chainhog .. " | EMP Blast : " .. weapons[hash].count.empblast) -- Send the player his weapon stats.
424 privatesay(player, "Fall Damage : " .. weapons[hash].count.falldamage .. " | Flag Melee : " .. weapons[hash].count.flagmelee .. " | Flamethrower : " .. weapons[hash].count.flamethrower .. " | Frag Grenade : " .. weapons[hash].count.fragnade .. " | Fuel Rod : " .. weapons[hash].count.fuelrod) -- Send the player his weapon stats.
425 privatesay(player, "Ghost : " .. weapons[hash].count.ghost .. " | Melee : " .. weapons[hash].count.melee .. " | Needler : " .. weapons[hash].count.needler .. " | Oddball Melee : " .. weapons[hash].count.oddballmelee .. " | Pistol : " .. weapons[hash].count.pistol .. " | Plasma Grenade : " .. weapons[hash].count.plasmanade .. " | Plasma Rilfe : " .. weapons[hash].count.plasmarifle) -- Send the player his weapon stats.
426 privatesay(player, "Plasma Pistol : " .. weapons[hash].count.plasmapistol .. " | Rocket Hog : " .. weapons[hash].count.rockethog .. " | Rocket Launcher : " .. weapons[hash].count.rocketlauncher .. " | Shotgun : " .. weapons[hash].count.shotgun .. " | Sniper Rifle : " .. weapons[hash].count.sniper) -- Send the player his weapon stats.
427 privatesay(player, "Stuck Plasma Grenade : " .. weapons[hash].count.splasmanade .. " | Splatter : " .. weapons[hash].count.splatter .. " | Tank Machine Gun : " .. weapons[hash].count.tankmachinegun .. " | Tank Shell : " .. weapons[hash].count.tankshell .. " | Turret : " .. weapons[hash].count.turret) -- Send the player his weapon stats.
428 privatesay(player, "--------------------")
429 return 0 -- Block the message from being sent to the server.
430 end
431 end
432 end
433
434 if Message == "@stats" and t[2] == nil then -- If the message is "@stats".
435 local days, hours, minutes, seconds = secondsToTime(stats[hash].total.timeinserver, 4) -- Get the player's time in the server.
436 local player_kdr -- Create the player_kdr local.
437 if stats[hash].total.kills ~= 0 then -- If the player's kills is not 0.
438 if stats[hash].total.deaths ~= 0 then -- If the player's deaths is not 0.
439 local kdr = stats[hash].total.kills/stats[hash].total.deaths -- Declare the player's kdr.
440 player_kdr = math.round(kdr, 2) -- Round the number.
441 else -- If player's deaths is 0.
442 player_kdr = "No Deaths" -- Tell them they have no deaths.
443 end
444 else -- If the player's kills is 0.
445 player_kdr = "No Kills" -- tell them they have no kills.
446 end
447 privatesay(player, "--------------------")
448 privatesay(player, "Kills : " .. stats[hash].total.kills .. " | Deaths : " .. stats[hash].total.deaths .. " | Assists : " .. stats[hash].total.assists) -- Send the player his stats.
449 privatesay(player, "KDR : " .. player_kdr .. " | Suicides : " .. stats[hash].total.suicides .. " | Betrays : " .. stats[hash].total.betrays) -- Send the player his stats.
450 privatesay(player, "Time in Server : " .. days .. "d " .. hours .. "h " .. minutes .. "m " .. seconds .. "s | Games Played : " .. stats[hash].total.gamesplayed) -- Send the player his stats.
451 privatesay(player, "Longest Kill : " .. math.round(stats[hash].total.longestkill, 2) .. " meter(s) | Distance Traveled : " .. math.round(stats[hash].total.distancetraveled/1000, 2) .. " kilometer(s)") -- Send the player his stats.
452 privatesay(player, "--------------------")
453 return 0 -- Block the message from being sent to the server.
454 end
455
456
457 if t[1] == "@stats" then -- If the first 'word' is @stats.
458 if t[2] then -- If there is a 2nd 'word'
459 local rcon_id = tonumber(t[2]) -- It should be a number, change it to a number so the script can read it as a number.
460 local Player = rresolveplayer(rcon_id) -- Resolve their memory ID from their rcon id.
461 local hash = gethash(Player) -- Get the hash of the Player.
462 if hash then -- If there is a hash.
463 local days, hours, minutes, seconds = secondsToTime(stats[hash].total.timeinserver, 4) -- Get the player's time in the server.
464 local player_kdr -- Create the player_kdr local.
465 if stats[hash].total.kills ~= 0 then -- If the player's kills is not 0.
466 if stats[hash].total.deaths ~= 0 then -- If the player's deaths is not 0.
467 local kdr = stats[hash].total.kills/stats[hash].total.deaths -- Declare the player's kdr.
468 player_kdr = math.round(kdr, 2) -- Round the player's kdr.
469 else -- If the player's deaths is 0.
470 player_kdr = "No Deaths" -- Tell them they have no deaths.
471 end
472 else -- If the player's kills is 0.
473 player_kdr = "No Kills" -- Tell them they have not kills.
474 end
475 privatesay(player, getname(Player) .. "'s Stats") -- Send them the Player's name.
476 privatesay(player, "--------------------")
477 privatesay(player, "Kills : " .. stats[hash].total.kills .. " | Deaths : " .. stats[hash].total.deaths .. " | Assists : " .. stats[hash].total.assists) -- Send the player his stats.
478 privatesay(player, "KDR : " .. player_kdr .. " | Suicides : " .. stats[hash].total.suicides .. " | Betrays : " .. stats[hash].total.betrays) -- Send the player his stats.
479 privatesay(player, "Time in Server : " .. days .. "d " .. hours .. "h " .. minutes .. "m " .. seconds .. "s | Games Played : " .. stats[hash].total.gamesplayed) -- Send the player his stats.
480 privatesay(player, "Longest Kill : " .. math.round(stats[hash].total.longestkill, 2) .. " meter(s) | Distance Traveled : " .. math.round(stats[hash].total.distancetraveled/1000, 2) .. " kilometer(s)")
481 privatesay(player, "--------------------")
482 return 0 -- Block the message from being sent to the server.
483 end
484 end
485 end
486
487 if multi_gametypes == true then -- Make sure multi_gametypes is turned on.
488 if Message == "@gametype" and t[2] == nil then -- If the message is "@gametype" then.
489 if stats[hash].total.gamesplayed >= 1 then -- Make sure the player has played a game. If not they won't have any stats.
490 privatesay(player, "--------------------")
491 privatesay(player, "CTF : Flags Grabbed : " .. gametype[hash].ctf.grabs .. " | Flags Scored : " .. gametype[hash].ctf.scores .. " | Flags Returned : " .. gametype[hash].ctf.returned) -- Send the player his stats.
492 privatesay(player, "Slayer Kills : FFA : " .. gametype[hash].slayer.ffakills .. " | Team : " .. gametype[hash].slayer.teamkills) -- Send the player his stats.
493 privatesay(player, "Race Laps : FFA : " .. gametype[hash].race.ffalaps .. " | Team : " .. gametype[hash].race.teamlaps) -- Send the player his stats.
494 privatesay(player, "Oddball Time with Ball : FFA : " .. math.round(gametype[hash].oddball.ffatime, 2) .. " seconds | Team : " .. math.round(gametype[hash].oddball.teamtime, 2) .. " seconds") -- Send the player his stats.
495 privatesay(player, "KOTH Time In Hill : FFA : " .. math.round(gametype[hash].koth.ffatime, 2) .. " seconds | Team : " .. math.round(gametype[hash].koth.teamtime, 2) .. " seconds") -- Send the player his stats.
496 privatesay(player, "--------------------")
497 return 0 -- BLock the message from being sent to the server.
498 else
499 privatesay(player, "You have not finished playing a match. Finish a match first.") -- If gamesplayed is less then 1 tell them they do not have stats yet.
500 end
501 end
502
503 if t[1] == "@gametype" then -- if the first 'word' is @gametype.
504 if t[2] then -- If there is a 2nd 'word'
505 local rcon_id = tonumber(t[2]) -- It should be a number, change it to a number so the script can read it as a number.
506 local Player = rresolveplayer(rcon_id) -- Resolve their memory ID from their rcon id.
507 local hash = gethash(Player) -- Get the hash of the Player.
508 if hash then -- If there is a hash.
509 if stats[hash].total.gamesplayed >= 1 then -- Make sure the player has played a game. If not they won't have any stats.
510 privatesay(player, getname(Player) .. "'s Gametype Stats") -- Send them the Player's name.
511 privatesay(player, "--------------------")
512 privatesay(player, "CTF : Flags Grabbed : " .. gametype[hash].ctf.grabs .. " | Flags Scored : " .. gametype[hash].ctf.scores .. " | Flags Returned : " .. gametype[hash].ctf.returned) -- Send the player his stats.
513 privatesay(player, "Slayer Kills : FFA : " .. gametype[hash].slayer.ffakills .. " | Team : " .. gametype[hash].slayer.teamkills) -- Send the player his stats.
514 privatesay(player, "Race Laps : FFA : " .. gametype[hash].race.ffalaps .. " | Team : " .. gametype[hash].race.teamlaps) -- Send the player his stats.
515 privatesay(player, "Oddball Time with Ball : FFA : " .. math.round(gametype[hash].oddball.ffatime, 2) .. " seconds | Team : " .. math.round(gametype[hash].oddball.teamtime, 2) .. " seconds") -- Send the player his stats.
516 privatesay(player, "KOTH Time In Hill : FFA : " .. math.round(gametype[hash].koth.ffatime, 2) .. " seconds | Team : " .. math.round(gametype[hash].koth.teamtime, 2) .. " seconds") -- Send the player his stats.
517 privatesay(player, "--------------------")
518 return 0 -- Block the message from being sent to the server.
519 else
520 privatesay(player, getname(Player) .. " has not finished playing a match. Finish a match first.") -- If gamesplayed is less then 1 tell them they do not have stats yet.
521 end
522 end
523 end
524 end
525 end
526
527 if Message == "@medals" and t[2] == nil then-- If the message is @medals or @commendations and t[2] is nil (Doex not exist)
528 privatesay(player, "--------------------")
529 privatesay(player, "Any Spree : " .. medals[hash].class.sprees .. " (" .. medals[hash].count.sprees .. ") | Assistant : " .. medals[hash].class.assists .. " (" .. medals[hash].count.assists .. ") | Close Quarters : " .. medals[hash].class.closequarters .. " (" .. medals[hash].count.assists .. ")") -- Send the player his stats.
530 privatesay(player, "Crack Shot : " .. medals[hash].class.crackshot .. " (" .. medals[hash].count.crackshot .. ") | Downshift : " .. medals[hash].class.downshift .. " (" .. medals[hash].count.downshift .. ") | Grenadier : " .. medals[hash].class.grenadier .. " (" .. medals[hash].count.grenadier .. ")") -- Send the player his stats.
531 privatesay(player, "Heavy Weapons : " .. medals[hash].class.heavyweapons .. " (" .. medals[hash].count.heavyweapons .. ") | Jack of all Trades : " .. medals[hash].class.jackofalltrades .. " (" .. medals[hash].count.jackofalltrades .. ") | Mobile Asset : " .. medals[hash].class.mobileasset .. " (" .. medals[hash].count.moblieasset .. ")") -- Send the player his stats.
532 privatesay(player, "Multi Kill : " .. medals[hash].class.multikill .. " (" .. medals[hash].count.multikill .. ") | Sidearm : " .. medals[hash].class.sidearm .. " (" .. medals[hash].count.sidearm .. ") | Trigger Man : " .. medals[hash].class.triggerman .. " (" .. medals[hash].count.triggerman .. ")") -- Send the player his stats.
533 privatesay(player, "--------------------")
534 return 0 -- Block the message from being sent to the server
535 end
536
537 if t[1] == "@medals" then -- if the first 'word' is @medals or @commendations.
538 if t[2] then -- If there is a 2nd 'word'
539 local rcon_id = tonumber(t[2]) -- It should be a number, change it to a number so the script can read it as a number.
540 local Player = rresolveplayer(rcon_id) -- Resolve their membory ID from their rcon id.
541 local hash = gethash(Player) -- Get the hash of the Player.
542 if hash then -- Make sure there is a hash.
543 privatesay(player, getname(Player) .. "'s Medal Stats")
544 privatesay(player, "--------------------")
545 privatesay(player, "Any Spree : " .. medals[hash].class.sprees .. " (" .. medals[hash].count.sprees .. ") | Assistant : " .. medals[hash].class.assists .. " (" .. medals[hash].count.assists .. ") | Close Quarters : " .. medals[hash].class.closequarters .. " (" .. medals[hash].count.assists .. ")") -- Send the player his stats.
546 privatesay(player, "Crack Shot : " .. medals[hash].class.crackshot .. " (" .. medals[hash].count.crackshot .. ") | Downshift : " .. medals[hash].class.downshift .. " (" .. medals[hash].count.downshift .. ") | Grenadier : " .. medals[hash].class.grenadier .. " (" .. medals[hash].class.grenadier .. ")") -- Send the player his stats.
547 privatesay(player, "Heavy Weapons : " .. medals[hash].class.heavyweapons .. " (" .. medals[hash].count.heavyweapons .. ") | Jack of all Trades : " .. medals[hash].class.jackofalltrades .. " (" .. medals[hash].count.jackofalltrades .. ") | Mobile Asset : " .. medals[hash].class.mobileasset .. " (" .. medals[hash].count.moblieasset .. ")") -- Send the player his stats.
548 privatesay(player, "Multi Kill : " .. medals[hash].class.multikill .. " (" .. medals[hash].count.multikill .. ") | Sidearm : " .. medals[hash].class.sidearm .. " (" .. medals[hash].count.sidearm .. ") | Trigger Man : " .. medals[hash].class.triggerman .. " (" .. medals[hash].count.triggerman .. ")") -- Send the player his stats.
549 privatesay(player, "--------------------")
550 return 0 -- Block the message from being sent to the server
551 end
552 end
553 end
554
555 if Message == "@rank" then -- If the message is "@rank"
556 local hash = gethash(player) -- Get the player's hash.
557 local credits = {} -- Create the credits table.
558 for k,_ in pairs(stats) do -- Loop through the "stats" table.
559 table.insert(credits, {["hash"] = k, ["credits"] = stats[hash].total.credits}) -- Add the player's hash and the player's total credits into the table "credits".
560 end
561
562 table.sort(credits, function(a, b) return a.credits > b.credits end) -- Sort the table.
563
564 for k,v in ipairs(credits) do -- Create a loop for the table "credits".
565 if hash == credits[k].hash then -- If hash is the same hash of the hash key value then.
566 privatesay(player, "--------------------")
567 privatesay(player, "You are ranked " .. k .. " out of " .. #credits .. "!") -- Tell them their rank.
568 privatesay(player, "Credits : " .. stats[hash].total.credits .. " | Rank : " .. stats[hash].total.rank) -- Tell them their rank.
569 privatesay(player, "--------------------")
570 end
571 end
572 return 0 -- Block the message from being sent to the server.
573 end
574
575 if t[1] == "@rank" then -- If the first 'word' is @rank.
576 if t[2] then -- If t[2] exist then.
577 local rcon_id = tonumber(t[2]) -- Turn t[2] into a number (It should already be a number)
578 local Player = rresolveplayer(rcon_id) -- Resolve the player ID from their Rcon ID.
579 if Player then -- If Player exist.
580 local hash = gethash(Player) -- Get the Player's hash.
581 local credits = {}
582 if hash then -- If the Player's hash exist.
583 for k,_ in pairs(stats) do -- Loop through the "stats" table.
584 table.insert(credits, {["hash"] = k, ["credits"] = stats[hash].total.credits}) -- Add the player's hash and the player's total credits into the table "credits".
585 end
586
587 table.sort(credits, function(a, b) return a.credits > b.credits end) -- Sort the table.
588
589 for k,v in ipairs(credits) do -- Create a loop for the table "credits".
590 if hash == credits[k].hash then -- If hash is the same hash of the hash key value then.
591 privatesay(player, "--------------------")
592 privatesay(player, getname(Player) .. " is ranked " .. k .. " out of " .. #credits .. "!") -- Tell them their rank.
593 privatesay(player, "Credits : " .. stats[hash].total.credits .. " | Rank : " .. stats[hash].total.rank) -- Tell them their rank.
594 privatesay(player, "--------------------")
595 end
596 end
597 end
598 end
599 end
600 return 0 -- Block the message from being sent to the server.
601 end
602
603 if Message == "@sprees" then -- If the message is "@sprees".
604 local hash = gethash(player) -- Get the player's hash.
605 privatesay(player, "--------------------")
606 privatesay(player, "Double Kill : " .. sprees[hash].count.double .. " | Triple Kill : " .. sprees[hash].count.triple .. " | Overkill : " .. sprees[hash].count.overkill .. " | Killtacular : " .. sprees[hash].count.killtacular) -- Send the player his stats.
607 privatesay(player, "Killtrocity : " .. sprees[hash].count.killtrocity .. " | Killimanjaro " .. sprees[hash].count.killimanjaro .. " | Killtastrophe : " .. sprees[hash].count.killtastrophe .. " | Killpocalypse : " .. sprees[hash].count.killpocalypse) -- Send the player his stats.
608 privatesay(player, "Killionaire : " .. sprees[hash].count.killionaire .. " | Kiling Spree " .. sprees[hash].count.killingspree .. " | Killing Frenzy : " .. sprees[hash].count.killingfrenzy .. " | Running Riot : " .. sprees[hash].count.runningriot) -- Send the player his stats.
609 privatesay(player, "Rampage : " .. sprees[hash].count.rampage .. " | Untouchable : " .. sprees[hash].count.untouchable .. " | Invincible : " .. sprees[hash].count.invincible) -- Send the player his stats.
610 privatesay(player, "Anomgstopkillingme : " .. sprees[hash].count.anomgstopkillingme .. " | Unfrigginbelievable : " .. sprees[hash].count.unfrigginbelievable) -- Send the player his stats.
611 privatesay(player, "--------------------")
612 return 0 -- Block the message from being sent to the server.
613 end
614
615 if t[1] == "@sprees" then -- If the first 'word' is @sprees.
616 if t[2] then -- If there is a 2nd 'word'
617 local rcon_id = tonumber(t[2]) -- Get the player's rconid.
618 local Player = resolveplayer(rcon_id) -- Resolve the player
619 if Player then -- Make sure the Player exist
620 local hash = gethash(Player) -- Get the Player's hash.
621 if hash then -- Make sure the hash exist.
622 privatesay(player, getname(Player) .. "'s Spree Stats")
623 privatesay(player, "--------------------")
624 privatesay(player, "Double Kill : " .. sprees[hash].count.double .. " | Triple Kill : " .. sprees[hash].count.triple .. " | Overkill : " .. sprees[hash].count.overkill .. " | Killtacular : " .. sprees[hash].count.killtacular) -- Send the player his stats.
625 privatesay(player, "Killtrocity : " .. sprees[hash].count.killtrocity .. " | Killimanjaro " .. sprees[hash].count.killimanjaro .. " | Killtastrophe : " .. sprees[hash].count.killtastrophe .. " | Killpocalypse : " .. sprees[hash].count.killpocalypse) -- Send the player his stats.
626 privatesay(player, "Killionaire : " .. sprees[hash].count.killionaire .. " | Kiling Spree " .. sprees[hash].count.killingspree .. " | Killing Frenzy : " .. sprees[hash].count.killingfrenzy .. " | Running Riot : " .. sprees[hash].count.runningriot) -- Send the player his stats.
627 privatesay(player, "Rampage : " .. sprees[hash].count.rampage .. " | Untouchable : " .. sprees[hash].count.untouchable .. " | Invincible : " .. sprees[hash].count.invincible) -- Send the player his stats.
628 privatesay(player, "Anomgstopkillingme : " .. sprees[hash].count.anomgstopkillingme .. " | Unfrigginbelievable : " .. sprees[hash].count.unfrigginbelievable) -- Send the player his stats.
629 privatesay(player, "--------------------")
630 end
631 end
632 end
633 return 0 -- Block the message from being sent to the server.
634 end
635
636 if Message == "@credits" then -- If the message is @credits.
637 local hash = gethash(player) -- Get the player's hash.
638 if match[hash] ~= nil then -- If match[hash] does not equal nil.
639 if match[hash] ~= 0 then -- If match[hash] does not equal 0.
640 privatesay(player, "You have " .. match[hash] .. " credits for this match!") -- Send them their credits.
641 else -- If match[hash] does equal 0.
642 privatesay(player, "You do not have any credits for this match!") -- Send them their credits.
643 end
644 end
645 return 0 -- Block the message from being sent to the server.
646 end
647
648 if t[1] == "@credits" then -- If the first 'word' is @credits.
649 if t[2] then -- If there is a 2nd word.
650 local rcon_id = tonumber(t[2]) -- Get the player's rcon id.
651 local Player = resolveplayer(rcon_id) -- Resolve the Player.
652 if Player then -- If the Player exist.
653 local hash = gethash(Player) -- Get the Player's hash.
654 if hash then -- If the Player's hash exist.
655 if match[hash] ~= nil then -- If match[hash] does not equal nil.
656 if match[hash] ~= 0 then -- If match[hash] does not equal 0.
657 privatesay(player, getname(Player) .. " has " .. match[hash] .. " credits for this match!") -- Send them their credits.
658 else -- If match[hash] does equal 0.
659 privatesay(player, getname(Player) .. " does not have any credits this match!") -- Send them their credits.
660 end
661 end
662 end
663 end
664 end
665 return 0 -- Block the message from being sent to the server.
666 end
667 return 1
668end
669-- Comment for OnServerCommand : Called when someone tries to execute a command.
670function OnServerCommand(player, command)
671
672 return 1
673end
674-- Comment for OnTeamDecision : Called to decide what a joining player's team will be. Called before they join.
675function OnTeamDecision(team)
676
677 return team
678end
679-- Comment for OnPlayerJoin : Called when a player joins the server.
680function OnPlayerJoin(player, team)
681
682 local hash = gethash(player) -- Get the hash of the player joining.
683
684 -- Create tables used to keep track of kills with each different weapon.
685
686 if weapons[hash] == nil then -- If the weapons[hash] table is nil (Does exist).
687 weapons[hash] = {} -- Create the weapons[hash] table.
688 weapons[hash].count = {} -- Create the weapons[hash].count table. (A table inside of a table.)
689 weapons[hash].count.melee = 0 -- Create melee count table.
690 weapons[hash].count.fragnade = 0 -- Create fragnade count table.
691 weapons[hash].count.plasmanade = 0 -- Create plasmanade count table.
692 weapons[hash].count.splasmanade = 0 -- Create splasmanade count table. (Stuck Plasma Nade)
693 weapons[hash].count.sniper = 0 -- Create sniper count table.
694 weapons[hash].count.shotgun = 0 -- Create shotgun count table.
695 weapons[hash].count.rocketlauncher = 0 -- Create rocketlauncher count table.
696 weapons[hash].count.fuelrod = 0 -- Create fuelrod count table.
697 weapons[hash].count.plasmarifle = 0 -- Create plasmarifle count table.
698 weapons[hash].count.plasmapistol = 0 -- Create plasmapistol count table.
699 weapons[hash].count.empblast = 0 -- Create empblast count table. (Charged Plasma Pistol)
700 weapons[hash].count.pistol = 0 -- Create pistol count table.
701 weapons[hash].count.needler = 0 -- Create needler count table.
702 weapons[hash].count.flamethrower = 0 -- Create flamethrower count table.
703 weapons[hash].count.flagmelee = 0 -- Create flagmelee count table.
704 weapons[hash].count.oddballmelee = 0 -- Create oddballmelee count table.
705 weapons[hash].count.assaultrifle = 0 -- Create assaultrifle count table.
706 weapons[hash].count.chainhog = 0 -- Create chainhog count table.
707 weapons[hash].count.rockethog = 0 -- Create rockethog count table.
708 weapons[hash].count.tankshell = 0 -- Create tankshell count table.
709 weapons[hash].count.tankmachinegun = 0 -- Create tankmachinegun table.
710 weapons[hash].count.ghost = 0 -- Create ghost count table.
711 weapons[hash].count.turret = 0 -- Create turret count table.
712 weapons[hash].count.bansheefuelrod = 0 -- Create bansheefuelrod count table.
713 weapons[hash].count.banshee = 0 -- Create banshee count table.
714 weapons[hash].count.falldamage = 0 -- Create falldamage count table.
715 weapons[hash].count.splatter = 0 -- Create splatter count table.
716 end
717
718 if stats[hash] == nil then -- If the stats[hash] table is nil (Does exist).
719 stats[hash] = {} -- Create the stats[hash] table.
720 stats[hash].total = {} -- Create the stats[hash].total table.
721 stats[hash].total.kills = 0 -- Create the kills total table.
722 stats[hash].total.deaths = 0 -- Create the deaths total table.
723 stats[hash].total.assists = 0 -- Create the assists total table.
724 stats[hash].total.betrays = 0 -- Create the betrays total table.
725 stats[hash].total.suicides = 0 -- Create the suicide total table.
726 stats[hash].total.credits = 0 -- Create the credits total table.
727 stats[hash].total.rank = 0 -- Create the rank total table.
728 stats[hash].total.gamesplayed = 0 -- Create the gamesplayed table.
729 stats[hash].total.timeinserver = 0 -- Create the timeinserver table.
730 stats[hash].total.longestkill = 0 -- Create the longestkill table.
731 stats[hash].total.distancetraveled = 0 -- Create the distancetraveled table.
732 end
733
734 if multi_gametypes == true then
735 if gametype[hash] == nil then -- If the gametype[hash] is nil (Does exist)
736 gametype[hash] = {} -- Create the gametype[hash] table.
737 gametype[hash].ctf = {} -- Create the ctf table.
738 gametype[hash].ctf.grabs = 0 -- Create the ctfgrabs table.
739 gametype[hash].ctf.scores = 0 -- Create the ctfscores table.
740 gametype[hash].ctf.returned = 0 -- Create the ctfreturned table.
741 gametype[hash].race = {} -- Create the race table.
742 gametype[hash].race.ffalaps = 0 -- Create the ffalaps table.
743 gametype[hash].race.teamlaps = 0 -- Create the tamelaps table.
744 gametype[hash].koth = {} -- Create the koth table.
745 gametype[hash].koth.ffatime = 0 -- Create the ffatime table.
746 gametype[hash].koth.teamtime = 0 -- Create the teamtime table.
747 gametype[hash].oddball = {} -- Create the oddball table.
748 gametype[hash].oddball.ffatime = 0 -- Create the ffatime table.
749 gametype[hash].oddball.teamtime = 0 -- Create the teamtime table.
750 gametype[hash].slayer = {} -- Create the slayer table.
751 gametype[hash].slayer.ffakills = 0 -- Create the ffakills table.
752 gametype[hash].slayer.teamkills = 0 -- Create the teamkills table.
753 end
754 end
755
756 if medals[hash] == nil then -- If medals[hash] is nil (Does exist)
757 medals[hash] = {} -- Create the medals table.
758 medals[hash].count = {} -- Create the medal count table.
759 medals[hash].class = {} -- Create the medal class table.
760 medals[hash].count.sprees = 0 -- Create the spree count table.
761 medals[hash].class.sprees = "Iron" -- Create the spree class table.
762 medals[hash].count.assists = 0 -- Create the assists count table.
763 medals[hash].class.assists = "Iron" -- Create the assists class table.
764 medals[hash].count.closequarters = 0 -- Create the closequarters count table.
765 medals[hash].class.closequarters = "Iron" -- Create the closequarters class table.
766 medals[hash].count.crackshot = 0 -- Create the crackshot count table.
767 medals[hash].class.crackshot = "Iron" -- Create the crackshot class table.
768 medals[hash].count.downshift = 0 -- Create the downshift count table.
769 medals[hash].class.downshift = "Iron" -- Create the downshift class table.
770 medals[hash].count.grenadier = 0 -- Create the grenadier count table.
771 medals[hash].class.grenadier = "Iron" -- Create the grenadier class table.
772 medals[hash].count.heavyweapons = 0 -- Create the heavyweapons count table.
773 medals[hash].class.heavyweapons = "Iron" -- Create the heavyweapons class table.
774 medals[hash].count.jackofalltrades = 0 -- Create the jackofalltrades count table.
775 medals[hash].class.jackofalltrades = "Iron" -- Create the jackofalltrades class table.
776 medals[hash].count.moblieasset = 0 -- Create the mobileasset count table.
777 medals[hash].class.mobileasset = "Iron" -- Create the mobileasset class table.
778 medals[hash].count.multikill = 0 -- Create the multikill count table.
779 medals[hash].class.multikill = "Iron" -- Create the multikill class table.
780 medals[hash].count.sidearm = 0 -- Create the sidearm count table.
781 medals[hash].class.sidearm = "Iron" -- Create the sidearm class table.
782 medals[hash].count.triggerman = 0 -- Create the triggerman count table.
783 medals[hash].class.triggerman = "Iron" -- Create the triggetman class table.
784 end
785
786 if done[hash] == nil then -- If the done[hash] is nil. (Does exist)
787 done[hash] = {} -- Create the done table.
788 done[hash].medal = {} -- Create the done medal table.
789 done[hash].medal.sprees = "False" -- Create the medal spree table.
790 done[hash].medal.assists = "False" -- Create the medal assists table.
791 done[hash].medal.closequarters = "False" -- Create the medal closequarters table.
792 done[hash].medal.crackshot = "False" -- Create the medal crackshot table.
793 done[hash].medal.downshift = "False" -- Create the medal downshift table.
794 done[hash].medal.grenadier = "False" -- Create the medal grenadier table.
795 done[hash].medal.heavyweapons = "False" -- Create the medal heavyweapons table.
796 done[hash].medal.jackofalltrades = "False" -- Create the medal jackofalltrades table.
797 done[hash].medal.mobileasset = "False" -- Create the medal mobileasset table.
798 done[hash].medal.multikill = "False" -- Create the mdeal multikill table.
799 done[hash].medal.sidearm = "False" -- Create the medal sidearm table.
800 done[hash].medal.triggerman = "False" -- Create the medal triggerman table.
801 end
802
803 if sprees[hash] == nil then -- If the sprees[hash] is nil. (Does exist)
804 sprees[hash] = {} -- Create the sprees table.
805 sprees[hash].count = {} -- Create the sprees count table.
806 sprees[hash].count.double = 0 -- Create the count double table.
807 sprees[hash].count.triple = 0 -- Create the count triple table.
808 sprees[hash].count.overkill = 0 -- Create the overkill table.
809 sprees[hash].count.killtacular = 0 -- Create the killtacular table.
810 sprees[hash].count.killtrocity = 0 -- Create the killtrocity table.
811 sprees[hash].count.killimanjaro = 0 -- Create the killimanjaro table.
812 sprees[hash].count.killtastrophe = 0 -- Create the killtastrophe table.
813 sprees[hash].count.killpocalypse = 0 -- Create the killpocalypse table.
814 sprees[hash].count.killionaire = 0 -- Create the killionaire table.
815 sprees[hash].count.killingspree = 0 -- Create the killingspree table.
816 sprees[hash].count.killingfrenzy = 0 -- Create the killingfrenzy table.
817 sprees[hash].count.runningriot = 0 -- Create the runningriot table.
818 sprees[hash].count.rampage = 0 -- Create the rampage table.
819 sprees[hash].count.untouchable = 0 -- Create the untouchable table.
820 sprees[hash].count.invincible = 0 -- Create the invincible table.
821 sprees[hash].count.anomgstopkillingme = 0 -- Create the anomgstopkilling table.
822 sprees[hash].count.unfrigginbelievable = 0 -- Create the unfrigginbelivable table.
823 end
824
825
826
827 GetPlayerRank(player) -- Will Declare the rank for every player who joins the server.
828 GetMedalClasses(player) -- Will Declare the class for each medal.
829
830 jointime[hash] = os.time() -- Declare the time the player joins the server.
831
832 local hash = gethash(player) -- Get the player's hash.
833 local m_player = getplayer(player) -- Declare m_player.
834 local objId = readdword(m_player, 0x34) -- Get the player's object ID.
835 local x, y, z = getobjectcoords(objId) -- Get the player's coords.
836
837 xcoords[hash] = x -- Declare their beginning x coord.
838 ycoords[hash] = y -- Declare their beginning y coord.
839 zcoords[hash] = z -- Declare their beginning z coord.
840
841 local hash = gethash(player) -- Get the player's hash.
842 match[hash] = 0 -- Declare their credits for this match as 0.
843
844end
845-- Command for OnPlayerLeave : Called when a player leaves the server.
846function OnPlayerLeave(player, team)
847
848 local hash = gethash(player) -- Get the player's hash.
849 time = os.time() - jointime[hash] -- Declare how long their were in the server.
850 stats[hash].total.timeinserver = stats[hash].total.timeinserver + time -- Add their time in this match to their total.
851
852end
853
854-- Comment for OnPlayerKill : Called everytime a player is killed.
855function OnPlayerKill(killer, victim, mode)
856
857 -- Mode 0 = Player was killed by the server.
858 -- Mode 1 = Player was killed by falling.
859 -- Mode 2 = Player was killed by the guardians.
860 -- Mode 3 = Player was killed by a vehicle.
861 -- Mode 4 = Player was killed by another player.
862 -- Mode 5 = Player was betrayed by another player.
863 -- Mode 6 = Player committed suicide.
864
865 if mode == 4 then -- If the player is killed by another.
866 local hash = gethash(killer) -- Get the killer's hash.
867 local vhash = gethash(victim) -- Get the hash of the victim.
868 local m_player = getplayer(killer) -- Declare m_player.
869 local m_object = getobject(readdword(m_player, 0x34)) -- Declare m_object.
870 local obj_crouch = readbyte(m_object, 0x2A0) -- Declare obj_crouch.
871 local word1, word2 -- Declear word1 and word2.
872 if string.find(last_damage[vhash], "melee") and last_damage[vhash] ~= "weapons\\flag\\melee" and last_damage[vhash] ~= "weapons\\ball\\melee" then -- If we find the word "melee" in the last_damage tag but is not a "flag melee" or an "oddball melee".
873 word1 = "killed" word2 = "with a Melee" -- Declare how they died.
874 weapons[hash].count.melee = weapons[hash].count.melee + 1 -- Add one to their 'melee count'.
875 medals[hash].count.closequarters = medals[hash].count.closequarters + 1 -- Add one to their 'closequarters count'.
876 elseif last_damage[vhash] == "weapons\\frag grenade\\explosion" then -- If the last_damage tag is from a Frag Grenade Explosion.
877 word1 = "killed" word2 = "with a Frag Grenade" -- Declare how they died.
878 medals[hash].count.grenadier = medals[hash].count.grenadier + 1 -- Add one to their 'grenadier count'.
879 weapons[hash].count.fragnade = weapons[hash].count.fragnade + 1 -- Add one to their 'fragnade count'.
880 elseif last_damage[vhash] == "weapons\\plasma grenade\\explosion" then -- If the last_damage tag is from a Plasma Grenade Explosion.
881 word1 = "killed" word2 = "with a Plasma Grenade" -- Declare how they died.
882 medals[hash].count.grenadier = medals[hash].count.grenadier + 1 -- Add one to their 'grenadier count'.
883 weapons[hash].count.plasmanade = weapons[hash].count.plasmanade + 1 -- Add one to their 'plasmanade count'.
884 elseif last_damage[vhash] == "weapons\\plasma grenade\\attached" then -- If the last_damage tag is from a Stuck Plasma Grenade.
885 word1 = "stuck" word2 = "with a Plasma Grenade" -- Declare how they died.
886 medals[hash].count.grenadier = medals[hash].count.grenadier + 1 -- Add one to their 'grenadier count'.
887 weapons[hash].count.splasmanade = weapons[hash].count.splasmanade + 1 -- Add one to their 'splasmanade count'.
888 elseif last_damage[vhash] == "weapons\\sniper rifle\\sniper bullet" then -- If the last_damage tag is from a Sniper Bullet.
889 word1 = "killed" word2 = "with a Sniper Rifle" -- Declare how they died.
890 weapons[hash].count.sniper = weapons[hash].count.sniper + 1 -- Add one to their 'sniper count'.
891 medals[hash].count.crackshot = medals[hash].count.crackshot + 1 -- Add one to their 'crackshot count'.
892 elseif last_damage[vhash] == "weapons\\shotgun\\pellet" then -- If the last_damage tag is from a Shotgun Pellet.
893 word1 = "killed" word2 = "with a Shotgun" -- Declare how they died.
894 weapons[hash].count.shotgun = weapons[hash].count.shotgun + 1 -- Add one to their 'shotgun count'.
895 medals[hash].count.closequarters = medals[hash].count.closequarters + 1 -- Add one to their close quarters count.
896 elseif last_damage[vhash] == "weapons\\plasma_cannon\\effects\\plasma_cannon_explosion" then -- If the last_damage tag is from a Plasma Cannon Explosion (Fuel Rod).
897 word1 = "killed" word2 = "with a Fuel Rod" -- Declare how they died.
898 medals[hash].count.heavyweapons = medals[hash].count.heavyweapons + 1 -- Add one to their 'heavyweapons count'.
899 weapons[hash].count.fuelrod = weapons[hash].count.fuelrod + 1 -- Add one to their 'fuelrod count'
900 elseif last_damage[vhash] == "weapons\\plasma rifle\\bolt" then -- If the last_damage tag is from a Plasma Rifle Bolt.
901 word1 = "killed" word2 = "with a Plasma Rifle" -- Declare how they died.
902 medals[hash].count.triggerman = medals[hash].count.triggerman + 1 -- Add one to their 'triggermane count'.
903 weapons[hash].count.plasmarifle = weapons[hash].count.plasmarifle + 1 -- Add one to their 'plasmarifle count'.
904 elseif last_damage[vhash] == "weapons\\plasma pistol\\bolt" then -- If the last_damage tag is from a Plasma Pistol Bolt.
905 word1 = "killed" word2 = "with a Plasma Pistol" -- Declare how they died.
906 medals[hash].count.sidearm = medals[hash].count.sidearm + 1 -- Add one to their 'sidearim count'.
907 weapons[hash].count.plasmapistol = weapons[hash].count.plasmapistol + 1 -- Add one to their 'plasmapistol count'.
908 elseif last_damage[vhash] == "weapons\\plasma rifle\\charged bolt" then -- If the last_damage tag is from a Plasma Pistol Charged Bolt (The tag is wrong, Bungie is really dumb.)
909 word1 = "killed" word2 = "with an EMP Blast" -- Declare how they died.
910 medals[hash].count.jackofalltrades = medals[hash].count.jackofalltrades + 1 -- Add one to their 'jackofalltrades count'.
911 weapons[hash].count.empblast = weapons[hash].count.empblast + 1 -- Add one to their 'empblast count'.
912 elseif last_damage[vhash] == "weapons\\pistol\\bullet" then -- If the last_damage tag is from a Pistol Bullet.
913 word1 = "killed" word2 = "with a Pistol" -- Declare how they died.
914 medals[hash].count.sidearm = medals[hash].count.sidearm + 1 -- Add one to their 'sidearm count'.
915 weapons[hash].count.pistol = weapons[hash].count.pistol + 1 -- Add one to their 'pistol count'.
916 elseif last_damage[vhash] == "weapons\\needler\\impact damage" or last_damage[vhash] == "weapons\\needler\\explosion" or last_damage[vhash] == "weapons\\needler\\detonation damage" then -- If the last_damage tag is from a Needler Impact Damage, Needler Explostion or Needler Detonation Damage.
917 word1 = "killed" word2 = "with a Needler" -- Declare how they died.
918 medals[hash].count.triggerman = medals[hash].count.triggerman + 1 -- Add one to their 'triggerman count'.
919 weapons[hash].count.needler = weapons[hash].count.needler + 1 -- Add one to their 'needer count'.
920 elseif last_damage[vhash] == "weapons\\flamethrower\\impact damage" or last_damage[vhash] == "weapons\\flamethrower\\explosion" or last_damage[vhash] == "weapons\\flamethrower\\burning" then -- If the last_damage tag is from a Flamethrower Impact Damage, Flamethrower Burning.
921 word1 = "killed" word2 = "with a Flame Thrower" -- Declare how they died.
922 medals[hash].count.heavyweapons = medals[hash].count.heavyweapons + 1 -- Add one to their 'heavyweapons count'.
923 weapons[hash].count.flamethrower = weapons[hash].count.flamethrower + 1 -- Add one to their 'flamethrower count'.
924 elseif last_damage[vhash] == "weapons\\flag\\melee" then -- If the last_damage tag is from a Flag Melee.
925 word1 = "meleed" word2 = "with the Flag" -- Declare how they died.
926 weapons[hash].count.flagmelee = weapons[hash].count.flagmelee + 1 -- Add one to their 'flagmelee count'.
927 medals[hash].count.closequarters = medals[hash].count.closequarters + 1 -- Add one to their 'closequarters count'.
928 elseif last_damage[vhash] == "weapons\\ball\\melee" then -- If the last_damage tag is from an Oddball Melee.
929 word1 = "meleed" word2 = "with the Oddball" -- Declare how they died.
930 weapons[hash].count.oddballmelee = weapons[hash].count.oddballmelee + 1 -- Add one to their 'oddballmelee count'.
931 medals[hash].count.closequarters = medals[hash].count.closequarters + 1 -- Add one to their 'closequarters count'.
932 elseif last_damage[vhash] == "weapons\\assault rifle\\bullet" then -- If the last_damage tag is from an Assault Rifle Bullet.
933 word1 = "killed" word2 = "with an Assault Rifle" -- Declare how they died.
934 medals[hash].count.triggerman = medals[hash].count.triggerman + 1 -- Add one to their 'tringgerman count'.
935 weapons[hash].count.assaultrifle = weapons[hash].count.assaultrifle + 1 -- Add one to their 'assaultrifle count'.
936-- Vehicles
937 elseif last_damage[vhash] == "vehicles\\warthog\\bullet" then -- If the last_damage tag is from a Warthog Bullet.
938 word1 = "killed" word2 = "with a Chain Hog" -- Declare how they died.
939 weapons[hash].count.chainhog = weapons[hash].count.chainhog + 1 -- Add one to their 'chainhog count'.
940 elseif last_damage[vhash] == "vehicles\\scorpion\\shell shock wave" or last_damage[vhash] == "vehicles\\scorpion\\shell explosion" then -- If last_damage tag is Shell Shock Wave or Sheel Explosion.
941 word1 = "killed" word2 = "with a Tank Shell" -- Declare how they died.
942 weapons[hash].count.tankshell = weapons[hash].count.tankshell + 1 -- Add one to their 'tankshell count'.
943 elseif last_damage[vhash] == "vehicles\\scorpion\\bullet" then -- If the last_damage tag is Scorpion Bullet.
944 word1 = "killed" word2 = "with a Tank's Machine Gun" -- Declare how they died.
945 weapons[hash].count.tankmachinegun = weapons[hash].count.tankmachinegun + 1 -- Add one to their 'tankmachinegun count'.
946 elseif last_damage[vhash] == "vehicles\\ghost\\ghost bolt" then -- If the last_damage tag is Ghost Golt.
947 word1 = "killed" word2 = "with a Ghost" -- Declare how they died.
948 weapons[hash].count.ghost = weapons[hash].count.ghost + 1 -- Add one to their 'ghost count'.
949 elseif last_damage[vhash] == "vehicles\\c gun turret\\mp bolt" then -- If the last_damage tag is MP Bolt (Turret Gun).
950 word1 = "killed" word2 = "with a Turret" -- Declare how they died.
951 weapons[hash].count.turret = weapons[hash].count.turret + 1 -- Add one to their 'turrent count'.
952 elseif last_damage[vhash] == "vehicles\\banshee\\mp_fuel rod explosion" then -- If the last_damage tag is MP_Fuel Rod Explosion (Banshee's Fuel Rod).
953 word1 = "killed" word2 = "with a Banshee's Fuel Rod" -- Declare how they died.
954 weapons[hash].count.bansheefuelrod = weapons[hash].count.bansheefuelrod + 1 -- Add one to their 'bansheefuelrod count'.
955 elseif last_damage[vhash] == "vehicles\\banshee\\banshee bolt" then -- If the last_damage tag is Banshee Bolt.
956 word1 = "killed" word2 = "with a Banshee" -- Declare how they died.
957 weapons[hash].count.banshee = weapons[hash].count.banshee + 1 -- Add one to their 'banshee count'.
958 elseif last_damage[vhash] == "globals\\vehicle_collision" then -- If the last_damage tag is Vehicle_collision.
959 word1 = "splattered" word2 = "across their windshield" -- Declare how they died.
960 medals[hash].count.moblieasset = medals[hash].count.moblieasset + 1 -- Add one to their 'mobileasset count'.
961 weapons[hash].count.splatter = weapons[hash].count.splatter + 1 -- Add one to their 'splatter count'
962 elseif last_damage[vhash] == "globals\\falling" then -- If the last_damage tag is Falling.
963 word1 = "killed" word2 = "with Fall Damage" -- Declare how they died.
964 weapons[hash].count.falldamage = weapons[hash].count.falldamage + 1 -- Add one to their 'falldamage count'
965 elseif last_damage[vhash] == "weapons\\rocket launcher\\explosion" then -- If the last_damage tag is from a Rocket Launcher Explosion. Rocket Launcher and Rocket Hogs use the same tags.
966 if obj_crouch == 1 then -- Check to make sure the player is a gunner of a vehicle.
967 word1 = "killed" word2 = "with a Rocket Hog" -- Declare how they died.
968 weapons[hash].count.rockethog = weapons[hash].count.rockethog + 1 -- Add one to their 'rockethog count'.
969 else
970 word1 = "killed" word2 = "with a Rocket Launcher" -- Declare how they died.
971 weapons[hash].count.rocketlauncher = weapons[hash].count.rocketlauncher + 1 -- Add one to their 'rocketlauncher count'.
972 medals[hash].count.heavyweapons = medals[hash].count.heavyweapons + 1 -- Add one to their 'heavyweapons count'.
973 end
974 end
975
976 local m_killer = getplayer(killer) -- Declare m_killer.
977 local m_victim = getplayer(victim) -- Declare m_victim.
978 local k_objId = readdword(m_killer, 0x34) -- Get the killer's object ID.
979 local v_objId = readdword(m_victim, 0x34) -- Get the victim's object ID.
980 if getobject(k_objId) then -- Make sure the killer's object ID exist.
981 local kx, ky, kz = getobjectcoords(k_objId) -- Get the killer's coords.
982 local vx, vy, vz = getobjectcoords(v_objId) -- Get the victim's coords.
983 local x_dist = kx - vx -- Find the difference in their x coords.
984 local y_dist = ky - vy -- Find the difference in their y coords.
985 local z_dist = kz - vz -- Find the difference in their z coords.
986 local dist = math.sqrt(x_dist ^ 2 + y_dist ^ 2 + z_dist ^ 2) -- Declare the total distance between them.
987
988 local hash = gethash(killer) -- Get the killer's hash.
989 if dist > stats[hash].total.longestkill then -- If the dist is more then their stored longest kill.
990 stats[hash].total.longestkill = dist -- Make their longest kill the new dist.
991 privatesay(killer, "New Longest Kill : " .. math.round(dist, 2) .. " meters!") -- Tell the player his new longest kill.
992 end
993 end
994
995 local m_player = getplayer(killer) -- Declare m_player.
996 local player_obj_id = readdword(m_player, 0x34) -- Get the player's object ID.
997 local m_object = getobject(player_obj_id) -- Declare m_object.
998 local kvehicleid = readdword(m_object, 0x11C) -- Declare the killer's vehicle ID.
999 local seat_index = readword(m_object, 0x2F0) -- Declare the seat_index of the driver.
1000 if kvehicleid ~= nil then -- If the killer's vehicle ID is not nil (Does not exist.
1001 if seat_index == 1 or seat_index == 2 or seat_index == 3 or seat_index == 4 then
1002 for i = 0,15 do -- Create a loop for the players.
1003 local m_player = getplayer(i) -- Declare m_player of the loop.
1004 local player_obj_id = readdword(m_player, 0x34) -- Declare the loop'd player's ID.
1005 local m_object = getobject(player_obj_id) -- Declare m_object.
1006 local loopid = readdword(m_object, 0x11C) -- Get the loop'd player's vehicle ID.
1007 local seat_index = readword(m_object, 0x2F0) -- Declare the seat_index of the loop'd player.
1008 if kvehicleid == loopid then -- Make sure the killer and the loop'd player are in the same hog.
1009 if seat_index == 0 then -- If they are the driver.
1010 local hash = gethash(i) -- Get the hash of the loop'd player.
1011 hprint(i, "+5 cR - Downshift", 5) -- Tell them what they did.
1012 match[hash] = match[hash] + 5 -- Add 5 to their match total.
1013 stats[hash].total.credits = stats[hash].total.credits + 5 -- Add 5 to their total.
1014 medals[hash].count.downshift = medals[hash].count.downshift + 1 -- Add one to their 'downshift count'.
1015 end
1016 end
1017 end
1018 end
1019 end
1020
1021 local khash = gethash(killer) -- Get the killer's hash.
1022 local vhash = gethash(victim) -- Get the victim's hash.
1023 if khash then -- If khash is not nil (Does exist)
1024 if vhash then -- If vhash is not nil (Does exist)
1025 revenge[vhash] = khash -- Declare revenge[vhash] as the killer's hash.
1026 if revenge[khash] == vhash then -- If revenge[khash] is the same as the victim's hash.
1027 local hash = gethash(killer) -- Get the killer's hash.
1028 hprint(killer, "+3 cR - Revenge", 5) -- Tell them what they did.
1029 match[hash] = match[hash] + 3 -- Add 3 to their match total.
1030 stats[hash].total.credits = stats[hash].total.credits + 3 -- Add 3 to their total.
1031 medals[hash].count.jackofalltrades = medals[hash].count.jackofalltrades + 1 -- Add one to their 'jackofalltrades count'.
1032 end
1033 end
1034 end
1035
1036 for i = 0,15 do -- Create a loop for the players.
1037 if i ~= victim then -- If i is not the victim.
1038 local hash = gethash(i) -- Get the loop'd player's hash.
1039 if hash then -- If there is a hash.
1040 if getteam(i) == getteam(victim) then -- If the loop'd player's team is the same as the victim's.
1041 avenge[hash] = gethash(killer) -- Declear the killer's hash as their targe.
1042 end
1043 end
1044 end
1045
1046 local khash = gethash(killer) -- Get the killer's hash.
1047 if avenge[khash] == gethash(victim) then -- If the killer's hash targe is the same as the victim's hash.
1048 medals[hash].count.jackofalltrades = medals[hash].count.jackofalltrades + 1 -- Add one to their 'jackofalltrades' count.
1049 match[hash] = match[hash] + 3 -- Add 3 to their match total.
1050 hprint(killer, "+3 cR - Avenger", 5) -- Tell them what they did.
1051 stats[hash].total.credits = stats[hash].total.credits + 3 -- Add 3 to their total.
1052 end
1053 end
1054
1055 local m_object = getobject(getplayerobjectid(killer)) -- Declear m_object.
1056 if not m_object then -- If the killer is not an object. They are dead.
1057 hprint(killer, "+5 cR - Killed from the Grave", 5) -- Tell them what they did.
1058 match[hash] = match[hash] + 5 -- Add 5 to their match total.
1059 stats[hash].total.credits = stats[hash].total.credits + 5 -- Add 5 to their total.
1060 medals[hash].count.jackofalltrades = medals[hash].count.jackofalltrades + 1 -- Add one to their 'jackofalltrades count'.
1061 end
1062
1063 if killer then -- If the killer exist.
1064 local khash = gethash(killer) -- Get the killer's hash.
1065 kills[khash] = kills[khash] or 0
1066 kills[khash] = kills[khash] + 1 -- Add one to his kill count.
1067 end
1068
1069 local vhash = gethash(victim) -- Get the victim's hash.
1070 if killer and victim then -- If there is a killer and a victim.
1071 if kills[vhash] ~= nil then
1072 if kills[vhash] >= 5 then -- If the kill amount of the victim is more then or equal to 5. (They are on a killing spree)
1073 local hash = gethash(killer) -- Get the killer's hash.
1074 hprint(killer, "+5 cR - Killjoy", 5) -- Tell them what they did.
1075 match[hash] = match[hash] + 5 -- Add 5 to the match total.
1076 stats[hash].total.credits = stats[hash].total.credits + 5 -- Add 5 to their total.
1077 medals[hash].count.jackofalltrades = medals[hash].count.jackofalltrades + 1 -- Add one to their 'jackofalltrades count'.
1078 end
1079 end
1080 end
1081 kills[vhash] = 0 -- Reset the victim's kill count to 0.
1082
1083 registertimer(10, "CloseCall", killer) -- Create the timer for the "Close Call" Jack of all Trades medal.
1084 registertimer(10, "FirstStrike", mode, killer) -- Create the timer for "First Strike" Jack of all Trades medal.
1085 end
1086
1087 -- There is extra checks then needed for below because I was having problems during testing.
1088 if send_kill_messages == true then -- If send_kill_messages is true (At the top of the script)
1089 if word1 and word2 then -- If there is word1 and word2
1090 if word1 ~= nil and word2 ~= nil then -- If word1 and word2 is not nil.
1091 if tostring(word1) and tostring(word2) then -- If word1 and word2 is a string.
1092 say(getname(killer) .. " " .. word1 .. " " .. getname(victim) .. " " .. word2 .. "!") -- Send the server message telling how they died.
1093 end
1094 end
1095 end
1096 end
1097
1098 if killing_spree_notifications == true then -- If killing_spree_notifictions is true (At the top of the script)
1099 local k_player = getplayer(killer) -- Declare k_player as the 'killer'.
1100 local spree = readword(k_player, 0x96) -- Declare spree.
1101 local hash = gethash(killer) -- Get the killer's hash.
1102 if spree == 5 then -- If player's killing spree is equal to 5.
1103 say(getname(killer) .. " is on a Killing Spree!") -- Send message to server.
1104 medals[hash].count.sprees = medals[hash].count.sprees + 1 -- Add one to their spree count.
1105 hprint(killer, "+3 cR - Killing Spree", 5) -- Tell them what they did.
1106 match[hash] = match[hash] + 3 -- Add 3 to their match total.
1107 stats[hash].total.credits = stats[hash].total.credits + 3 -- Add 3 to their total.
1108 sprees[hash].count.killingspree = sprees[hash].count.killingspree + 1 -- Add one to their killingspree count.
1109 elseif spree == 10 then -- If player's killing spree is equal to 10.
1110 say(getname(killer) .. " is on a Killing Frenzy!") -- Send message to server.
1111 medals[hash].count.sprees = medals[hash].count.sprees + 1 -- Add one to their spree count.
1112 hprint(killer, "+5 cR - Killing Frenzy", 5) -- Tell them what they did.
1113 match[hash] = match[hash] + 5 -- Add 5 to their match total.
1114 stats[hash].total.credits = stats[hash].total.credits + 5 -- Add 5 to their total.
1115 sprees[hash].count.killingfrenzy = sprees[hash].count.killingfrenzy + 1 -- Add one to their killingfrenzy count.
1116 elseif spree == 15 then -- If player's killing spree is equal to 15.
1117 say(getname(killer) .. " is on a Running Riot!") -- Send message to server.
1118 medals[hash].count.sprees = medals[hash].count.sprees + 1 -- Add one to their spree count.
1119 hprint(killer, "+10 cR - Running Riot", 5) -- Tell them what they did.
1120 match[hash] = match[hash] + 10 -- Add 10 to their match total.
1121 stats[hash].total.credits = stats[hash].total.credits + 10 -- Add 10 to their total.
1122 sprees[hash].count.runningriot = sprees[hash].count.runningriot + 1 -- Add one to their runningriot count.
1123 elseif spree == 20 then -- If player's killing spree is equal to 20.
1124 say(getname(killer) .. " is on a Rampage!") -- Send message to server.
1125 medals[hash].count.sprees = medals[hash].count.sprees + 1 -- Add one to their spree count.
1126 hprint(killer, "+15 cR - Rampage", 5) -- Tell them what they did.
1127 match[hash] = match[hash] + 15 -- Add 15 to their match total.
1128 stats[hash].total.credits = stats[hash].total.credits + 15 -- Add 15 to their total.
1129 sprees[hash].count.rampage = sprees[hash].count.rampage + 1 -- Add one to their rampage count.
1130 elseif spree == 25 then -- If player's killing spree is equal to 25.
1131 say(getname(killer) .. " is Untouchable!") -- Send message to server.
1132 medals[hash].count.sprees = medals[hash].count.sprees + 1 -- Add one to their spree count.
1133 hprint(killer, "+20 cR - Untouchable", 5) -- Tell them what they did.
1134 match[hash] = match[hash] + 20 -- Add 20 to their match total.
1135 stats[hash].total.credits = stats[hash].total.credits + 20 -- Add 20 to their total.
1136 sprees[hash].count.untouchable = sprees[hash].count.untouchable + 1 -- Add 1 to their untouchable count.
1137 elseif spree == 30 then -- If player's killing spree is equal to 30.
1138 say(getname(killer) .. " is Invincible!") -- Send message to server.
1139 medals[hash].count.sprees = medals[hash].count.sprees + 1 -- Add one to their spree count.
1140 hprint(killer, "+30 cR - Invincible", 5) -- Tell them what they did.
1141 match[hash] = match[hash] + 30 -- Add 30 to their match total.
1142 stats[hash].total.credits = stats[hash].total.credits + 30 -- Add 30 to their total.
1143 sprees[hash].count.invincible = sprees[hash].count.invincible + 1 -- Add one to their invincible count.
1144 elseif spree == 35 then -- If player's killing spree is equal to 35.
1145 say(getname(killer) .. " is Anomgstopkillingme!") -- Send message to server.
1146 medals[hash].count.sprees = medals[hash].count.sprees + 1 -- Add one to their spree count.
1147 hprint(killer, "+40 cR - Anomgstopkillingme", 5) -- Tell them what they did.
1148 match[hash] = match[hash] + 40 -- Add 40 to their match total.
1149 stats[hash].total.credits = stats[hash].total.credits + 40 -- Add 40 to their total.
1150 sprees[hash].count.anomgstopkillingme = sprees[hash].count.anomgstopkillingme + 1 -- Add one to their anomgstopkillingme count.
1151 elseif spree >= 40 and spree%5 == 0 then -- If player's killing spree is 40 or more (Every 5 it will say this after 40).
1152 say(getname(killer) .. " is Unfrigginbelievable!") -- Send message to server.
1153 medals[hash].count.sprees = medals[hash].count.sprees + 1 -- Add one to their spree count.
1154 hprint(killer, "+50 cR - Unfrigginbelievable", 5) -- Tell them what they did.
1155 match[hash] = match[hash] + 50 -- Add 50 to their match total.
1156 stats[hash].total.credits = stats[hash].total.credits + 50 -- Add 50 to their total.
1157 sprees[hash].count.unfrigginbelievable = sprees[hash].count.unfrigginbelievable + 1 -- Add on to their unfrigginbelieveable count.
1158 end
1159 end
1160
1161 local k_player = getplayer(killer) -- Declare k_player
1162 local multikill = readword(k_player, 0x98) -- Multi Kill Counter
1163 local hash = gethash(killer) -- Get the killer's hash.
1164
1165 if multikill == 2 then -- If multikill is 2.
1166 medals[hash].count.multikill = medals[hash].count.multikill + 1 -- Add one to their 'multikill count'.
1167 sprees[hash].count.double = sprees[hash].count.double + 1 -- Add one to their double count.
1168 hprint(killer, "+5 cR - Double Kill", 5) -- Tell them what they did.
1169 match[hash] = match[hash] + 5 -- Add 5 to their match total.
1170 stats[hash].total.credits = stats[hash].total.credits + 5 -- Add 5 to their total.
1171 elseif multikill == 3 then -- If multikill is 3.
1172 medals[hash].count.multikill = medals[hash].count.multikill + 1 -- Add one to their 'multikill count'.
1173 sprees[hash].count.triple = sprees[hash].count.triple + 1 -- Add one to their triple count.
1174 hprint(killer, "+10 cR - Triple Kill", 5) -- Tell them what they did.
1175 match[hash] = match[hash] + 10 -- Add 10 to their match total.
1176 stats[hash].total.credits = stats[hash].total.credits + 10 -- Add 10 to their total.
1177 elseif multikill == 4 then -- If multikill is 4
1178 medals[hash].count.multikill = medals[hash].count.multikill + 1 -- Add one to their 'multikill count'.
1179 sprees[hash].count.overkill = sprees[hash].count.overkill + 1 -- Add one to their overkill count.
1180 hprint(killer, "+15 cR - Overkill", 5) -- Tell them what they did.
1181 match[hash] = match[hash] + 15 -- Add 15 to their match total.
1182 stats[hash].total.credits = stats[hash].total.credits + 15 -- Add 15 to their total.
1183 elseif multikill == 5 then -- If multikill is 5.
1184 medals[hash].count.multikill = medals[hash].count.multikill + 1 -- Add one to their 'multikill count'.
1185 sprees[hash].count.killtacular = sprees[hash].count.killtacular + 1 -- Add one to their killtacular count.
1186 hprint(killer, "+20 cR - Killtacular", 5) -- Tell them what they did.
1187 match[hash] = match[hash] + 20 -- Add 20 to their match total.
1188 stats[hash].total.credits = stats[hash].total.credits + 20 -- Add 20 to their total.
1189 elseif multikill == 6 then -- If multikill is 6.
1190 medals[hash].count.multikill = medals[hash].count.multikill + 1 -- Add one to their 'multikill count'.
1191 sprees[hash].count.killtrocity = sprees[hash].count.killtrocity + 1 -- Add one to their killtrocity count.
1192 hprint(killer, "+25 cR - Killtrocity", 5) -- Tell them what they did.
1193 match[hash] = match[hash] + 25 -- Add 25 to their match total.
1194 stats[hash].total.credits = stats[hash].total.credits + 25 -- Add 25 to their total.
1195 elseif multikill == 7 then -- If multikill is 7.
1196 medals[hash].count.multikill = medals[hash].count.multikill + 1 -- Add one to their 'multikill count'.
1197 sprees[hash].count.killimanjaro = sprees[hash].count.killimanjaro + 1 -- Add one to their killimanjaro count.
1198 hprint(killer, "+30 cR - Killimanjaro", 5) -- Tell them what they did.
1199 match[hash] = match[hash] + 30 -- Add 30 to their match total.
1200 stats[hash].total.credits = stats[hash].total.credits + 30 -- Add 30 to their total.
1201 elseif multikill == 8 then -- If multikill is 8.
1202 medals[hash].count.multikill = medals[hash].count.multikill + 1 -- Add one to their 'multikill count'.
1203 sprees[hash].count.killtastrophe = sprees[hash].count.killtastrophe + 1 -- Add one to their killtastrophe count.
1204 hprint(killer, "+35 cR - Killtastrophe", 5) -- Tell them what they did.
1205 match[hash] = match[hash] + 35 -- Add 35 to their match total.
1206 stats[hash].total.credits = stats[hash].total.credits + 35 -- Add 35 to their total.
1207 elseif multikill == 9 then -- If multikill is 9.
1208 medals[hash].count.multikill = medals[hash].count.multikill + 1 -- Add one to their 'multikill count'.
1209 sprees[hash].count.killpocalypse = sprees[hash].count.killpocalypse + 1 -- Add one to their killpocalypse count.
1210 hprint(killer, "+40 cR - Killpocalypse", 5) -- Tell them what they did.
1211 match[hash] = match[hash] + 40 -- Add 40 to their match total.
1212 stats[hash].total.credits = stats[hash].total.credits + 40 -- Add 40 to their total.
1213 elseif multikill >= 10 then -- If multikill is 10 or more.
1214 medals[hash].count.multikill = medals[hash].count.multikill + 1 -- Add one to their 'multikill count'.
1215 sprees[hash].count.killionaire = sprees[hash].count.killionaire + 1 -- Add one to their killionaire count.
1216 hprint(killer, "+50 cR - Killionaire", 5) -- Tell them what they did.
1217 match[hash] = match[hash] + 50 -- Add 50 to their match total.
1218 stats[hash].total.credits = stats[hash].total.credits + 50 -- Add 50 to their total.
1219 end
1220
1221
1222 if mode == 0 then -- If the player was killed by the server.
1223 local hash = gethash(victim) -- Get the hash of the victim.
1224 stats[hash].total.deaths = stats[hash].total.deaths + 1 -- Add one to their total deaths.
1225 elseif mode == 1 then -- If the player was killed by fall damage
1226 local hash = gethash(victim) -- Get the hash of the victim.
1227 stats[hash].total.deaths = stats[hash].total.deaths + 1 -- Add one to their total deaths.
1228 elseif mode == 2 then -- If the player was killed by the guardians
1229 local hash = gethash(victim) -- Get the hash of the victim.
1230 stats[hash].total.deaths = stats[hash].total.deaths + 1 -- Add one to their total deaths.
1231 elseif mode == 3 then -- If player was killed by a vehicle.
1232 local hash = gethash(victim) -- Get the hash of the victim.
1233 stats[hash].total.deaths = stats[hash].total.deaths + 1 -- Add one to the total deaths.
1234 elseif mode == 4 then -- If player was killed by another player.
1235 local khash = gethash(killer) -- Get the hash of the killer.
1236 stats[khash].total.kills = stats[khash].total.kills + 1 -- Add one to the total kills.
1237 local vhash = gethash(victim) -- Get the hash of the victim.
1238 stats[hash].total.deaths = stats[hash].total.deaths + 1 -- Add one to the total deaths.
1239 hprint(killer, "+5 cR - Enemy Kill", 5) -- Tell them what they did.
1240 match[hash] = match[hash] + 5 -- Add 5 to their match total.
1241 stats[hash].total.credits = stats[hash].total.credits + 5 -- Add 5 to their total.
1242 elseif mode == 5 then -- If player was betrayed by another player.
1243 local khash = gethash(killer) -- Get the hash of the killer.
1244 stats[khash].total.betrays = stats[khash].total.betrays + 1 -- Add one to the total betrays.
1245 local vhash = gethash(victim) -- Get the hash of the victim.
1246 stats[vhash].total.deaths = stats[vhash].total.deaths + 1
1247 elseif mode == 6 then -- If player committed suicide.
1248 local hash = gethash(victim) -- Get the hash of the victim.
1249 stats[hash].total.deaths = stats[hash].total.deaths + 1 -- Add one to their death total.
1250 stats[hash].total.suicides = stats[hash].total.suicides + 1 -- Add one to their suicide total.
1251 end
1252end
1253-- Comment for OnKillMultipler : Called everytime a player gets a multikill.
1254function OnKillMultiplier(player, multiplier)
1255
1256
1257end
1258-- Comment for OnPlayerSpawn : Called everytime a player spawns. Called before they fully spawn.
1259function OnPlayerSpawn(player, m_objectId)
1260
1261
1262end
1263-- Comment for OnPlayerSpawnEnd : Called everytime a player spawns. Called after they fully spawn.
1264function OnPlayerSpawnEnd(player, m_objId)
1265
1266
1267end
1268-- Comment for OnTeamChange : Called everytime a player tries to change his/her team.
1269function OnTeamChange(relevant, player, cur_team, dest_team)
1270
1271 return 1
1272end
1273-- Comment for OnObjectCreation : Called everytime an object is created.
1274function OnObjectCreation(m_objId, player, tagName)
1275
1276
1277end
1278-- Comment for OnObjectInteraction : Called everytime a player interacts with an object.
1279function OnObjectInteraction(player, m_objId, tagType, tagName)
1280
1281 return 1
1282end
1283-- Comment for OnWeaponAssignment : Called everytime a player is assigned a weapon.
1284function OnWeaponAssignment(player, m_objId, slot, tagName)
1285
1286 return 0
1287end
1288-- Comment for OnWeaponReload : Called everytime a player attempts to reload his/her weapon.
1289function OnWeaponReload(player, m_weapId)
1290
1291 return 1
1292end
1293-- Comment for OnDamageLookup : Called everytime damage is dealt to something.
1294function OnDamageLookup(receiver, causer, tagData, tagName)
1295
1296 local cplayer = objecttoplayer(causer) -- Define cplayer.
1297 local rplayer = objecttoplayer(receiver) -- Define rplayer.
1298
1299 if rplayer then -- If "rplayer" exist.
1300 local rhash = gethash(rplayer) -- Get the hash of the rplayer
1301 last_damage[rhash] = tagName -- Add the tagname to the table so we know how they got killed.
1302 end
1303
1304end
1305-- Comment for OnVehicleEntry : Called everytime a player tries to enter a vehicle.
1306function OnVehicleEntry(relevant, player, m_vehicleId, tagName, seat)
1307
1308
1309 return 1
1310end
1311-- Comment for OnVehicleEject : Called everytime a player tries to get out of their vehicle.
1312function OnVehicleEject(player, forced)
1313
1314 return 1
1315end
1316-- Comment for OnClientUpdate : Called everytime the server updates the client.
1317function OnClientUpdate(player, m_objId)
1318
1319 local hash = gethash(player) -- Get the player's hash.
1320 local m_object = getobject(m_objId) -- Declare m_object.
1321
1322 if m_object then -- If m_object exist.
1323 local x, y, z = getobjectcoords(m_objId) -- Get the object's coords (the player).
1324 if xcoords[hash] then -- If coords have been added.
1325 local x_dist = x - xcoords[hash] -- Declare x_dist.
1326 local y_dist = y - ycoords[hash] -- Declare y_dist.
1327 local z_dist = z - zcoords[hash] -- Declare z_dist.
1328 local dist = math.sqrt(x_dist ^ 2 + y_dist ^ 2 + z_dist ^ 2) -- Get the total distance they have traveled.
1329 stats[hash].total.distancetraveled = stats[hash].total.distancetraveled + dist -- Add their dist traveled to their total dist traveled.
1330 end
1331 xcoords[hash] = x -- Declare their x coord so we can get the distance again.
1332 ycoords[hash] = y -- Declare their y coord so we can get the distance again.
1333 zcoords[hash] = z -- Declare their z coord so we can get the distance again.
1334 end
1335
1336 GivePlayerMedals(player) -- Give the player his medals if they are ranked up.
1337
1338end
1339
1340------------------------------------- TIMERS MADE WITHIN THE SCRIPT --------------------------------------
1341-- Comment for AssistDelay(Timer) : Used to give player credit for his/her assist and add them to their total.
1342function AssistDelay(id, count)
1343
1344 for i = 0,15 do -- Creat a loop for all players.
1345 local hash = gethash(i) -- Get the hash of the player.
1346 if hash then -- If the hash exist.
1347 local m_player = getplayer(i) -- Declare m_player.
1348 local number_of_assists = readword(m_player, 0xA4) -- Get the player's assist.
1349 local assist_credits = number_of_assists * 3 -- Each assist is 3 credits, find out of many credits they get.
1350 if number_of_assists ~= 0 then -- If number of assists is not 0.
1351 if number_of_assists == 1 then -- If number of assists is equal to 1.
1352 hprint(i, "+" .. assist_credits .. " cR - " .. number_of_assists .. " Assist", 5) -- Send them their credit amounts and number of assists.
1353 else -- If number of assists is not 1...... We add this check so out grammer is correct.
1354 hprint(i, "+" .. assist_credits .. " cR - " .. number_of_assists .. " Assists", 5) -- Send them their credit amounts and number of assists.
1355 end
1356 stats[hash].total.assists = stats[hash].total.assists + number_of_assists -- Add their number of assists to their total.
1357 medals[hash].count.assists = medals[hash].count.assists + number_of_assists -- Add their number of assists to their medal count.
1358 match[hash] = match[hash] + assist_credits -- Add assist_credits to their match total.
1359 stats[hash].total.credits = stats[hash].total.credits + assist_credits -- Add assist_credits to their total.
1360 end
1361 end
1362 end
1363end
1364-- Comment for CloseCall(Timer) : Used for a 'Close Call'. It is used for the Jack of all Trades medal.
1365function CloseCall(id, count, killer)
1366
1367 local m_player = getplayer(killer) -- Declare m_player.
1368 local player_obj_id = readdword(m_player, 0x34) -- Get the player's object ID.
1369 local m_object = getobject(player_obj_id) -- Declare m_object.
1370 local shields = readfloat(m_object, 0xE4) -- Get the object's shields.
1371 local health = readfloat(m_object, 0xE0) -- Get the object's health.
1372 if shields ~= nil then -- If the player's shields does not equal nil.
1373 if shields == 0 then -- If their shields equal 0. They have no shields left.
1374 if health then -- If the player's health exist.
1375 if health ~= 1 then -- If it is less then 1. They have less then full health.
1376 local hash = gethash(killer) -- Get the killer's hash.
1377 hprint(killer, "+10 cR - Close Call", 5) -- Tell them what they did.
1378 match[hash] = match[hash] + 10 -- Add 10 to their match total.
1379 stats[hash].total.credits = stats[hash].total.credits + 10 -- Add 10 to their total.
1380 medals[hash].count.jackofalltrades = medals[hash].count.jackofalltrades + 1 -- Add one to their 'jackofalltrades count'.
1381 end
1382 end
1383 end
1384 end
1385end
1386-- Comment for FirstStrike(Timer) : Used for 'First Strike'. It is used for Jack of all Trades medal.
1387function FirstStrike(id, count, mode, killer)
1388
1389 local first = false -- Declare as first true.
1390 if killer then
1391 local m_player = getplayer(killer)
1392 local kkills = readword(m_player, 0x9C)
1393 if kkills == 1 then
1394 for i = 0,15 do -- Create a loop for the players.
1395 if killer ~= i then
1396 if getplayer(i) then
1397 local m_player = getplayer(i)
1398 local ikills = readword(m_player, 0x9C)
1399 if ikills == 0 then
1400 first = true -- Declare first as false.
1401 break -- Stop the loop.
1402 end
1403 end
1404 end
1405 end
1406 end
1407 end
1408
1409 if first == true then -- If first is true.
1410 local hash = gethash(killer) -- Get the killer's hash.
1411 hprint(killer, "+15 cR - First Strike", 5) -- Tell them what they did.
1412 match[hash] = match[hash] + 15 -- Add 15 to their match total.
1413 stats[hash].total.credits = stats[hash].total.credits + 15 -- Add 15 to their total.
1414 medals[hash].count.jackofalltrades = medals[hash].count.jackofalltrades + 1 -- Add one to his 'jackofalltrades count'.
1415 end
1416end
1417
1418-- Comment for PTimeout(Timer) : Used for the ping kick feature.
1419function PTimeout(id, count)
1420
1421 for i = 0, 15 do -- Create a loop for all the players.
1422 if getplayer(i) ~= nil then -- Make sure the player exist.
1423 warned[gethash(i)] = nil -- Declare the player's hash warn count as nil.
1424 end
1425 end
1426end
1427-- Comment for PKTimer(Timer) : used for the ping kick feature.
1428function PKTimer(id, count)
1429
1430 for i = 0, 15 do -- Create a loop for the players.
1431 local m_player = getplayer(i) -- Declare m_player.
1432 local ping = readword(m_player, 0xDC) -- Declare the player's ping.
1433 if tonumber(max_ping) then
1434 if ping > max_ping then -- If the player's ping is higher then the max_ping at the top of the script.
1435 if warned[gethash(i)] ~= nil then -- If the warned[hash] not nil
1436 svcmd("sv_kick " .. resolveplayer(i)) -- Kick the player
1437 say(getname(i) .. " was kicked for ping above " .. max_ping) -- Tell the server that he was kicked.
1438 else -- If warned[hash] is nil.
1439 warned[gethash(i)] = true -- Declare that they have been warned.
1440 if warn_server == true then -- If "warn_server" is true.
1441 say("WARNING! " .. getname(i) .. " will be kicked for ping over " .. max_ping) -- Warn the server.
1442 end
1443 end
1444 end
1445 end
1446 end
1447end
1448------------------------------------- FUNCTIONS MADE WITHIN THE SCRIPT -----------------------------------
1449-- Comment for GetPlayerRank : This function will return the rank of a player when he joins.
1450function GetPlayerRank(player)
1451
1452 local hash = gethash(player) -- Get the hash of the player.
1453 stats[hash].total.credits = stats[hash].total.credits or 0 -- Declear credits as credits or 0.
1454 stats[hash].total.rank = stats[hash].total.rank or "Recruit" -- Declear rank as rank or Recruit.
1455
1456 if stats[hash].total.credits >= 0 and stats[hash].total.credits < 7500 then -- 0 - 7,500
1457 stats[hash].total.rank = "Recruit" -- Decide his rank.
1458 elseif stats[hash].total.credits > 7500 and stats[hash].total.credits < 10000 then -- 7,500 - 10,000
1459 stats[hash].total.rank = "Private" -- Decide his rank.
1460 elseif stats[hash].total.credits > 10000 and stats[hash].total.credits < 15000 then -- 10,000 - 15,000
1461 stats[hash].total.rank = "Corporal" -- Decide his rank.
1462 elseif stats[hash].total.credits > 15000 and stats[hash].total.credits < 20000 then -- 15,000 - 20,000
1463 stats[hash].total.rank = "Sergeant" -- Decide his rank.
1464 elseif stats[hash].total.credits > 20000 and stats[hash].total.credits < 26250 then -- 20,000 - 26,250
1465 stats[hash].total.rank = "Sergeant Grade 1" -- Decide his rank.
1466 elseif stats[hash].total.credits > 26250 and stats[hash].total.credits < 32500 then -- 26,250 - 32,500
1467 stats[hash].total.rank = "Sergeant Grade 2" -- Decide his rank.
1468 elseif stats[hash].total.credits > 32500 and stats[hash].total.credits < 45000 then -- 32,500 - 45,000
1469 stats[hash].total.rank = "Warrant Officer" -- Decide his rank.
1470 elseif stats[hash].total.credits > 45000 and stats[hash].total.credits < 78000 then -- 45,000 - 78,000
1471 stats[hash].total.rank = "Warrant Officer Grade 1" -- Decide his rank.
1472 elseif stats[hash].total.credits > 78000 and stats[hash].total.credits < 111000 then -- 78,000 - 111,000
1473 stats[hash].total.rank = "Warrant Officer Grade 2" -- Decide his rank.
1474 elseif stats[hash].total.credits > 111000 and stats[hash].total.credits < 144000 then -- 111,000 - 144,000
1475 stats[hash].total.rank = "Warrant Officer Grade 3" -- Decide his rank.
1476 elseif stats[hash].total.credits > 144000 and stats[hash].total.credits < 210000 then -- 144,000 - 210,000
1477 stats[hash].total.rank = "Captain" -- Decide his rank.
1478 elseif stats[hash].total.credits > 210000 and stats[hash].total.credits < 233000 then -- 210,000 - 233,000
1479 stats[hash].total.rank = "Captain Grade 1" -- Decide his rank.
1480 elseif stats[hash].total.credits > 233000 and stats[hash].total.credits < 256000 then -- 233,000 - 256,000
1481 stats[hash].total.rank = "Captain Grade 2" -- Decide his rank.
1482 elseif stats[hash].total.credits > 256000 and stats[hash].total.credits < 279000 then -- 256,000 - 279,000
1483 stats[hash].total.rank = "Captain Grade 3" -- Decide his rank.
1484 elseif stats[hash].total.credits > 279000 and stats[hash].total.credits < 325000 then -- 279,000 - 325,000
1485 stats[hash].total.rank = "Major" -- Decide his rank.
1486 elseif stats[hash].total.credits > 325000 and stats[hash].total.credits < 350000 then -- 325,000 - 350,000
1487 stats[hash].total.rank = "Major Grade 1" -- Decide his rank.
1488 elseif stats[hash].total.credits > 350000 and stats[hash].total.credits < 375000 then -- 350,000 - 375,000
1489 stats[hash].total.rank = "Major Grade 2" -- Decide his rank.
1490 elseif stats[hash].total.credits > 375000 and stats[hash].total.credits < 400000 then -- 375,000 - 400,000
1491 stats[hash].total.rank = "Major Grade 3" -- Decide his rank
1492 elseif stats[hash].total.credits > 400000 and stats[hash].total.credits < 450000 then -- 400,000 - 450,000
1493 stats[hash].total.rank = "Lt. Colonel" -- Decide his rank.
1494 elseif stats[hash].total.credits > 450000 and stats[hash].total.credits < 480000 then -- 450,000 - 480,000
1495 stats[hash].total.rank = "Lt. Colonel Grade 1" -- Decide his rank.
1496 elseif stats[hash].total.credits > 480000 and stats[hash].total.credits < 510000 then -- 480,000 - 510,000
1497 stats[hash].total.rank = "Lt. Colonel Grade 2" -- Decide his rank.
1498 elseif stats[hash].total.credits > 510000 and stats[hash].total.credits < 540000 then -- 510,000 - 540,000
1499 stats[hash].total.rank = "Lt. Colonel Grade 3" -- Decide his rank.
1500 elseif stats[hash].total.credits > 540000 and stats[hash].total.credits < 600000 then -- 540,000 - 600,000
1501 stats[hash].total.rank = "Commander" -- Decide his rank.
1502 elseif stats[hash].total.credits > 600000 and stats[hash].total.credits < 650000 then -- 600,000 - 650,000
1503 stats[hash].total.rank = "Commander Grade 1" -- Decide his rank.
1504 elseif stats[hash].total.credits > 650000 and stats[hash].total.credits < 700000 then -- 650,000 - 700,000
1505 stats[hash].total.rank = "Commander Grade 2" -- Decide his rank.
1506 elseif stats[hash].total.credits > 700000 and stats[hash].total.credits < 750000 then -- 700,000 - 750,000
1507 stats[hash].total.rank = "Commander Grade 3" -- Decide his rank
1508 elseif stats[hash].total.credits > 750000 and stats[hash].total.credits < 850000 then -- 750,000 - 850,000
1509 stats[hash].total.rank = "Colonel" -- Decide his rank.
1510 elseif stats[hash].total.credits > 850000 and stats[hash].total.credits < 960000 then -- 850,000 - 960,000
1511 stats[hash].total.rank = "Colonel Grade 1" -- Decide his rank.
1512 elseif stats[hash].total.credits > 960000 and stats[hash].total.credits < 1070000 then -- 960,000 - 1,070,000
1513 stats[hash].total.rank = "Colonel Grade 2" -- Decide his rank.
1514 elseif stats[hash].total.credits > 1070000 and stats[hash].total.credits < 1180000 then -- 1,070,000 - 1,180,000
1515 stats[hash].total.rank = "Colonel Grade 3" -- Decide his rank.
1516 elseif stats[hash].total.credits > 1180000 and stats[hash].total.credits < 1400000 then -- 1,180,000 - 1,400,000
1517 stats[hash].total.rank = "Brigadier" -- Decide his rank.
1518 elseif stats[hash].total.credits > 1400000 and stats[hash].total.credits < 1520000 then -- 1,400,000 - 1,520,000
1519 stats[hash].total.rank = "Brigadier Grade 1" -- Decide his rank.
1520 elseif stats[hash].total.credits > 1520000 and stats[hash].total.credits < 1640000 then -- 1,520,000 - 1,640,000
1521 stats[hash].total.rank = "Brigadier Grade 2" -- Decide his rank
1522 elseif stats[hash].total.credits > 1640000 and stats[hash].total.credits < 1760000 then -- 1,640,000 - 1,760,000
1523 stats[hash].total.rank = "Brigadier Grade 3" -- Decide his rank.
1524 elseif stats[hash].total.credits > 1760000 and stats[hash].total.credits < 2000000 then -- 1,760,000 - 2,000,000
1525 stats[hash].total.rank = "General" -- Decide his rank.
1526 elseif stats[hash].total.credits > 2000000 and stats[hash].total.credits < 2200000 then -- 2,000,000 - 2,200,000
1527 stats[hash].total.rank = "General Grade 1" -- Decide his rank.
1528 elseif stats[hash].total.credits > 2200000 and stats[hash].total.credits < 2350000 then -- 2,200,000 - 2,350,000
1529 stats[hash].total.rank = "General Grade 2" -- Decide his rank.
1530 elseif stats[hash].total.credits > 2350000 and stats[hash].total.credits < 2500000 then -- 2,350,000 - 2,500,000
1531 stats[hash].total.rank = "General Grade 3" -- Decide his rank.
1532 elseif stats[hash].total.credits > 2500000 and stats[hash].total.credits < 2650000 then -- 2,500,000 - 2,650,000
1533 stats[hash].total.rank = "General Grade 4" -- Decide his rank.
1534 elseif stats[hash].total.credits > 2650000 and stats[hash].total.credits < 3000000 then -- 2,650,000 - 3,000,000
1535 stats[hash].total.rank = "Field Marshall" -- Decide his rank.
1536 elseif stats[hash].total.credits > 3000000 and stats[hash].total.credits < 3700000 then -- 3,000,000 - 3,700,000
1537 stats[hash].total.rank = "Hero" -- Decide his rank.
1538 elseif stats[hash].total.credits > 3700000 and stats[hash].total.credits < 4600000 then -- 3,700,000 - 4,600,000
1539 stats[hash].total.rank = "Legend" -- Decide his rank.
1540 elseif stats[hash].total.credits > 4600000 and stats[hash].total.credits < 5650000 then -- 4,600,000 - 5,650,000
1541 stats[hash].total.rank = "Mythic" -- Decide his rank.
1542 elseif stats[hash].total.credits > 5650000 and stats[hash].total.credits < 7000000 then -- 5,650,000 - 7,000,000
1543 stats[hash].total.rank = "Noble" -- Decide his rank.
1544 elseif stats[hash].total.credits > 7000000 and stats[hash].total.credits < 8500000 then -- 7,000,000 - 8,500,000
1545 stats[hash].total.rank = "Eclipse" -- Decide his rank.
1546 elseif stats[hash].total.credits > 8500000 and stats[hash].total.credits < 11000000 then -- 8,500,000 - 11,000,000
1547 stats[hash].total.rank = "Nova" -- Decide his rank.
1548 elseif stats[hash].total.credits > 11000000 and stats[hash].total.credits < 13000000 then -- 11,000,000 - 13,000,000
1549 stats[hash].total.rank = "Forerunner" -- Decide his rank.
1550 elseif stats[hash].total.credits > 13000000 and stats[hash].total.credits < 16500000 then -- 13,000,000 - 16,500,000
1551 stats[hash].total.rank = "Reclaimer" -- Decide his rank.
1552 elseif stats[hash].total.credits > 16500000 and stats[hash].total.credits < 20000000 then -- 16,500,000 - 20,000,000
1553 stats[hash].total.rank = "Inheritor" -- Decide his rank.
1554 end
1555end
1556-- Comment for GetGametype : Will return info about the Gametype that is loaded and if it is Team Player or not.
1557function GetGametype()
1558
1559 local gametype_game = readbyte(gametype_base, 0x30) -- Confirmed. (CTF = 1) (Slayer = 2) (Oddball = 3) (KOTH = 4) (Race = 5)
1560 local team_play = readbyte(gametype_base, 0x34) -- Confirmed. (Off = 0) (On = 1)
1561
1562 if gametype_game == 1 then -- If gametype_game is equal to 1 (CTF).
1563 return "CTF" -- Return CTF.
1564
1565 elseif gametype_game == 2 then -- If gametype_game is equal to 2 (Slayer).
1566 if team_play == 0 then -- If team_play is equal to 0 (Off).
1567 return "FFA Slayer" -- Return Free For All Slayer.
1568 else -- If team_play is not 0 (Off).
1569 return "Team Slayer" -- Return Team Slayer.
1570 end
1571
1572 elseif gametype_game == 3 then -- If gametype_game is equal to 3 (Oddball).
1573 if team_play == 0 then -- If team_play is equal to 0 (Off).
1574 return "FFA Oddball" -- Return Free For All Oddball
1575 else -- If team_play is not 0 (Off).
1576 return "Team Oddball" -- Return Team Oddball.
1577 end
1578
1579 elseif gametype_game == 4 then -- If gametype_game is equal to 4 (KOTH).
1580 if team_play == 0 then -- If team_play is equal to 0 (Off).
1581 return "FFA KOTH" -- Return Free For All KOTH.
1582 else -- If team_play is not 0 (Off).
1583 return "Team KOTH" -- Return Team KOTH.
1584 end
1585
1586 elseif gametype_game == 5 then -- If gametype_game is equal to 5 (Race).
1587 if team_play == 0 then -- If team_play is equal to 0 (Off).
1588 return "FFA Race" -- Return Free For All Race.
1589 else -- If team_play is not 0 (Off).
1590 return "Team Race" -- Return Team Race.
1591 end
1592 end
1593end
1594
1595-- Comment for WriteChangeLog : Will make the changelog if it does not exist.
1596function WriteChangeLog()
1597
1598 local file = io.open(profilepath .. "\\StatsChangeLog.txt", "w")
1599 file:write("Changelog for Stats Script\n")
1600 file:write("------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n")
1601 file:write("Commands Version : " .. Version_Number .. " (Release Date : " .. Release_Date .. ")\n")
1602 file:write("------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n")
1603 file:write("First Release, hope to add more features.\n")
1604 file:close()
1605
1606end
1607-- Comment for GetMedalClasses : Will return the class for each medal.
1608function GetMedalClasses(player)
1609
1610 local hash = gethash(player)
1611
1612 if medals[hash].count.sprees > 5 and medals[hash].count.sprees < 50 then
1613 medals[hash].class.sprees = "Bronze" -- Declare the medal's class.
1614 elseif medals[hash].count.sprees > 50 and medals[hash].count.sprees < 250 then
1615 medals[hash].class.sprees = "Silver" -- Declare the medal's class.
1616 elseif medals[hash].count.sprees > 250 and medals[hash].count.sprees < 1000 then
1617 medals[hash].class.sprees = "Gold" -- Declare the medal's class.
1618 elseif medals[hash].count.sprees > 1000 and medals[hash].count.sprees < 4000 then
1619 medals[hash].class.sprees = "Onyx" -- Declare the medal's class.
1620 elseif medals[hash].count.sprees > 4000 and medals[hash].count.sprees < 10000 then
1621 medals[hash].class.sprees = "MAX" -- Declare the medal's class.
1622 elseif medals[hash].count.sprees > 10000 then
1623 medals[hash].class.sprees = "MAX" -- Declare the medal's class.
1624 end
1625
1626 if medals[hash].count.assists > 50 and medals[hash].count.assists < 250 then
1627 medals[hash].class.assists = "Bronze" -- Declare the medal's class.
1628 elseif medals[hash].count.assists > 250 and medals[hash].count.assists < 1000 then
1629 medals[hash].class.assists = "Silver" -- Declare the medal's class.
1630 elseif medals[hash].count.assists > 1000 and medals[hash].count.assists < 4000 then
1631 medals[hash].class.assists = "Gold" -- Declare the medal's class.
1632 elseif medals[hash].count.assists > 4000 and medals[hash].count.assists < 8000 then
1633 medals[hash].class.assists = "Onyx" -- Declare the medal's class.
1634 elseif medals[hash].count.assists > 8000 and medals[hash].count.assists < 20000 then
1635 medals[hash].class.assists = "MAX" -- Declare the medal's class.
1636 elseif medals[hash].count.assists > 20000 then
1637 medals[hash].class.assists = "MAX" -- Declare the medal's class.
1638 end
1639
1640 if medals[hash].count.closequarters > 50 and medals[hash].count.closequarters < 150 then
1641 medals[hash].class.closequarters = "Bronze" -- Declare the medal's class.
1642 elseif medals[hash].count.closequarters > 150 and medals[hash].count.closequarters < 400 then
1643 medals[hash].class.closequarters = "Silver" -- Declare the medal's class.
1644 elseif medals[hash].count.closequarters > 400 and medals[hash].count.closequarters < 1600 then
1645 medals[hash].class.closequarters = "Gold" -- Declare the medal's class.
1646 elseif medals[hash].count.closequarters > 1600 and medals[hash].count.closequarters < 4000 then
1647 medals[hash].class.closequarters = "Onyx" -- Declare the medal's class.
1648 elseif medals[hash].count.closequarters > 4000 and medals[hash].count.closequarters < 8000 then
1649 medals[hash].count.closequarters = "MAX" -- Declare the medal's class.
1650 elseif medals[hash].count.closequarters > 8000 then
1651 medals[hash].count.closequarters = "MAX" -- Declare the medal's class.
1652 end
1653
1654 if medals[hash].count.crackshot > 100 and medals[hash].count.crackshot < 500 then
1655 medals[hash].class.crackshot = "Bronze" -- Declare the medal's class.
1656 elseif medals[hash].count.crackshot > 500 and medals[hash].count.crackshot < 4000 then
1657 medals[hash].class.crackshot = "Silver" -- Declare the medal's class.
1658 elseif medals[hash].count.crackshot > 4000 and medals[hash].count.crackshot < 10000 then
1659 medals[hash].class.crackshot = "Gold" -- Declare the medal's class.
1660 elseif medals[hash].count.crackshot > 10000 and medals[hash].count.crackshot < 20000 then
1661 medals[hash].class.crackshot = "Onyx" -- Declare the medal's class.
1662 elseif medals[hash].count.crackshot > 20000 and medals[hash].count.crackshot < 32000 then
1663 medals[hash].class.crackshot = "MAX" -- Declare the medal's class.
1664 elseif medals[hash].count.crackshot > 32000 then
1665 medals[hash].class.crackshot = "MAX" -- Declare the medal's class.
1666 end
1667
1668 if medals[hash].count.downshift > 5 and medals[hash].count.downshift < 50 then
1669 medals[hash].class.downshift = "Bronze" -- Declare the medal's class.
1670 elseif medals[hash].count.downshift > 50 and medals[hash].count.downshift < 750 then
1671 medals[hash].class.downshift = "Silver" -- Declare the medal's class.
1672 elseif medals[hash].count.downshift > 750 and medals[hash].count.downshift < 4000 then
1673 medals[hash].class.downshift = "Gold" -- Declare the medal's class.
1674 elseif medals[hash].count.downshift > 4000 and medals[hash].count.downshift < 8000 then
1675 medals[hash].class.downshift = "Onyx" -- Declare the medal's class.
1676 elseif medals[hash].count.downshift > 8000 and medals[hash].count.downshift < 20000 then
1677 medals[hash].count.downshift = "MAX" -- Declare the medal's class.
1678 elseif medals[hash].count.downshift > 20000 then
1679 medals[hash].count.downshift = "MAX" -- Declare the medal's class.
1680 end
1681
1682 if medals[hash].count.grenadier > 25 and medals[hash].count.grenadier < 125 then
1683 medals[hash].class.grenadier = "Bronze" -- Declare the medal's class.
1684 elseif medals[hash].count.grenadier > 125 and medals[hash].count.grenadier < 500 then
1685 medals[hash].class.grenadier = "Silver" -- Declare the medal's class.
1686 elseif medals[hash].count.grenadier > 500 and medals[hash].count.grenadier < 4000 then
1687 medals[hash].class.grenadier = "Gold" -- Declare the medal's class.
1688 elseif medals[hash].count.grenadier > 4000 and medals[hash].count.grenadier < 8000 then
1689 medals[hash].class.grenadier = "Onyx" -- Declare the medal's class.
1690 elseif medals[hash].count.grenadier > 8000 and medals[hash].count.grenadier < 14000 then
1691 medals[hash].class.grenadier = "MAX" -- Declare the medal's class.
1692 elseif medals[hash].count.grenadier > 14000 then
1693 medals[hash].class.grenadier = "MAX" -- Declare the medal's class.
1694 end
1695
1696 if medals[hash].count.heavyweapons > 25 and medals[hash].count.heavyweapons < 150 then
1697 medals[hash].class.heavyweapons = "Bronze" -- Declare the medal's class.
1698 elseif medals[hash].count.heavyweapons > 150 and medals[hash].count.heavyweapons < 750 then
1699 medals[hash].class.heavyweapons = "Silver" -- Declare the medal's class.
1700 elseif medals[hash].count.heavyweapons > 750 and medals[hash].count.heavyweapons < 3000 then
1701 medals[hash].class.heavyweapons = "Gold" -- Declare the medal's class.
1702 elseif medals[hash].count.heavyweapons > 3000 and medals[hash].count.heavyweapons < 7000 then
1703 medals[hash].class.heavyweapons = "Onyx" -- Declare the medal's class.
1704 elseif medals[hash].count.heavyweapons > 7000 and medals[hash].count.heavyweapons < 14000 then
1705 medals[hash].class.heavyweapons = "MAX" -- Declare the medal's class.
1706 elseif medals[hash].count.heavyweapons > 14000 then
1707 medals[hash].class.heavyweapons = "MAX" -- Declare the medal's class.
1708 end
1709
1710 if medals[hash].count.jackofalltrades > 50 and medals[hash].count.jackofalltrades < 125 then
1711 medals[hash].class.jackofalltrades = "Bronze" -- Declare the medal's class.
1712 elseif medals[hash].count.jackofalltrades > 125 and medals[hash].count.jackofalltrades < 400 then
1713 medals[hash].class.jackofalltrades = "Silver" -- Declare the medal's class.
1714 elseif medals[hash].count.jackofalltrades > 400 and medals[hash].count.jackofalltrades < 1600 then
1715 medals[hash].class.jackofalltrades = "Gold" -- Declare the medal's class.
1716 elseif medals[hash].count.jackofalltrades > 1600 and medals[hash].count.jackofalltrades < 4800 then
1717 medals[hash].class.jackofalltrades = "Onyx" -- Declare the medal's class.
1718 elseif medals[hash].count.jackofalltrades > 4800 and medals[hash].count.jackofalltrades < 9600 then
1719 medals[hash].class.jackofalltrades = "MAX" -- Declare the medal's class.
1720 elseif medals[hash].count.jackofalltrades > 9600 then
1721 medals[hash].class.jackofalltrades = "MAX" -- Declare the medal's class.
1722 end
1723
1724 if medals[hash].count.moblieasset > 25 and medals[hash].count.moblieasset < 125 then
1725 medals[hash].class.mobileasset = "Bronze" -- Declare the medal's class.
1726 elseif medals[hash].count.moblieasset > 125 and medals[hash].count.moblieasset < 500 then
1727 medals[hash].class.mobileasset = "Silver" -- Declare the medal's class.
1728 elseif medals[hash].count.moblieasset > 500 and medals[hash].count.moblieasset < 4000 then
1729 medals[hash].class.mobileasset = "Gold" -- Declare the medal's class.
1730 elseif medals[hash].count.moblieasset > 4000 and medals[hash].count.moblieasset < 8000 then
1731 medals[hash].class.mobileasset = "Onyx" -- Declare the medal's class.
1732 elseif medals[hash].count.moblieasset > 8000 and medals[hash].count.moblieasset < 14000 then
1733 medals[hash].class.mobileasset = "MAX" -- Declare the medal's class.
1734 elseif medals[hash].count.moblieasset > 14000 then
1735 medals[hash].class.mobileasset = "MAX" -- Declare the medal's class.
1736 end
1737
1738 if medals[hash].count.multikill > 10 and medals[hash].count.multikill < 125 then
1739 medals[hash].class.multikill = "Bronze" -- Declare the medal's class.
1740 elseif medals[hash].count.multikill > 125 and medals[hash].count.multikill < 500 then
1741 medals[hash].class.multikill = "Silver" -- Declare the medal's class.
1742 elseif medals[hash].count.multikill > 500 and medals[hash].count.multikill < 2500 then
1743 medals[hash].class.multikill = "Gold" -- Declare the medal's class.
1744 elseif medals[hash].count.multikill > 2500 and medals[hash].count.multikill < 5000 then
1745 medals[hash].class.multikill = "Onyx" -- Declare the medal's class.
1746 elseif medals[hash].count.multikill > 5000 and medals[hash].count.multikill < 15000 then
1747 medals[hash].class.multikill = "MAX" -- Declare the medal's class.
1748 elseif medals[hash].count.multikill > 15000 then
1749 medals[hash].class.multikill = "MAX" -- Declare the medal's class.
1750 end
1751
1752 if medals[hash].count.sidearm > 50 and medals[hash].count.sidearm < 250 then
1753 medals[hash].class.sidearm = "Bronze" -- Declare the medal's class.
1754 elseif medals[hash].count.sidearm > 250 and medals[hash].count.sidearm < 1000 then
1755 medals[hash].class.sidearm = "Silver" -- Declare the medal's class.
1756 elseif medals[hash].count.sidearm > 1000 and medals[hash].count.sidearm < 4000 then
1757 medals[hash].class.sidearm = "Gold" -- Declare the medal's class.
1758 elseif medals[hash].count.sidearm > 4000 and medals[hash].count.sidearm < 8000 then
1759 medals[hash].class.sidearm = "Onyx" -- Declare the medal's class.
1760 elseif medals[hash].count.sidearm > 8000 and medals[hash].count.sidearm < 10000 then
1761 medals[hash].class.sidearm = "MAX" -- Declare the medal's class.
1762 elseif medals[hash].count.sidearm > 10000 then
1763 medals[hash].class.sidearm = "MAX" -- Declare the medal's class.
1764 end
1765
1766 if medals[hash].count.triggerman > 100 and medals[hash].count.triggerman < 500 then
1767 medals[hash].class.triggerman = "Bronze" -- Declare the medal's class.
1768 elseif medals[hash].count.triggerman > 500 and medals[hash].count.triggerman < 4000 then
1769 medals[hash].class.triggerman = "Silver" -- Declare the medal's class.
1770 elseif medals[hash].count.triggerman > 4000 and medals[hash].count.triggerman < 10000 then
1771 medals[hash].class.triggerman = "Gold" -- Declare the medal's class.
1772 elseif medals[hash].count.triggerman > 10000 and medals[hash].count.triggerman < 20000 then
1773 medals[hash].class.triggerman = "Onyx" -- Declare the medal's class.
1774 elseif medals[hash].count.triggerman > 20000 and medals[hash].count.triggerman < 32000 then
1775 medals[hash].class.triggerman = "MAX" -- Declare the medal's class.
1776 elseif medals[hash].count.triggerman > 32000 then
1777 medals[hash].class.triggerman = "MAX" -- Declare the medal's class.
1778 end
1779end
1780-- Comment for GivePlayerMedals : Will be called everytime a player's client is updated. It is to give them their medal and credits if they have earned a medal.
1781function GivePlayerMedals(player)
1782
1783 local hash = gethash(player) -- Get the player's hash.
1784
1785 if done[hash].medal.sprees == "False" then -- If the medal is not finished.
1786 if medals[hash].class.sprees == "Iron" and medals[hash].count.sprees >= 5 then -- If the class is iron and the count is more then 5,
1787 medals[hash].class.sprees = "Bronze" -- Level it up.
1788 say(getname(player) .. " has earned a medal : Any Spree Iron!") -- Tell them what they earned.
1789 elseif medals[hash].class.sprees == "Bronze" and medals[hash].count.sprees >= 50 then -- If the class is bronze and the count is more then 50.
1790 medals[hash].class.sprees = "Silver" -- Level it up.
1791 say(getname(player) .. " has earned a medal : Any Spree Bronze!") -- Tell them what they earned.
1792 elseif medals[hash].class.sprees == "Silver" and medals[hash].count.sprees >= 250 then -- If the class is silver and the clount is more then 250.
1793 medals[hash].class.sprees = "Gold" -- Level it up.
1794 say(getname(player) .. " has earned a medal : Any Spree Silver!") -- Tell them what they earned.
1795 elseif medals[hash].class.sprees == "Gold" and medals[hash].count.sprees >= 1000 then -- If the class is gold and the count is more then 1000.
1796 medals[hash].class.sprees = "Onyx" -- Level it up.
1797 say(getname(player) .. " has earned a medal : Any Spree Gold!") -- Tell them what they earned.
1798 elseif medals[hash].class.sprees == "Onyx" and medals[hash].count.sprees >= 4000 then -- If the class is onyx and the count is more then 4000.
1799 medals[hash].class.sprees = "MAX" -- Level it up.
1800 say(getname(player) .. " has earned a medal : Any Spree Onyx!") -- Tell them what they earned.
1801 elseif medals[hash].class.sprees == "MAX" and medals[hash].count.sprees == 10000 then -- if the class is max and the count is 10000.
1802 say(getname(player) .. " has earned a medal : Any Spree MAX!") -- Tell them what they have earned.
1803 done[hash].medal.sprees = "True" -- Declear that they have finished the medal.
1804 end
1805 end
1806
1807 if done[hash].medal.assists == "False" then -- If the medal is not finished.
1808 if medals[hash].class.assists == "Iron" and medals[hash].count.assists >= 50 then -- If the class is iron and the count is more then 50.
1809 medals[hash].class.assists = "Bronze" -- Level it up.
1810 say(getname(player) .. " has earned a medal : Assistant Iron!") -- Tell them what they earned.
1811 elseif medals[hash].class.assists == "Bronze" and medals[hash].count.assists >= 250 then -- If the class is bronze and the count is more then 250.
1812 medals[hash].class.assists = "Silver" -- Level it up.
1813 say(getname(player) .. " has earned a medal : Assistant Bronze!") -- Tell them what they earned.
1814 elseif medals[hash].class.assists == "Silver" and medals[hash].count.assists >= 1000 then -- If the class is silver and the count is more then 1000.
1815 medals[hash].class.assists = "Gold" -- Level it up.
1816 say(getname(player) .. " has earned a medal : Assistant Silver!") -- Tell them what they earned.
1817 elseif medals[hash].class.assists == "Gold" and medals[hash].count.assists >= 4000 then -- If the class is gold and the count is more then 4000.
1818 medals[hash].class.assists = "Onyx" -- Level it up.
1819 say(getname(player) .. " has earned a medal : Assistant Gold!") -- Tell them what they earned.
1820 elseif medals[hash].class.assists == "Onyx" and medals[hash].count.assists >= 8000 then -- If the class is onyx and the count is more then 8000.
1821 medals[hash].class.assists = "MAX" -- Level it up.
1822 say(getname(player) .. " has earned a medal : Assistant Onyx!") -- Tell them what they earned.
1823 elseif medals[hash].class.assists == "MAX" and medals[hash].count.assists == 20000 then -- If the class is max and the count is 20000.
1824 say(getname(player) .. " has earned a medal : Assistant MAX!") -- Tell them what they earned.
1825 done[hash].medal.assists = "True" -- Declear that they have finished the medal.
1826 end
1827 end
1828
1829 if done[hash].medal.closequarters == "False" then -- If the medal is not finished.
1830 if medals[hash].class.closequarters == "Iron" and medals[hash].count.closequarters >= 50 then -- If the class is iron and the count is more then 50.
1831 medals[hash].class.closequarters = "Bronze" -- Level it up.
1832 say(getname(player) .. " has earned a medal : Close Quarters Iron!") -- Tell them what they earned.
1833 elseif medals[hash].class.closequarters == "Bronze" and medals[hash].count.closequarters >= 125 then -- If the class is bronze and the count is more then 125.
1834 medals[hash].class.closequarters = "Silver" -- Level it up.
1835 say(getname(player) .. " has earned a medal : Close Quarters Bronze!") -- Tell them what they earned.
1836 elseif medals[hash].class.closequarters == "Silver" and medals[hash].count.closequarters >= 400 then -- If the class is silver and the count is more then 400.
1837 medals[hash].class.closequarters = "Gold" -- Level it up.
1838 say(getname(player) .. " has earned a medal : Close Quarters Silver!") -- Tell them what they earned.
1839 elseif medals[hash].class.closequarters == "Gold" and medals[hash].count.closequarters >= 1600 then -- If the class is gold and the count is more then 1600.
1840 medals[hash].class.closequarters = "Onyx" -- Level it up.
1841 say(getname(player) .. " has earned a medal : Close Quarters Gold!") -- Tell them what they earned.
1842 elseif medals[hash].class.closequarters == "Onyx" and medals[hash].count.closequarters >= 4000 then -- If the class is onyx and the count is more then 4000.
1843 medals[hash].class.closequarters = "MAX" -- Level it up.
1844 say(getname(player) .. " has earned a medal : Close Quarters Onyx!") -- Tell them what they earned.
1845 elseif medals[hash].class.closequarters == "MAX" and medals[hash].count.closequarters == 8000 then -- If the class is max and the count is 8000.
1846 say(getname(player) .. " has earned a medal : Close Quarters MAX!") -- Tell them what they earned.
1847 done[hash].medal.closequarters = "True" -- Declear that they have finished the medal.
1848 end
1849 end
1850
1851 if done[hash].medal.crackshot == "False" then -- If the medal is not finished.
1852 if medals[hash].class.crackshot == "Iron" and medals[hash].count.crackshot >= 100 then -- If the class is iron and the count is more then 100 .
1853 medals[hash].class.crackshot = "Bronze" -- Level it up.
1854 say(getname(player) .. " has earned a medal : Crack Shot Iron!") -- Tell them what they earned.
1855 elseif medals[hash].class.crackshot == "Bronze" and medals[hash].count.crackshot >= 500 then -- If the class is bronze and the count is more then 500.
1856 medals[hash].class.crackshot = "Silver" -- Level it up.
1857 say(getname(player) .. " has earned a medal : Crack Shot Bronze!") -- Tell them what they earned.
1858 elseif medals[hash].class.crackshot == "Silver" and medals[hash].count.crackshot >= 4000 then -- If the class is silver and the count is more then 4000.
1859 medals[hash].class.crackshot = "Gold" -- Level it up.
1860 say(getname(player) .. " has earned a medal : Crack Shot Silver!") -- Tell them what they earned.
1861 elseif medals[hash].class.crackshot == "Gold" and medals[hash].count.crackshot >= 10000 then -- If the class is gold and the count is more then 10000.
1862 medals[hash].class.crackshot = "Onyx" -- Level it up.
1863 say(getname(player) .. " has earned a medal : Crack Shot Gold!") -- Tell them what they earned.
1864 elseif medals[hash].class.crackshot == "Onyx" and medals[hash].count.crackshot >= 20000 then -- If the class is onyx and the count is more then 20000.
1865 medals[hash].class.crackshot = "MAX" -- Level it up.
1866 say(getname(player) .. " has earned a medal : Crack Shot Onyx!") -- Tell them what they earned.
1867 elseif medals[hash].class.crackshot == "MAX" and medals[hash].count.crackshot == 32000 then -- If the class is max and the count is 32000.
1868 say(getname(player) .. " has earned a medal : Crack Shot MAX!") -- Tell them what they earned.
1869 done[hash].medal.crackshot = "True" -- Declear that they have finished the medal.
1870 end
1871 end
1872
1873 if done[hash].medal.downshift == "False" then -- If the medal is not finished.
1874 if medals[hash].class.downshift == "Iron" and medals[hash].count.downshift >= 5 then -- If the class is iron and count is more then 5.
1875 medals[hash].class.downshift = "Bronze" -- Level it up.
1876 say(getnamye(player) .. " has earned a medal : Downshift Iron!") -- Tell them what they earned.
1877 elseif medals[hash].class.downshift == "Bronze" and medals[hash].count.downshift >= 50 then -- If the class is bronze and count is more then 50.
1878 medals[hash].class.downshift = "Silver" -- Level it up
1879 say(getname(player) .. " has earned a medal : Downshift Bronze!") -- Tell them what the earned.
1880 elseif medals[hash].class.downshift == "Silver" and medals[hash].count.downshift >= 750 then -- If the class is silver and count is more then 750.
1881 medals[hash].class.downshift = "Gold" -- Level it up.
1882 say(getname(player) .. " has earned a medal : Downshift Silver!") -- Tell them what they earned.
1883 elseif medals[hash].class.downshift == "Gold" and medals[hash].count.downshift >= 4000 then -- If the class is gold and count is more then 4000.
1884 medals[hash].class.downshift = "Onyx" -- Level it up.
1885 say(getname(player) .. " has earned a medal : Downshift Gold!") -- Tell them what they earned.
1886 elseif medals[hash].class.downshift == "Onyx" and medals[hash].count.downshift >= 8000 then -- If the class is onyx and count is more then 8000.
1887 medals[hash].class.downshift = "MAX" -- Level it up.
1888 say(getname(player) .. " has earned a medal : Downshift Onyx!") -- Tell them what they earned.
1889 elseif medals[hash].class.downshift == "MAX" and medals[hash].count.downshift == 20000 then -- If the class is max and count is 20000.
1890 say(getname(player) .. " has earned a medal : Downshift MAX!") -- Tell them what they earned.
1891 done[hash].medal.downshift = "True" -- Declear that they have finished the medal.
1892 end
1893 end
1894
1895 if done[hash].medal.grenadier == "False" then -- If the medal is not finished.
1896 if medals[hash].class.grenadier == "Iron" and medals[hash].count.grenadier >= 25 then -- If the class is iron and count is more then 25.
1897 medals[hash].class.grenadier = "Bronze" -- Level it up.
1898 say(getname(player) .. " has earned a medal : Grenadier Iron!") -- Tell them what they earned.
1899 elseif medals[hash].class.grenadier == "Bronze" and medals[hash].count.grenadier >= 125 then -- If the class is bronze and count is more then 125.
1900 medals[hash].class.grenadier = "Silver" -- Level it up.
1901 say(getname(player) .. " has earned a medal : Grenadier Bronze!") -- Tell them what they earned.
1902 elseif medals[hash].class.grenadier == "Silver" and medals[hash].count.grenadier >= 500 then -- If the class is silver and count is more then 500.
1903 medals[hash].class.grenadier = "Gold" -- Level it up.
1904 say(getname(player) .. " has earned a medal : Grenadier Silver!") -- Tell them what they earned.
1905 elseif medals[hash].class.grenadier == "Gold" and medals[hash].count.grenadier >= 4000 then -- If the class is gold and count is more then 4000.
1906 medals[hash].class.grenadier = "Onyx" -- Level it up.
1907 say(getname(player) .. " has earned a medal : Grenadier Gold!") -- Tell them what they earned.
1908 elseif medals[hash].class.grenadier == "Onyx" and medals[hash].count.grenadier >= 8000 then -- If the class is onyx and count is more then 8000.
1909 medals[hash].class.grenadier = "MAX" -- Level it up
1910 say(getname(player) .. " has earned a medal : Grenadier Onyx!") -- Tell them what they earned.
1911 elseif medals[hash].class.grenadier == "MAX" and medals[hash].count.grenadier == 14000 then -- If the class is max and count is 14000.
1912 say(getname(player) .. " has earned a medal : Grenadier MAX!") -- Tell them what they earned.
1913 done[hash].medal.grenadier = "True" -- Declear that they have finished the medal.
1914 end
1915 end
1916
1917 if done[hash].medal.heavyweapons == "False" then -- If the medal is not finished.
1918 if medals[hash].class.heavyweapons == "Iron" and medals[hash].count.heavyweapons >= 25 then -- Check the count and the rank.
1919 medals[hash].class.heavyweapons = "Bronze" -- Change the rank.
1920 say(getname(player) .. " has earned a medal : Heavy Weapon Iron!") -- Tell them what they earned.
1921 elseif medals[hash].class.heavyweapons == "Bronze" and medals[hash].count.heavyweapons >= 150 then -- Check the count and the rank.
1922 medals[hash].class.heavyweapons = "Silver" -- Change the rank.
1923 say(getname(player) .. " has earned a medal : Heavy Weapon Bronze!") -- Tell them what they earned.
1924 elseif medals[hash].class.heavyweapons == "Silver" and medals[hash].count.heavyweapons >= 750 then -- Check the count and the rank.
1925 medals[hash].class.heavyweapons = "Gold" -- Change the rank.
1926 say(getname(player) .. " has earned a medal : Heavy Weapon Silver!") -- Tell them what they earned.
1927 elseif medals[hash].class.heavyweapons == "Gold" and medals[hash].count.heavyweapons >= 3000 then -- Check the count and the rank.
1928 medals[hash].class.heavyweapons = "Onyx" -- Change the rank.
1929 say(getname(player) .. " has earned a medal : Heavy Weapon Gold!") -- Tell them what they earned.
1930 elseif medals[hash].class.heavyweapons == "Onyx" and medals[hash].count.heavyweapons >= 7000 then -- Check the count and the rank.
1931 medals[hash].class.heavyweapons = "MAX" -- Change the rank.
1932 say(getname(player) .. " has earned a medal : Heavy Weapon Onyx!") -- Tell them what they earned.
1933 elseif medals[hash].class.heavyweapons == "MAX" and medals[hash].count.heavyweapons == 14000 then -- Check the count and the rank.
1934 say(getname(player) .. " has earned a medal : Heavy Weapon MAX!") -- Tell them what they earned.
1935 done[hash].medal.heavyweapons = "True" -- Declear that they have finished the medal.
1936 end
1937 end
1938
1939 if done[hash].medal.jackofalltrades == "False" then -- If the medal is not finished.
1940 if medals[hash].class.jackofalltrades == "Iron" and medals[hash].count.jackofalltrades >= 50 then -- Check the count and the rank.
1941 medals[hash].class.jackofalltrades = "Bronze" -- Change the rank.
1942 say(getname(player) .. " has earned a medal : Jack of all Trades Iron!") -- Tell them what they earned.
1943 elseif medals[hash].class.jackofalltrades == "Bronze" and medals[hash].count.jackofalltrades >= 125 then -- Check the count and the rank.
1944 medals[hash].class.jackofalltrades = "Silver" -- Change the rank.
1945 say(getname(player) .. " has earned a medal : Jack of all Trades Bronze!") -- Tell them what they earned.
1946 elseif medals[hash].class.jackofalltrades == "Silver" and medals[hash].count.jackofalltrades >= 400 then -- Check the count and the rank.
1947 medals[hash].class.jackofalltrades = "Gold" -- Change the rank.
1948 say(getname(player) .. " has earned a medal : Jack of all Trades Silver!") -- Tell them what they earned.
1949 elseif medals[hash].class.jackofalltrades == "Gold" and medals[hash].count.jackofalltrades >= 1600 then -- Check the count and the rank.
1950 medals[hash].class.jackofalltrades = "Onyx" -- Change the rank.
1951 say(getname(player) .. " has earned a medal : Jack of all Trades Gold!") -- Tell them what they earned.
1952 elseif medals[hash].class.jackofalltrades == "Onyx" and medals[hash].count.jackofalltrades >= 4800 then -- Check the count and the rank.
1953 medals[hash].class.jackofalltrades = "MAX" -- Change the rank.
1954 say(getname(player) .. " has earned a medal : Jack of all Trades Onyx!") -- Tell them what they earned.
1955 elseif medals[hash].class.jackofalltrades == "MAX" and medals[hash].count.jackofalltrades == 9600 then -- Check the count and the rank.
1956 say(getname(player) .. " has earned a medal : Jack of all Trades MAX!") -- Tell them what they earned.
1957 done[hash].medal.jackofalltrades = "True" -- Declear that they have finished the medal.
1958 end
1959 end
1960
1961 if done[hash].medal.mobileasset == "False" then -- If the medal is not finished.
1962 if medals[hash].class.mobileasset == "Iron" and medals[hash].count.moblieasset >=25 then -- Check the count and the rank.
1963 medals[hash].class.mobileasset = "Bronze" -- Change the rank.
1964 say(getname(player) .. " has earned a medal : Mobile Asset Iron!") -- Tell them what they earned.
1965 elseif medals[hash].class.mobileasset == "Bronze" and medals[hash].count.moblieasset >= 125 then -- Check the count and the rank.
1966 medals[hash].class.mobileasset = "Silver" -- Change the rank.
1967 say(getname(player) .. " has earned a medal : Mobile Asset Bronze!") -- Tell them what they earned.
1968 elseif medals[hash].class.mobileasset == "Silver" and medals[hash].count.moblieasset >= 500 then -- Check the count and the rank.
1969 medals[hash].class.mobileasset = "Gold" -- Change the rank.
1970 say(getname(player) .. " has earned a medal : Mobile Asset Silver!") -- Tell them what they earned.
1971 elseif medals[hash].class.mobileasset == "Gold" and medals[hash].count.moblieasset >= 4000 then -- Check the count and the rank.
1972 medals[hash].class.mobileasset = "Onyx" -- Change the rank.
1973 say(getname(player) .. " has earned a medal : Mobile Asset Gold!") -- Tell them what they earned.
1974 elseif medals[hash].class.mobileasset == "Onyx" and medals[hash].count.moblieasset >= 8000 then -- Check the count and the rank.
1975 medals[hash].class.mobileasset = "MAX" -- Change the rank.
1976 say(getname(player) .. " has earned a medal : Mobile Asset Onyx!") -- Tell them what they earned.
1977 elseif medals[hash].class.mobileasset == "MAX" and medals[hash].count.moblieasset == 14000 then -- Check the count and the rank.
1978 say(getname(player) .. " has earned a medal : Mobile Asset MAX!") -- Tell them what they earned.
1979 done[hash].medal.mobileasset = "True" -- Declear that they have finished the medal.
1980 end
1981 end
1982
1983 if done[hash].medal.multikill == "False" then -- If the medal is not finished.
1984 if medals[hash].class.multikill == "Iron" and medals[hash].count.multikill >= 10 then -- Check the count and the rank.
1985 medals[hash].class.multikill = "Bronze" -- Change the rank.
1986 say(getname(player) .. " has earned a medal : Multikill Iron!") -- Tell them what they earned.
1987 elseif medals[hash].class.multikill == "Bronze" and medals[hash].count.multikill >= 125 then -- Check the count and the rank.
1988 medals[hash].class.multikill = "Silver" -- Change the rank.
1989 say(getname(player) .. " has earned a medal : Multikill Bronze!") -- Tell them what they earned.
1990 elseif medals[hash].class.multikill == "Silver" and medals[hash].count.multikill >= 500 then -- Check the count and the rank.
1991 medals[hash].class.multikill = "Gold" -- Change the rank.
1992 say(getname(player) .. " has earned a medal : Multikill Silver!") -- Tell them what they earned.
1993 elseif medals[hash].class.multikill == "Gold" and medals[hash].count.multikill >= 2500 then -- Check the count and the rank.
1994 medals[hash].class.multikill = "Onyx" -- Change the rank.
1995 say(getname(player) .. " has earned a medal : Multikill Gold!") -- Tell them what they earned.
1996 elseif medals[hash].class.multikill == "Onyx" and medals[hash].count.multikill >= 5000 then -- Check the count and the rank.
1997 medals[hash].class.multikill = "MAX" -- Change the rank.
1998 say(getname(player) .. " has earned a medal : Multikill Onyx!") -- Tell them what they earned.
1999 elseif medals[hash].class.multikill == "MAX" and medals[hash].count.multikill == 15000 then -- Check the count and the rank.
2000 say(getname(player) .. " has earned a mdeal : Multikill MAX!") -- Tell them what they earned.
2001 done[hash].medal.multikill = "True" -- Declear that they have finished the medal.
2002 end
2003 end
2004
2005 if done[hash].medal.sidearm == "False" then -- If the medal is not finished.
2006 if medals[hash].class.sidearm == "Iron" and medals[hash].count.sidearm >= 50 then -- Check the count and the rank.
2007 medals[hash].class.sidearm = "Bronze" -- Change the rank.
2008 say(getname(player) .. " has earned a medal : Sidearm Iron!") -- Tell them what they earned.
2009 elseif medals[hash].class.sidearm == "Bronze" and medals[hash].count.sidearm >= 250 then -- Check the count and the rank.
2010 medals[hash].class.sidearm = "Silver" -- Change the rank.
2011 say(getname(player) .. " has earned a medal : Sidearm Bronze!") -- Tell them what they earned.
2012 elseif medals[hash].class.sidearm == "Silver" and medals[hash].count.sidearm >= 1000 then -- Check the count and the rank.
2013 medals[hash].class.sidearm = "Gold" -- Change the rank.
2014 say(getname(player) .. " has earned a medal : Sidearm Silver!") -- Tell them what they earned.
2015 elseif medals[hash].class.sidearm == "Gold" and medals[hash].count.sidearm >= 4000 then -- Check the count and the rank.
2016 medals[hash].class.sidearm = "Onyx" -- Change the rank.
2017 say(getname(player) .. " has earned a medal : Sidearm Gold!") -- Tell them what they earned.
2018 elseif medals[hash].class.sidearm == "Onyx" and medals[hash].count.sidearm >= 8000 then -- Check the count and the rank.
2019 medals[hash].class.sidearm = "MAX" -- Change the rank.
2020 say(getname(player) .. " has earned a medal : Sidearm Onyx!") -- Tell them what they earned.
2021 elseif medals[hash].class.sidearm == "MAX" and medals[hash].count.sidearm == 10000 then -- Check the count and the rank.
2022 say(getname(player) .. " has earned a medal : Sidearm MAX!") -- Tell them what they earned.
2023 done[hash].medal.sidearm = "True" -- Declear that they have finished the medal.
2024 end
2025 end
2026
2027 if done[hash].medal.triggerman == "False" then -- If the medal is not finished.
2028 if medals[hash].class.triggerman == "Iron" and medals[hash].count.triggerman >= 100 then -- Check the count and the rank.
2029 medals[hash].class.triggerman = "Bronze" -- Change the rank.
2030 say(getname(player) .. " has earned a medal : Triggerman Iron!") -- Tell them what they earned.
2031 elseif medals[hash].class.triggerman == "Bronze" and medals[hash].count.triggerman >= 500 then -- Check the count and the rank.
2032 medals[hash].class.triggerman = "Silver" -- Change the rank.
2033 say(getname(player) .. " has earned a medal : Triggerman Bronze!") -- Tell them what they earned.
2034 elseif medals[hash].class.triggerman == "Silver" and medals[hash].count.triggerman >= 4000 then -- Check the count and the rank.
2035 medals[hash].class.triggerman = "Gold" -- Change the rank.
2036 say(getname(player) .. " has earned a medal : Triggerman Silver!") -- Tell them what they earned.
2037 elseif medals[hash].class.triggerman == "Gold" and medals[hash].count.triggerman >= 10000 then -- Check the count and the rank.
2038 medals[hash].class.triggerman = "Onyx" -- Change the rank.
2039 say(getname(player) .. " has earned a medal : Triggerman Gold!") -- Tell them what they earned.
2040 elseif medals[hash].class.triggerman == "Onyx" and medals[hash].count.triggerman >= 20000 then -- Check the count and the rank.
2041 medals[hash].class.triggerman = "MAX" -- Change the rank.
2042 say(getname(player) .. " has earned a medal : Triggerman Onyx!") -- Tell them what they earned.
2043 elseif medals[hash].class.triggerman == "MAX" and medals[hash].count.triggerman == 32000 then -- Check the count and the rank.
2044 say(getname(player) .. " has earned a medal : Triggerman MAX!") -- Tell them what they earned.
2045 done[hash].medal.triggerman = "True" -- Declear that they have finished the medal.
2046 end
2047 end
2048end
2049
2050-- Comment for EditScore : It will change the player's score if enabled.
2051function EditScore(player, amount, type)
2052
2053 local m_player = getplayer(player) -- Declare m_player.
2054 local gt = GetGametype() -- Get the gametype.
2055 if gt == "CTF" then -- If the gametype is CTF
2056 if type == "+" then -- If the type is +
2057 if tonumber(amount) then -- If amount is a number.
2058 local score = readword(m_player, 0xC8) -- Get the player's score.
2059 local setscore = score + amount -- Declare setscore.
2060 writeword(m_player, 0xC8, setscore) -- Write the player's score.
2061 end
2062 elseif type == "-" then -- If the type is -
2063 if tonumber(amount) then -- If the amount is a number.
2064 local score = readword(m_player, 0xC8) -- Get the player's score.
2065 local setscore = score - amount -- Declare setscore.
2066 writeword(m_player, 0xC8, setscore) -- Write the player's score.
2067 end
2068 elseif type == "=" then -- If the type is =
2069 if tonumber(amount) then -- If amount is a number.
2070 local score = amount -- Declare score.
2071 writeword(m_player, 0xC8, score) -- Write the player's score.
2072 end
2073 end
2074 elseif gt == "Team Race" or gt == "FFA Race" then -- If the gametype is Team Race or FFA Race
2075 if type == "+" then -- If the type is +
2076 if tonumber(amount) then -- If amount is a number.
2077 local score = readword(m_player, 0xC6) -- Get the player's score.
2078 local setscore = score + amount -- Declare setscore.
2079 writeword(m_player, 0xC6, setscore) -- Write the player's score.
2080 end
2081 elseif type == "-" then -- If type is -
2082 if tonumber(amount) then -- If amount is a number.
2083 local score = readword(m_player, 0xC6) -- Get the player's score.
2084 local setscore = score - amount -- Declare setscore.
2085 writeword(m_player, 0xC6, setscore) -- Write the player's score.
2086 end
2087 elseif type == "=" then -- If type is =
2088 if tonumber(amount) then -- If amount is a number.
2089 local score = amount -- Declare score.
2090 writeword(m_player, 0xC6, score) -- Write the player's score.
2091 end
2092 end
2093 elseif gt == "FFA Slayer" or gt == "Team Slayer" then
2094 if type == "+" then
2095 if tonumber(amount) then
2096 local score = readdword(slayer_globals + player*4, 0x40)
2097 local setscore = score + amount
2098 writedword(slayer_globals + player*4, 0x40, setscore)
2099 end
2100 elseif type == "-" then
2101 if tonumber(amount) then
2102 local score = readdword(slayer_globals + player*4, 0x40)
2103 local setscore = score - amount
2104 writedword(slayer_globals + player*4, 0x40, setscore)
2105 end
2106 elseif type == "=" then
2107 if tonumber(amount) then
2108 local score = amount
2109 writedword(slayer_globals + player*4, 0x40, score)
2110 end
2111 end
2112 end
2113end
2114
2115
2116-- Function writted by Nuggets.
2117-- Comment for secondsToTime : Will turn an amount of seconds into an amount of years, weeks, days hours, or minutes.
2118function secondsToTime(seconds, places)
2119
2120 local years = math.floor(seconds / (60 * 60 * 24 * 365))
2121 seconds = seconds % (60 * 60 * 24 * 365)
2122 local weeks = math.floor(seconds / (60 * 60 * 24 * 7))
2123 seconds = seconds % (60 * 60 * 24 * 7)
2124 local days = math.floor(seconds / (60 * 60 * 24))
2125 seconds = seconds % (60 * 60 * 24)
2126 local hours = math.floor(seconds / (60 * 60))
2127 seconds = seconds % (60 * 60)
2128 local minutes = math.floor(seconds / 60)
2129 seconds = seconds % 60
2130
2131 if places == 6 then
2132 return string.format("%02d:%02d:%02d:%02d:%02d:%02d", years, weeks, days, hours, minutes, seconds)
2133 elseif places == 5 then
2134 return string.format("%02d:%02d:%02d:%02d:%02d", weeks, days, hours, minutes, seconds)
2135 elseif not places or places == 4 then
2136 return days, hours, minutes, seconds
2137 elseif places == 3 then
2138 return string.format("%02d:%02d:%02d", hours, minutes, seconds)
2139 elseif places == 2 then
2140 return string.format("%02d:%02d", minutes, seconds)
2141 elseif places == 1 then
2142 return string.format("%02", seconds)
2143 end
2144end
2145
2146-- Function made by Nuggets.
2147-- Comment for math.round : Will round a number.
2148function math.round(val, precision)
2149
2150 if (decimal) then
2151 return math.floor((val * 10^decimal) + 0.5) / (10^decimal)
2152 else
2153 return math.floor(val+0.5)
2154 end
2155end
2156
2157-- Table Functions written by Nuggets.
2158
2159function table.len(t)
2160
2161 local count = 0
2162 for k,v in pairs(t) do
2163 count = count + 1
2164 end
2165 return count
2166end
2167
2168function table.find(t, value)
2169
2170 for k,v in pairs(t) do
2171 if v == value then
2172 return k
2173 end
2174 end
2175end
2176
2177function table.random(array, n, allow_multiple)
2178
2179 n = math.min(n, #array)
2180 local chosen = {}
2181 for i = 1, n do
2182 local rand
2183 if not allow_multiple then
2184 repeat
2185 rand = getrandomnumber(1, #array + 1)
2186 until not table.find(chosen, rand)
2187 table.insert(chosen, array[rand])
2188 else
2189 table.insert(chosen, array[getrandomnumber(1, #array + 1)])
2190 end
2191 end
2192
2193 return chosen
2194end
2195
2196function table.max(t)
2197
2198 local key, max = 0, 0
2199 for k,v in pairs(t) do
2200 if type(v) == "number" then
2201 if v > max then
2202 max = v
2203 key = k
2204 end
2205 end
2206 end
2207
2208 return key
2209end
2210
2211function table.save(t, filename)
2212
2213 local dir = getprofilepath()
2214 local file = io.open(dir .. "\\data\\" .. filename, "w+")
2215 local spaces = 1
2216
2217 local function format(t)
2218
2219 local function whitespace(num)
2220 local str = ""
2221 for i = 1, num do
2222 str = str .. "\t"
2223 end
2224
2225 return str
2226 end
2227
2228 local str = ""
2229
2230 for k,v in pairs(t) do
2231 if type(v) == "string" then
2232 v = string.format("%q", v)
2233 end
2234 if type(k) == "string" then
2235 k = string.format("%q", k)
2236 end
2237 k = tostring(k)
2238 if v == math.inf then
2239 v = "1 / 0"
2240 end
2241 if type(v) == "table" then
2242 if table.len(v) > 0 then
2243 spaces = spaces + 1
2244 str = str .. "\n" .. whitespace(spaces - 1) .. "[" .. k .. "] = {" .. format(v) .."\n" .. whitespace(spaces - 1) .. "},"
2245 spaces = spaces - 1
2246 else
2247 str = str .. "\n" .. whitespace(spaces) .. "[" .. k .. "] = {},"
2248 end
2249 else
2250 str = str .."\n" .. whitespace(spaces) .. "[" .. k .. "] = " .. tostring(v) .. ","
2251 end
2252 end
2253
2254 return string.sub(str, 1, string.len(str) - 1)
2255 end
2256
2257 file:write("return {" .. format(t) .. "\n}")
2258 file:close()
2259end
2260
2261function table.load(filename)
2262
2263 local dir = getprofilepath()
2264 local exists = loadfile(dir .. "\\data\\" .. filename)
2265 local t
2266 if exists then
2267 t = exists()
2268 end
2269 return t or {}
2270end
2271
2272function table.string(t)
2273
2274 local spaces = 1
2275
2276 local function format(t)
2277
2278 local function whitespace(num)
2279 local str = ""
2280 for i = 1, num do
2281 str = str .. "\t"
2282 end
2283
2284 return str
2285 end
2286
2287 local str = ""
2288
2289 for k,v in pairs(t) do
2290 if type(v) == "string" then
2291 v = string.format("%q", v)
2292 end
2293 if type(k) == "string" then
2294 k = string.format("%q", k)
2295 end
2296 k = tostring(k)
2297 if v == math.inf then
2298 v = "1 / 0"
2299 end
2300 if type(v) == "table" then
2301 if table.len(v) > 0 then
2302 spaces = spaces + 1
2303 str = str .. "\n" .. whitespace(spaces - 1) .. "[" .. k .. "] = {" .. format(v) .."\n" .. whitespace(spaces - 1) .. "},"
2304 spaces = spaces - 1
2305 else
2306 str = str .. "\n" .. whitespace(spaces) .. "[" .. k .. "] = {},"
2307 end
2308 else
2309 str = str .."\n" .. whitespace(spaces) .. "[" .. k .. "] = " .. tostring(v) .. ","
2310 end
2311 end
2312
2313 return string.sub(str, 1, string.len(str) - 1)
2314 end
2315
2316 return "{" .. format(t) .. "}"
2317end
2318
2319
2320-- Hprint Function by Nuggets.
2321function hprint(player, text, time, align, func)
2322
2323 console[player] = console[player] or {}
2324 local id = nextindex(player)
2325 console[player][id] = {}
2326 console[player][id].p = player
2327 console[player][id].id = id
2328 console[player][id].msg = text
2329 console[player][id].t = time or 5
2330 console[player][id].r = time or 5
2331 console[player][id].f = func
2332 console[player][id].a = align or "left"
2333
2334 setmetatable(console[player][id], console)
2335 return console[player][id]
2336end
2337
2338function nextindex(player)
2339
2340 local max = 0
2341 for k,v in pairs(console[player]) do
2342 if k > max then
2343 max = k
2344 end
2345 end
2346
2347 return max + 1
2348end
2349
2350function getmessages(player)
2351
2352 return console[player]
2353end
2354
2355function console:append(text, time_reset)
2356
2357 local player = self.p
2358 if getplayer(player) then
2359 local id = self.id
2360 if console[player] then
2361 if console[player][id] then
2362 console[player][id].msg = text
2363 if time_reset == true or time_reset == nil then
2364 console[player][id].r = console[player][id].t
2365 end
2366 end
2367 end
2368 end
2369end
2370
2371function console:message()
2372
2373 return self.msg
2374end
2375
2376function console:player()
2377
2378 return self.p
2379end
2380
2381function console:time()
2382
2383 return self.t
2384end
2385
2386function console:remaining()
2387
2388 return self.r
2389end
2390
2391function console:index()
2392
2393 return self.id
2394end
2395
2396function console:func()
2397
2398 return self.f
2399end
2400
2401function console:alignment()
2402
2403 return self.a
2404end
2405
2406function console:delete()
2407
2408 console[self.p][self.id] = nil
2409end
2410
2411function console:pause(duration)
2412
2413 duration = duration or 5
2414 console[self.p][self.id].pa = duration
2415end
2416
2417function console:paused()
2418
2419 return self.pa
2420end
2421
2422function ConsoleTimer(id, count)
2423
2424 for player,t in opairs(console) do
2425 if type(t) == "table" and player ~= "__index" then
2426 for id,t2 in opairs(t) do
2427 if console[player][id].pa then
2428 console[player][id].pa = console[player][id].pa - 0.1
2429 if console[player][id].pa <= 0 then
2430 console[player][id].pa = nil
2431 end
2432 else
2433 console[player][id].r = console[player][id].r - 0.1
2434 if console[player][id].r <= 0 then
2435 console[player][id] = nil
2436 end
2437 end
2438
2439 if console[player][id] then
2440 if console[player][id].f then
2441 if not console[player][id].f(player) then
2442 console[player][id] = nil
2443 end
2444 end
2445 end
2446 end
2447 end
2448 end
2449
2450 for player,t in opairs(console) do
2451 if type(t) == "table" and player ~= "__index" then
2452 if getplayer(player) then
2453 if table.len(t) > 0 then
2454 local paused = 0
2455 for id,t2 in pairs(t) do
2456 if console[player][id].pa then
2457 paused = paused + 1
2458 end
2459 end
2460
2461 if paused < table.len(t) then
2462 local str = ""
2463 for i = 0,30 do
2464 str = str .. "\n "
2465 end
2466 hprintf(str, player)
2467 for id,t2 in opairs(t) do
2468 if console[player][id].a == "left" then
2469 hprintf(console[player][id].msg, player)
2470 elseif console[player][id].a == "right" then
2471 hprintf(consolerightalign(console[player][id].msg), player)
2472 end
2473 end
2474 end
2475 end
2476 else
2477 console[player] = nil
2478 end
2479 end
2480 end
2481
2482 return true
2483end
2484
2485-- Console text length limit = 78
2486function consolerightalign(text)
2487
2488 local len = string.len(text)
2489 for i = len + 1, 78 do
2490 text = " " .. text
2491 end
2492
2493 return text
2494end
2495
2496function opairs(t)
2497
2498 local keys = {}
2499 for k,v in pairs(t) do
2500 table.insert(keys, k)
2501 end
2502 table.sort(keys,
2503 function(a,b)
2504 if type(a) == "number" and type(b) == "number" then
2505 return a < b
2506 end
2507 an = string.lower(tostring(a))
2508 bn = string.lower(tostring(b))
2509 if an ~= bn then
2510 return an < bn
2511 else
2512 return tostring(a) < tostring(b)
2513 end
2514 end)
2515 local count = 1
2516 return function()
2517 if unpack(keys) then
2518 local key = keys[count]
2519 local value = t[key]
2520 count = count + 1
2521 return key,value
2522 end
2523 end
2524end
2525
2526function table.len(t)
2527
2528 local count = 0
2529 for k,v in pairs(t) do
2530 count = count + 1
2531 end
2532
2533 return count
2534end