The script has been updated! I've redesigned the GUI, added a couple commands, reformatted the text, and fixed a couple of bugs. The installation instructions remain the same. /customize has been removed.
Commands:
getrecord [MAPNAME] [MODENAME] - It grabs the record for the given information and displays it in the console. If no map/mode has been specified, it displays the record for the current game. If the map is specified, a mode must be given as well (same mode name as if voting for one).
setrecord - Toggles record keeping on or off. This can also be changed through the Settings menu in the Records GUI.
Code:
//Frag Records (Vanilla Edition) 3.0 (27/12/17) - by [FD]Venera
//Save this code as "fragrecords.cfg" then add 'exec "/PATH/TO/fragrecords.cfg"' to your autoexec.cfg to install the script.
//This script will keep track of your frag records for every mode except coop-edit.
//When your frags in a game surpass the current frags stored for that map/mode, it will update with all of your stats for that game.
//fragdata_MAPNAME = [ [MODENUM FRAGS DEATHS KpD ACC FLAGS (if applicable)] [MODENUM2 FRAGS2 ... ] ]
//fragmodes_MAPNAME = [MODENUM MODENUM MODENUM]
//fragdata_list = [MAPNAME MAPNAME2 MAPNAME3 ...]
//Check if aliases needed are set, if not, set them
if (=s (getalias fragdata_list) "") [ fragdata_list = "None" ]
if (=s (getalias fragkey) "") [ fragkey = "p" ]
if (=s (getalias fragrec_switch) "") [ fragrec_switch = 1 ]
//Set the bind and say it's working
bind $fragkey [ showgui "Frag Records" ]
echo (format "^f6[ RECORDS ] ^f7Frag Records activated! Open the menu with ^f6%1^f7!" $fragkey)
//GUI - Main Menu
newgui "Frag Records" [
guistayopen [
guititle "^f3[ MAIN MENU ]"
guibar
guibutton "^f7Show Records" [ showgui "Map List" ]
guibutton "^f4Settings" [ showgui "Frag Records Settings" ]
guibar
guibutton "^f3Close" [ cleargui ]
]
]
//GUI - Settings
newgui "Frag Records Settings" [
guistayopen [
guititle "^f3[ SETTINGS ]"
guibar
guibutton "^f3Back" [ showgui "Frag Records" ]
guibar
guilist [
guilist [
guilist [
guitext "^f6Bound Key: "
guifield fragkey 10
]
]
guibar
guilist [
guibutton "^f7Clear ^f3all ^f7records" [ showgui "Clear Records" ]
guibar
guicheckbox "^f0Show delete buttons" customize_switch
guicheckbox "^f0Collect records on intermission" fragrec_switch
]
]
]
]
//GUI - Clear Records
newgui "Clear Records" [
guistayopen [
guitext "Are you sure you want to clear all records?"
guibar
guibutton "^f0Yes" [ fragrec_clearall ]
guibutton "^f3No" [ showgui "Frag Records Settings" ]
]
]
//GUI - Map list
newgui "Map List" [
guistayopen [
guititle "^f3[ MAP LIST ]"
guibar
guibutton "^f3Go back" [ showgui "Frag Records" ]
guibar
guilist [
guitext "^f6Search: "
guifield fragdata_searchbox 20
guibar
guibutton "^f0Go" [ fragdata_search $fragdata_searchbox ]
]
guibar
//Loop the current list and create buttons
tabindex = 0
tabcounter = 1
looplist mapbutton $fragdata_list [
if (= $tabindex 14) [
guitab $tabcounter
tabcounter = (+ $tabcounter 1)
tabindex = -4
]
guilist [
if (customize_switch) [ guibutton "^f3X " [fragdata_clearmap @mapbutton] ]
guibar
guibutton $mapbutton [ fragdata_viewmap = @mapbutton; showgui "Records" ]
]
tabindex = (+ $tabindex 1)
]
]
]
//GUI - Record list for the map
newgui "Records" [
guistayopen [
tempname = [fragdata_@fragdata_viewmap]
fragdata = (getalias $tempname)
//Title the list with the map name
guititle $fragdata_viewmap
guibutton "^f3Map list" [showgui "Frag Records"]
guibar
//Loop through the list of data and do the thing
looplist curdata $fragdata [
if (inlist $fragctfmodes (at $fragmodenames (at $curdata 0))) [
guilist [
if (customize_switch) [ guibutton "^f3X " [ fragdata_clearmode @fragdata_viewmap @(at $curdata 0) ] ]
datatext = (format "^f6%1 ^f1| ^f5Frags: ^f0%2 ^f5Deaths: ^f0%3 ^f5KpD: ^f0%4 ^f5Acc: ^f0%5 ^f5Flags: ^f0%6" (at $fragmodenames (at $curdata 0)) (at $curdata 1) (at $curdata 2) (at $curdata 3) (at $curdata 4) (at $curdata 5) (at $curdata 6))
guitext $datatext
]
guibar
] [
guilist [
if (customize_switch) [ guibutton "^f3X " [ fragdata_clearmode @fragdata_viewmap @(at $curdata 0) ] ]
datatext = (format "^f6%1 ^f1| ^f5Frags: ^f0%2 ^f5Deaths: ^f0%3 ^f5KpD: ^f0%4 ^f5Acc: ^f0%5" (at $fragmodenames (at $curdata 0)) (at $curdata 1) (at $curdata 2) (at $curdata 3) (at $curdata 4) (at $curdata 5))
guitext $datatext
]
guibar
]
]
]
]
//Functions that accomplish things
fragrec_addrecord = [ //Adds records. 0 = Completely new, 1 = map exists, but not mode, 2 = beat previous record
fragrec_replace = $arg1
fragrec_add = -1
if (=s $fragdata_list "None") [ fragdata_list = "" ]
mapdata_alias = [fragdata_@mapname]
mapdata = (getalias $mapdata_alias)
mapmodes_alias = [fragmodes_@mapname]
mapmodes = (getalias $mapmodes_alias)
replacedata = (format "%1 %2 %3 %4 %5 %6" (getmode) (getfrags) (getdeaths) (divf (getfrags) (getdeaths)) (getaccuracy) (? (flagcheck) (getflags) "X"))
newdata = (concatword "[ " $replacedata " ]")
replaceloop_switch = 1
case $fragrec_replace 0 [ //Do the thing if the map doesn't exist in records
fragdata_list = (concat $fragdata_list $mapname)
alias $mapdata_alias $newdata
alias $mapmodes_alias (getmode)
fragrec_add = 1
] 1 [ //Do the thing if the map exists, but the mode does not.
alias $mapmodes_alias (concat $mapmodes (getmode))
alias $mapdata_alias (concat $mapdata $newdata)
fragrec_add = 1
] 2 [ //Do the thing if the new record's frags are higher than the old ones
loopwhile i (listlen $mapdata) [= $replaceloop_switch 1] [
tempdata = (at $mapdata $i)
if (&& (= (at $tempdata 0) (getmode)) (> (getfrags) (at $tempdata 1))) [
alias $mapdata_alias (strreplace $mapdata $tempdata $replacedata)
replaceloop_switch = 0
fragrec_add = 0
]
]
]
case $fragrec_add 0 [
echo (format "^f6[ RECORD ] ^f7You have beaten your previous record for ^f5%1 %2^f7!" (at $fragmodenames (getmode)) $mapname)
] 1 [
echo (format "^f6[ RECORD ] ^f7A new record was added for ^f5%1 %2^f7!" (at $fragmodenames (getmode)) $mapname)
]
]
fragdata_search = [ //Checks to see if a given map exists within the records
if (inlist $fragdata_list $arg1) [
fragdata_viewmap = $arg1
showgui "Records"
] [
echo (format "^f6[ RECORD ] ^f7You do not have any records for ^f5%1^f7!" $arg1)
showgui "Frag Records"
]
]
fragdata_clearmap = [ //Removes a map and all of its records
tempname = [fragdata_@arg1]
alias $tempname ""
tempname = [fragmodes_@arg1]
alias $tempname ""
listname = (format " %1" $arg1)
fragdata_list = (listsplice $fragdata_list "" (indexof $fragdata_list $arg1) 1)
echo (format "^f6[ RECORD ] ^f7All records were erased for ^f5%1^f7!" $arg1)
]
fragdata_clearmode = [ //Removes a record for a mode within a map
mapdataname = [fragdata_@arg1]
mapdata = (getalias $mapdataname)
mapmodename = [fragmodes_@arg1]
mapmodes = (getalias $mapmodename)
looplist curdata $mapdata [
if (= (at $curdata 0) $arg2) [
wholedata = (format "[%1]" $curdata)
mapdata = (strreplace $mapdata $wholedata "")
alias $mapdataname $mapdata
mapmodes = (listsplice $mapmodes "" (indexof $mapmodes $arg2) 1)
alias $mapmodename $mapmodes
echo (format "^f6[ RECORD ] ^f7Record removed for ^f5%1 %2^f7!" (at $fragmodenames $arg2) $arg1)
]
]
]
fragrec_clearall = [ //Clears all records
looplist tempdata $fragdata_list [
tempalias = [fragmodes_@tempdata]
alias $tempalias ""
tempalias = [fragdata_@tempdata]
alias $tempalias ""
]
fragdata_list = ""
echo "^f6[ RECORD ] ^f7All records have been ^f3removed^f7!"
showgui "Frag Records"
]
//COMMAND - showrecord MAPNAME MODENAME
getrecord = [
if (=s $arg1 "") [ //If mapname is not specified, pull the data for the current map and mode
if (inlist $fragdata_list $mapname) [
//Grab the map's data
tempalias = [fragdata_@mapname]
mapdata = (getalias $tempalias)
tempalias = [fragmodes_@mapname]
mapmodes = (getalias $tempalias)
//Check if the mode exists, if not error
if (inlist $mapmodes (getmode)) [
modenumber = (at $mapmodes (indexof $mapmodes (getmode)))
recorddata = (at $mapdata (indexof $mapmodes (getmode)))
//Check for CTF mode
if (inlist $fragctfmodes (at $fragmodenames $modenumber)) [
recordstatement = (format "^f6[ RECORD ] ^f5%1 %2^f7: Frags: ^f3%3 ^f1| ^f7Deaths: ^f3%4 ^f1| ^f7KpD: ^f3%5 ^f1| ^f7Accuracy: ^f3%6 ^f1| ^f7Flags: ^f3%7" (at $fragmodenames $modenumber) $mapname (at $recorddata 1) (at $recorddata 2) (at $recorddata 3) (at $recorddata 4) (at $recorddata 5))
] [
recordstatement = (format "^f6[ RECORD ] ^f5%1 %2^f7: Frags: ^f3%3 ^f1| ^f7Deaths: ^f3%4 ^f1| ^f7KpD: ^f3%5 ^f1| ^f7Accuracy: ^f3%6" (at $fragmodenames $modenumber) $mapname (at $recorddata 1) (at $recorddata 2) (at $recorddata 3) (at $recorddata 4))
]
echo $recordstatement
] [
echo "^f3[ ERROR ] ^f7There are no records for this mode."
]
] [
echo (format "^f3[ ERROR ] ^f7There are no records for ^f5%1" $mapname)
]
] [ //Pull the data for the specified map and mode. Error if mode not specified
if (&& (!=s $arg2 "") (inlist $modenames $arg2)) [
//Check if the map exists
if (inlist $fragdata_list $arg1) [
//Pull the map's modes, then check if the mode exists in the records
tempalias = [fragmodes_@arg1]
mapmodes = (getalias $tempalias)
if (inlist $mapmodes (indexof $modenames $arg2)) [
//Pull the data for the map and mode; present the results
modeindex = (indexof $mapmodes (getmode))
modedata = (at $mapmodes $modeindex)
modename = (at $fragmodenames (indexof $modenames $arg2))
tempalias = [fragdata_@arg1]
recorddata = (at (getalias $tempalias) $modeindex)
//Check if it's a flag mode and present the proper results
if (inlist $fragctfmodes $modename) [
recordstatement = (format "^f6[ RECORD ] ^f5%1 %2^f7: Frags: ^f3%3 ^f1| ^f7Deaths: ^f3%4 ^f1| ^f7KpD: ^f3%5 ^f1| ^f7Accuracy: ^f3%6 ^f1| ^f7Flags: ^f3%7" (at $fragmodenames $modenumber) $mapname (at $recorddata 1) (at $recorddata 2) (at $recorddata 3) (at $recorddata 4) (at $recorddata 5))
] [
recordstatement = (format "^f6[ RECORD ] ^f5%1 %2^f7: Frags: ^f3%3 ^f1| ^f7Deaths: ^f3%4 ^f1| ^f7KpD: ^f3%5 ^f1| ^f7Accuracy: ^f3%6" (at $fragmodenames $modenumber) $mapname (at $recorddata 1) (at $recorddata 2) (at $recorddata 3) (at $recorddata 4))
]
echo $recordstatement
] [
echo "^f3[ ERROR ] ^f7There is no record for that mode!"
]
] [
echo (format "^f3[ ERROR ] ^f7No record exists for ^f5%1" $arg1)
]
] [
echo "^f3[ ERROR ] ^f7Invalid mode specified!"
]
]
]
//COMMAND - setrecord - Toggles the record keeping on or off
setrecord = [
fragrec_switch = (? ($fragrec_switch) 0 1)
echo (format "^f6[ RECORD ] ^f7Record keeping has been turned %1^f7!" (? ($fragrec_switch) "^f0on" "^f3off"))
]
//EVENT - Intermission
//Note: Must have fragrec_intermission in /intermission. /intermission = [fragrec_intermission]
fragrec_intermission = [
if (&& (! (isspectator (getclientnum))) $fragrec_switch) [
if (! (inlist $fragdata_list $mapname)) [ //If map doesn't have a record
fragrec_addrecord 0
] [ //If the map has a record, check if this mode is already recorded
if (!= (getmode) 1) [ //Only record if it is not coop
mapmodes_alias = [fragmodes_@mapname]
mapmodes = (getalias $mapmodes_alias)
if (! (inlist $mapmodes (getmode))) [ //If the mode has not been recorded
fragrec_addrecord 1
] [ //If the mode exists, compare the frag counts and replace the record if necessary
fragrec_addrecord 2
]
]
]
]
]
//Useful minor functions and aliases
fragmodenames = [FFA Coop Teamplay Insta "Insta Team" Effic "Effic Team" Tactics "Tactics Team" Capture "Regen Capture" CTF iCTF Protect iProtect Hold iHold eCTF eProtect eHold Collect iCollect eCollect]
fragctfmodes = [CTF iCTF Protect iProtect Hold iHold eCTF eProtect eHold]
inlist = [ result (!= (indexof $arg1 $arg2) -1) ]
flagcheck = [
if (inlist $fragctfmodes (at $fragmodenames (getmode))) [
result 1
] [
result 0
]
]