// DuelScript, v1.6 // (C) 2011 David "srbs" Forrest & Chaos, ZLIB license // somerandombystander (at) gmail (dot) com // http://www.opensource.org/licenses/zlib-license.php //Key Bind: bind L [ showgui duel ] //Defaults: createine = [ if (=s (getalias $arg1) "") [ $arg1 = $arg2 ] ] createine ifw "Winning by" createine ifl "Losing by" createine ift "Tied!" createine delay 3 createine _ds_opts 30 createine _stats_gh 126 createine _stats_dgh 0 createine scw 0 createine scl 3 createine sct 1 createine scf 1 createine scc 7 createine sst 1 createine ssn 3 createine ssc 7 go = 0 color = [ result (concatword "^f" $arg1) ] //GUI: newgui duel [ guititle "^f2DuelScript Manager" guibar guilist [ guilist [ guitext (concatword (color $scw) "Text if winning: ") 0 guitext (concatword (color $scl) "Text if losing: ") 0 guitext (concatword (color $sct) "Text if tied: ") 0 ] guilist [ guifield ifw 20 [ echo "^f6Text if winning set to:" (concatword (color $scw) $ifw) ] guifield ifl 20 [ echo "^f7Text if losing set to:" (concatword (color $scl) $ifl) ] guifield ift 20 [ echo "^f6Text if tied set to:" (concatword (color $sct) $ift) ] ] ] guibar guilist [ guibitfield "Enable Auto-Start" _ds_opts 16 if (! (& $_ds_opts 16)) [ guibar guistayopen [ guibutton (concatword "Script is " (? $go "^f7On/^f~^f4Off" "^f4On^f~^f7/Off")) [ go = (! $go) ] ] ] ] guitab "Options" guilist [ guitext "^f2Continuous Echo: " 0 guibitfield "Enable" _ds_opts 1 ] if (& $_ds_opts 1) [ guilist [ guitext "Interval (seconds): " 0 guifield delay 2 [ echo (concatword "^f7Interval between echos set to^f~ ^f1" $delay "^f~ ^f7seconds.^f~") ] ] ] guibar guilist [ guitext "^f2Echo on Keystroke: " 0 newbinds = (searchbinds "echo (getduelstatus)") guikeyfield newbinds -8 [ looplist i (searchbinds "echo (getduelstatus)") [ bind $i "" ] looplist i $newbinds [ bind $i "echo (getduelstatus)" ] ] ] guibar guilist [ guitext "^f2Duel Gamehud: " 0 guibitfield "Enable" _ds_opts 2 if (& $_ds_opts 2) [ guibar guibutton "Configure" [ showgui dgconfig ] ] ] if (! (& $_ds_opts 16)) [ guibar guilist [ guitext "^f2Toggle On/Off: " 0 newerbinds = (searchbinds "go = (! $go)") guikeyfield newerbinds -8 [ looplist i (searchbinds "go = (! $go)") [ bind $i "" ] looplist i $newerbinds [ bind $i "go = (! $go)" ] ] ] ] guitab "Stats" guitext "^f2Normal Gamehud Options: " 0 guibitfield "Show Time Left" _stats_gh 64 guibitfield "Show Name" _stats_gh 1 guibitfield "Show Frags" _stats_gh 2 guibitfield "Show Deaths" _stats_gh 4 guibitfield "Show Acc" _stats_gh 8 guibitfield "Show KpD" _stats_gh 16 guibitfield "Show Flags" _stats_gh 32 guibar guibutton "Color Configuration" [ showgui scolors ] guitab "About" guitext "Created and Developed by ^f6Chaos^f~ and ^f6srbs^f~." 0 guibar guialign 0 [ guitextbox "Questions or Comments? Visit us on IRC at ^f6#sauer-scripts^f~ on gamesurge.net, or post a comment online at ^f6http://quadropolis.us/node/2979^f~." 30 ] ] "Duel" newgui dgconfig [ guitext "^f2Duel Gamehud Options: " 0 guibitfield "Show Time Left" _ds_opts 8 guibitfield "Show Difference" _ds_opts 4 guibitfield "Show Name" _stats_dgh 1 guibitfield "Show Frags" _stats_dgh 2 guibitfield "Show Deaths" _stats_dgh 4 guibitfield "Show Acc" _stats_dgh 8 guibitfield "Show KpD" _stats_dgh 16 guibitfield "Show Flags" _stats_dgh 32 guibar guibutton "Color Configuration" [ showgui dscolors ] ] "Duelhud" colrad = [ guiradio "Green" $arg1 0 guiradio "Blue" $arg1 1 guiradio "Yellow" $arg1 2 guiradio "Red" $arg1 3 guiradio "Grey" $arg1 4 guiradio "Purple" $arg1 5 guiradio "Orange" $arg1 6 guiradio "White" $arg1 7 ] newgui dscolors [ guitext (concatword (color $scw) "Winning Text:") 0 colrad scw guitab "Losing" guitext (concatword (color $scl) "Losing Text:") 0 colrad scl guitab "Tied" guitext (concatword (color $sct) "Tied Text:") 0 colrad sct if (& $_ds_opts 4) [ guitab "Difference" guitext (concatword (color $scf) "Frag Difference:") 0 colrad scf ] if (& $_ds_opts 8) [ guitab "Clock" guitext (concatword (color $scc) "Clock:") 0 colrad scc ] ] "Winning" newgui scolors [ guitext (concatword (color $sst) "Text:") 0 colrad sst guitab "Numbers" guitext (concatword (color $ssn) "Numbers:") 0 colrad ssn guitab "Clock" guitext (concatword (color $ssc) "Clock:") 0 colrad ssc ] "Text" //Helper Functions: getstats = [ result (concatword (? (& $arg1 64) (concatword (color $ssc) (timeleft))) (? (& $arg1 1) (format " %2Name: %3%1" (getname) (color $sst) (color $ssn))) (? (& $arg1 2) (format " %2Frags: %3%1" (getfrags) (color $sst) (color $ssn))) (? (& $arg1 4) (format " %2Deaths: %3%1" (getdeaths) (color $sst) (color $ssn))) (? (& $arg1 8) (format " %2Acc: %3%1%%" (getaccuracy) (color $sst) (color $ssn))) (? (& $arg1 16) (format " %2KpD: %3%1" (substr (divf (getfrags) (max (getdeaths) 1)) 0 4) (color $sst) (color $ssn))) (? (&& (& $arg1 32) (> (getmode) 10)) (format " %2Flags: %3%1" (getflags) (color $sst) (color $ssn)))) ] getduelstatus = [ if $go [ if (> (getfrags) (getdeaths)) [ result (concatword (color $scw) $ifw " " (color $scf) (? (& $_ds_opts 4) (- (getfrags) (getdeaths)))) ] [ if (= (getfrags) (getdeaths)) [ result (concatword (color $sct) $ift) ] [ result (concatword (color $scl) $ifl " " (color $scf) (? (& $_ds_opts 4) (- (getdeaths) (getfrags)))) ] ] ] [ echostats ] ] echostats = [ result (? (& $_stats_gh 64) (substr (getstats (- $_stats_gh 64)) 1) (substr (getstats ($_stats_gh)) 1)) ] addzero = [ if (> $arg1 9) [ result $arg1 ] [ result (concatword "0" $arg1) ] ] timeleft = [ result (format "%1:%2" (div (timeremaining) 60) (addzero (mod (timeremaining) 60))) ] //Gamehud: gamehud = [ if (&& $go (& $_ds_opts 2)) [ result (concatword (? (& $_ds_opts 8) (concatword (color $scc) (timeleft))) (concat (? (& $_ds_opts 8)) (getduelstatus) (getstats $_stats_dgh))) ] [ result (getstats $_stats_gh) ] ] //Forever Loops: duelloop = [ if (&& $go (& $_ds_opts 1)) [ echo (getduelstatus) ] ; sleep (* $delay 1000) [ duelloop ] ] duelloop isduel = [ if (& $_ds_opts 16) [ if (>= (getmode) 0) [ count = 0 looplist i (listclients 1) [ if (! (isspectator $i)) [ count = (+ $count 1) ] ] go = (= $count 2) ] [ go = 0 ] ] sleep 5000 [ isduel ] ] isduel