diff --git a/config/scripts.cfg b/config/scripts.cfg index 5104f439..814a8cf9 100644 --- a/config/scripts.cfg +++ b/config/scripts.cfg @@ -10,8 +10,6 @@ const MODEALIASES [map lms vip sendmap] // Note: The editent command can NOT define rotation/yaw inside the command! // However, the current yaw of the player will define the rotation/yaw when // using the command! -const return [ result $arg1 ] - const editent [ if $editing [ if (strcmp (getenttype) mapmodel) [ saycommand "/entset" (getenttype) (getentattr 1) (getentattr 2) (getentattr 3) ] [ @@ -68,9 +66,8 @@ const gibsgore [ // "fullscreenscript" command: // This command allows swapping of fullscreen mode to be bound to a key. const fullscreenscript [ if $fullscreen [ fullscreen 0 ] [ fullscreen 1 ] ] - const editmapmsg [ saycommand (concat "/mapmsg" (addpunct (getmapmsg))) ] - +const return [ result $arg1 ] const run [ exec (concatword config/ $arg1 .cfg) ] // Auto-completions @@ -135,10 +132,26 @@ const lms [ surv $arg1 $arg2 ] const vip [ htf $arg1 $arg2 ] // Helper aliases for (c) - easy color insertion. (e.g. echo (red)Hello (blue)world! (white)My fov today is: (orange) $fov) -loop k 10 [ const (at [green blue yellow red gray white dbrown dred purple orange] $k) (format "if (= $arg1 -1) [ result %1 ] [ result %2 ]" $k (addpunct (concat c $k) 2)) ] +loop k 10 [ const (at [green blue yellow red gray white dbrown dred purple orange] $k) (format [if (= $arg1 -1) [ result %1 ] [ result %2 ]] $k (addpunct (concat c $k) 2)) ] // echo (blue -1) - returns 1 // echo (purple -1) - returns 8 +const add2alias [ + if (strcmp [] (getalias $arg1)) [ $arg1 = $arg2 ] [ + $arg1 = (concat (concatword (getalias $arg1) [;]) $arg2) + ] +] +const addOnLoadOnce [ add2alias mapstartonce $arg1 ] +const addOnLoadAlways [ add2alias mapstartalways $arg1 ] +const addOnQuit [ add2alias onQuit $arg1 ] +const check2init [ if (! (checkalias $arg1)) [ $arg1 = $arg2 ] ] // only overwrites an alias if it doesn't exist +const check2initlist [ loop cll (listlen $arg1) [ check2init (at $arg1 $cll) $arg2 ] ] // check2inits multiple aliases +const forceinit [ loop fil (listlen $arg1) [ (at $arg1 $fil) = $arg2 ] ] // forcibly overwrites multiple aliases +const checkinit [ if (! (checkalias $arg1)) [ $arg1 = "" ]; if (> $numargs 1) [ if (! (strstr (getalias $arg1) $arg2)) [ add2alias $arg1 $arg2 ] ] ] // ensures the initialization of an alias, optionally ensures the alias contains string $arg2 +const aliasinit [ loop ail (listlen $arg1) [ checkinit (at $arg1 $ail) $arg2 ] ] // checkinits multiple aliases +const add2list [ if (strcmp [] (getalias $arg1)) [ $arg1 = $arg2 ] [ $arg1 = (concat (getalias $arg1) $arg2) ] ] // works exactly like concat, use as a shortcut to: alias = (concat $alias "some string") +const add2bind [ if (! (strstr (keybind $arg1) $arg2)) [ bind $arg1 (format [%1; %2] (keybind $arg1) $arg2) ] ] // works exactly like add2alias except for used with keybinds + // Weapon switching/action utilities. const hasprimary [ if (= (curweapon) (currentprimary)) [ result 1 ] [ result 0 ] ] const primary [ weapon (currentprimary) ] @@ -156,18 +169,19 @@ const checkmag [ if (|| (magcontent $arg1) (magreserve $arg1)) [ result 1 ] [ re const checkrange [ if (&& (>=f $arg1 $arg2) (<=f $arg1 $arg3)) [ result 1 ] [ result 0 ] ] const quicknadethrow_old [ - if (> (magcontent 8) 0) [ - if (!= (curweapon) 7) [ grenades ] + if (> (magcontent $GRENADES) 0) [ + if (!= (curweapon) $CPISTOL) grenades attack ] - onrelease [ sleep 1 [ if (= (curweapon) $CPISTOL) [ weapon (prevweapon) ] ] ] + // onrelease [ sleep 1 [ if (= (curweapon) $CPISTOL) [ weapon (prevweapon) ] ] ] ] -loop i 10 [ (concatword altaction_ $i) = quicknadethrow ] // Quick nade throw is default -// altaction_0 = [ if (checkmag (currentprimary)) [ primary ] [ if (|| (checkmag 1) (checkmag 9)) [ secondary ] [ if (checkmag 8) [ grenades ] ] ] ] // Knife // uncomment to switch to primary/secondary/grenades with MOUSE2 depending on ammo content for each. -altaction_5 = [ setscope 1; onrelease [ setscope 0 ] ] // Sniper -// altaction_7 = [ setburst 1; onrelease [ setburst 0 ] ] // Combat pistol // TODO uncomment when this becomes a priority/testing, for now lets save an unused alias - Bukz -// altaction_8 = [ attack ] // Grenade // with this comment, you throw the nade and the nade is unselected : Brahma +loop i $NUM_WEAPONS [ (concatword altaction_ $i) = quicknadethrow ] // Quick nade throw is default +// Use format to define altaction_N aliases from now on, makes for less edits in the future if weapon IDs change. - Bukz +// (format altaction_%1 $KNIFE) = [ if (checkmag (currentprimary)) primary [ if (|| (checkmag $PISTOL) (checkmag $AKIMBO)) secondary [ if (checkmag $GRENADES) grenades ] ] ] // Knife // uncomment to switch to primary/secondary/grenades with MOUSE2 depending on ammo content for each. +(format altaction_%1 $SNIPER) = [ setscope 1; onrelease [ setscope 0 ] ] // Sniper +// (format altaction_%1 $CPISTOL) = [ setburst 1; onrelease [ setburst 0 ] ] // Combat pistol // TODO uncomment when this becomes a priority/testing, for now lets save an unused alias - Bukz +// (format altaction_%1 $GRENADES) = attack // Grenade // with this comment, you throw the nade and the nade is unselected : Brahma oldsens = $sensitivity @@ -228,9 +242,9 @@ const toggleshowmap [ showmap 1; onrelease [ showmap 0 ] ] // arg7 "server description" // TODO: interpret a#3,4,5,6 [ft:any1:2010apr04] -sbdns = []; sbport = []; sbdesc = []; sbmsg = []; sbpwd = [] +forceinit [sbdns sbport sbdesc sbmsg sbpwd] [] const sbconnect [ - sbdns = $arg1; sbport = $arg2; sbdesc = $arg7; sbpwd = []; sbmsg = [] + sbdns = $arg1; sbport = $arg2; sbdesc = $arg7; forceinit [sbpwd sbmsg] [] if (>= $arg5 1) [ sbmsg = [This server is set to private.]; showmenu [password required] ] [ @@ -247,36 +261,19 @@ const sbconnect [ ] // answer last PM -const quickanswer [ if (>= $lastpm 0) [ saycommand (concat "/pm" $lastpm []) ] [ saycommand (concat "/pm" []) ] ] +const quickanswer [ if (>= $lastpm 0) [ saycommand (concat /pm $lastpm []) ] [ saycommand (concat /pm []) ] ] // For those players who use IRC too much... const join [ connect $arg1 $arg2 $arg3 ] -const add2alias [ - if (strcmp "" (getalias $arg1)) [ $arg1 = $arg2 ] [ - $arg1 = (concat (concatword (getalias $arg1) ";") $arg2) - ] -] -const addOnLoadOnce [ add2alias mapstartonce $arg1 ] -const addOnLoadAlways [ add2alias mapstartalways $arg1 ] -const addOnQuit [ add2alias onQuit $arg1 ] -const check2init [ if (! (checkalias $arg1)) [ $arg1 = $arg2 ] ] // only overwrites an alias if it doesn't exist -const check2initlist [ loop cll (listlen $arg1) [ check2init (at $arg1 $cll) $arg2 ] ] // check2inits multiple aliases -const forceinit [ loop fil (listlen $arg1) [ (at $arg1 $fil) = $arg2 ] ] // forcibly overwrites multiple aliases -const checkinit [ if (! (checkalias $arg1)) [ $arg1 = "" ]; if (> $numargs 1) [ if (! (strstr (getalias $arg1) $arg2)) [ add2alias $arg1 $arg2 ] ] ] // ensures the initialization of an alias, optionally ensures the alias contains string $arg2 -const aliasinit [ loop ail (listlen $arg1) [ checkinit (at $arg1 $ail) $arg2 ] ] // checkinits multiple aliases -const add2list [ if (strcmp [] (getalias $arg1)) [ $arg1 = $arg2 ] [ $arg1 = (concat (getalias $arg1) $arg2) ] ] // works exactly like concat, use as a shortcut to: alias = (concat $alias "some string") -const add2bind [ if (! (strstr (keybind $arg1) $arg2)) [ bind $arg1 (format [%1; %2] (keybind $arg1) $arg2) ] ] // works exactly like add2alias except for used with keybinds -const rndmap [ result (at $defaultmaps (rnd (listlen $defaultmaps))) ] +const rndmap [ result (at $defaultmaps (rnd (listlen $defaultmaps))) ] const rrnd [ + (rnd (- $arg2 $arg1)) $arg1 ] - const ++ [ if (checkalias $arg1) [ += $arg1 1 ] ] const -- [ if (checkalias $arg1) [ -= $arg1 1 ] ] const ++f [ if (checkalias $arg1) [ +=f $arg1 1 ] ] const --f [ if (checkalias $arg1) [ -=f $arg1 1 ] ] - const listaverage [ if (listlen $arg1) [ tmp_sum = 0; loop gsl (listlen $arg1) [ +=f tmp_sum (at $arg1 $gsl) ]; result (divf $tmp_sum (listlen $arg1)) ] ] -cp_entbuf = NULL; cp_entstr = NULL +forceinit [cp_entbuf cp_entstr] NULL const get_ent_attrs [ cp_entbuf = (getenttype); loop gea $ENT_NUM_ATTRS [ add2list cp_entbuf (getentattr $gea) ] ] const copyent [ @@ -366,8 +363,8 @@ const cs_sets [clockdisplay crosshairsize hidecompass hideconsole hidectfhud hid const cs_newsets [0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0] const disablehud [ storesets $cs_sets tmp_old_sets; loop csl (listlen $cs_sets) [ (at $cs_sets $csl) (at $cs_newsets $csl) ]; if $editing [ seteditshow 0 ] ] -const enablehud [ if (checkalias tmp_old_sets) [ loop ros (listlen $cs_sets) [ (at $cs_sets $ros) (at $tmp_old_sets $ros) ]; if $editing [ seteditshow ] ] ] -const cleanshot [ disablehud; sleep 200 [ screenshot ]; sleep 500 [ enablehud ] ] +const enablehud [ if (checkalias tmp_old_sets) [ loop ros (listlen $cs_sets) [ (at $cs_sets $ros) (at $tmp_old_sets $ros) ]; if $editing seteditshow ] ] +const cleanshot [ disablehud; sleep 200 screenshot; sleep 500 enablehud ] // highestcn - Returns the highest valid client number available. const highestcn [