scripts.cfg 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. // CubeScript placed in this file is automatically executed on each startup.
  2. persistidents 0
  3. const MODES [tdm coop dm surv ts ctf pf btdm bdm lss osok tosok bosok htf tktf ktf tpf tlss bpf blss bts btosok]
  4. const MODEALIASES [map lms vip sendmap]
  5. // "editent" command:
  6. // This command collects all the attributes of the nearest entity, and then
  7. // prompts that into a handy command that allows you to edit that entities
  8. // attributes easily.
  9. // Note: The editent command can NOT define rotation/yaw inside the command!
  10. // However, the current yaw of the player will define the rotation/yaw when
  11. // using the command!
  12. const editent [
  13. if $editing [
  14. if (strcmp (getenttype) mapmodel) [ saycommand "/entset" (getenttype) (getentattr 1) (getentattr 2) (getentattr 3) ] [
  15. if (> (findlist [light sound clip plclip] (getenttype)) -1) [
  16. saycommand "/entset" (getenttype) (getentattr 0) (getentattr 1) (getentattr 2) (getentattr 3)
  17. ] [
  18. saycommand "/entset" (getenttype) (getentattr ((> (findlist [playerstart ctf-flag] (getenttype)) -1)))
  19. ]
  20. ]
  21. ]
  22. ]
  23. // "convertclips" command:
  24. // This command automatically changes the a "clip" to a "plclip" entity or vice-versa.
  25. const convertclips [
  26. if $editing [
  27. if (strcmp (getenttype) clip) [ entset plclip (getentattr 0) (getentattr 1) (getentattr 2) (getentattr 3) ] [
  28. if (strcmp (getenttype) plclip) [ entset clip (getentattr 0) (getentattr 1) (getentattr 2) (getentattr 3) ] [
  29. echo No changes made. This entity isn't a clip or a plclip.; echo Try using the /closestenttype command to find a specific entity.
  30. ]
  31. ]
  32. ]
  33. ]
  34. // "gibsgore" command:
  35. // This command controls gib Speed/Number/TTL all in one variable.
  36. const gibsgore [
  37. if (= $arg1 4) [ // Unrealistic
  38. gib 1; gibspeed 40; gibnum 100; gibttl 2500 // Turn TTL down to minimise lag...
  39. __gibsgore = 4
  40. ] [
  41. if (= $arg1 3) [ // Messy
  42. gib 1; gibspeed 15; gibnum 65; gibttl 10000
  43. __gibsgore = 3
  44. ] [
  45. if (= $arg1 2) [ // Good
  46. gib 1; gibspeed 30; gibnum 75; gibttl 5000
  47. __gibsgore = 2
  48. ] [
  49. if (= $arg1 1) [ // Normal
  50. gib 1; gibspeed 30; gibnum 6; gibttl 5000
  51. __gibsgore = 1
  52. ] [
  53. if (= $arg1 0) [ // Off
  54. gib 0
  55. __gibsgore = 0
  56. ]
  57. ]
  58. ]
  59. ]
  60. ]
  61. ]
  62. // "fullscreenscript" command:
  63. // This command allows swapping of fullscreen mode to be bound to a key.
  64. const fullscreenscript [ fullscreen (! $fullscreen) ]
  65. const editmapmsg [ saycommand (concat "/mapmsg" (addpunct (getmapmsg))) ]
  66. const return [ result $arg1 ]
  67. const run [ exec (concatword config/ $arg1 .cfg) ]
  68. // Auto-completions
  69. const mapcomplete [complete $arg1 "packages/maps/official packages/maps" cgz]
  70. loop i (listlen (concat $MODES $MODEALIASES)) [ mapcomplete (at (concat $MODES $MODEALIASES) $i) ]
  71. complete demo demos dmo
  72. const entcomplete [ listcomplete $arg1 [light playerstart pistol ammobox grenades health armour akimbo mapmodel ladder ctf-flag sound clip plclip helmet] ]
  73. entcomplete newent; entcomplete clearents; entcomplete closestenttype
  74. // TODO:FIXME change all occurrence of SPECT(ator) to GHOST
  75. listcomplete team [CLA RVSF CLA-SPECT RVSF-SPECT SPECTATOR]
  76. // Game mode descriptions...
  77. gamemodedesc 0 [Team Deathmatch: Shred the enemy team to pieces!]
  78. gamemodedesc 1 [Co-operative edit: Edit maps with others online!]
  79. gamemodedesc 2 [Deathmatch: Destroy anything that moves! Everyone for themselves!]
  80. gamemodedesc 3 [Survivor: Conserve you precious life, destroy the enemy's. Once all your enemies are dead, the round restarts.]
  81. gamemodedesc 4 [Team Survivor: Conserve you precious life, destroy the enemy team. Once all your enemies are dead, the round restarts.]
  82. gamemodedesc 5 [Capture the Flag: Steal the enemy teams flag and bring it to your home base. Don't let your own flag get stolen.]
  83. gamemodedesc 6 [Pistol Frenzy: Can you make your enemy eat lead with the most simplest of weapons?]
  84. gamemodedesc 7 [Bot Team Deathmatch: Find the enemy A.I. and destroy them!]
  85. gamemodedesc 8 [Bot Deathmatch: It's every man and A.I. for themselves! Dismantle those bots! ]
  86. gamemodedesc 9 [Last Swiss Standing: Knive and bomb the enemy!]
  87. gamemodedesc 10 [One Shot, One Kill: You and your opponents start with 1hp, a sniper rifle, a knife and no pickups. Survive with your sniper, or humiliate with your swiss steel.]
  88. gamemodedesc 11 [Team One Shot, One Kill: Your team starts with 1hp, a sniper rifle, a knife and no pickups. Survive with your sniper, or humiliate with your swiss steel.]
  89. gamemodedesc 12 [Bot One-Shot, One Kill: You and the bots start with 1hp, a sniper rifle, a knife and no pickups. Survive with your sniper, or humiliate with your swiss steel.]
  90. gamemodedesc 13 [Hunt the Flag: Find the enemy flag, frag the flag bearer and collect the flag to score. Protect your own team flag. If the flag bearer collects the enemy flag, they gain a 1 point bonus.]
  91. gamemodedesc 14 [Team Keep the Flag: There is only one flag. Get the flag and keep it. You score one point every 15 seconds. If your teammate has the flag, protect him. If the flag bearer collects the enemy flag, they gain a 1 point bonus.]
  92. gamemodedesc 15 [Keep the Flag: Get the flag and keep it. You score one point every 15 seconds. Everybody else will want to destroy you!]
  93. gamemodedesc 16 [Team Pistol Frenzy: Can you make your enemy team eat lead with the most simplest of weapons?]
  94. gamemodedesc 17 [Team Last Swiss Standing: Knive and bomb the enemy team!]
  95. gamemodedesc 18 [Bot Pistol Frenzy: Can you make the enemy A.I. eat lead with the most simplest of weapons?]
  96. gamemodedesc 19 [Bot Last Swiss Standing: Knive and bomb the enemy A.I!]
  97. const resetbinds [ run resetbinds; echo (c 3)All binds have been reset to default values! ]
  98. const changeteam [ if (< (player1 team) 4) [ team (at [RVSF CLA RVSF-SPECT CLA-SPECT] (player1 team)) ] ]
  99. const WEAPONS [KNIFE PISTOL CARBINE SHOTGUN SMG SNIPER AR CPISTOL GRENADES AKIMBO]
  100. const NUM_WEAPONS (listlen $WEAPONS)
  101. const NUM_MODES (listlen $MODES)
  102. const PUNCTUATION "QUOTES BRACKETS PARENTHESIS _$_ QUOTE PERCENT"
  103. const MAX_CLIENTS 16
  104. const MAX_BOT_MATCH_LENGTH 60
  105. const MAX_ARGS 24
  106. const ENT_NUM_ATTRS 4
  107. loop g (listlen $PUNCTUATION) [ const (at $PUNCTUATION $g) $g ]
  108. // echo (addpunct "hello world" $PARENTHESIS) - output: (hello world)
  109. // echo (addpunct "hello world" $BRACKETS) - output: [hello world]
  110. loop d $NUM_WEAPONS [ const (at $WEAPONS $d) $d ]
  111. loop r $NUM_MODES [ const (at $MODES $r) (format [votemap %1 %2 %3] $r "$arg1" "$arg2") ]
  112. const modenum [ result (findlist $MODES $arg1) ]
  113. // Mode/map-setting aliases.
  114. const votemap [ mode $arg1; map $arg2 $arg3 ]
  115. const lms [ surv $arg1 $arg2 ]
  116. const vip [ htf $arg1 $arg2 ]
  117. // Helper aliases for (c) - easy color insertion. (e.g. echo (red)Hello (blue)world! (white)My fov today is: (orange) $fov)
  118. 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)) ]
  119. // echo (blue -1) - returns 1
  120. // echo (purple -1) - returns 8
  121. const add2alias [
  122. if (strcmp [] (getalias $arg1)) [ $arg1 = $arg2 ] [
  123. $arg1 = (concat (concatword (getalias $arg1) [;]) $arg2)
  124. ]
  125. ]
  126. const addOnLoadOnce [ add2alias mapstartonce $arg1 ]
  127. const addOnLoadAlways [ add2alias mapstartalways $arg1 ]
  128. const addOnQuit [ add2alias onQuit $arg1 ]
  129. const check2init [ if (! (checkalias $arg1)) [ $arg1 = $arg2 ] ] // only overwrites an alias if it doesn't exist
  130. const check2initlist [ loop cll (listlen $arg1) [ check2init (at $arg1 $cll) $arg2 ] ] // check2inits multiple aliases
  131. const forceinit [ loop fil (listlen $arg1) [ (at $arg1 $fil) = $arg2 ] ] // forcibly overwrites multiple aliases
  132. 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
  133. const aliasinit [ loop ail (listlen $arg1) [ checkinit (at $arg1 $ail) $arg2 ] ] // checkinits multiple aliases
  134. 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")
  135. const add2bind [ if (! (strstr (keybind $arg1) $arg2)) [ bind $arg1 (format [%1; %2] (keybind $arg1) $arg2) ] ] // works exactly like add2alias except for used with keybinds
  136. // Weapon switching/action utilities.
  137. const hasprimary [ result (= (curweapon) (currentprimary)) ]
  138. const primary [ weapon (currentprimary) ]
  139. const ptoggle [ if (hasprimary) $arg1 primary ] // Toggle between primary/specified weapon
  140. const secondary [ weapon $PISTOL ]
  141. const sndtoggle [ ptoggle secondary ]
  142. const melee [ weapon $KNIFE ]
  143. const knftoggle [ ptoggle melee ]
  144. const grenades [ weapon $GRENADES ]
  145. const gndtoggle [ ptoggle grenades ]
  146. const altaction [ (concatword altaction_ (curweapon)) ]
  147. const checkmag [ result (|| (magcontent $arg1) (magreserve $arg1)) ]
  148. const checkrange [ result (&& (>=f $arg1 $arg2) (<=f $arg1 $arg3)) ]
  149. const quicknadethrow_old [
  150. if (> (magcontent $GRENADES) 0) [
  151. if (!= (curweapon) $CPISTOL) grenades
  152. attack
  153. ]
  154. // onrelease [ sleep 1 [ if (= (curweapon) $CPISTOL) [ weapon (prevweapon) ] ] ]
  155. ]
  156. loop i $NUM_WEAPONS [ (concatword altaction_ $i) = quicknadethrow ] // Quick nade throw is default
  157. // Use format to define altaction_N aliases from now on, makes for less edits in the future if weapon IDs change. - Bukz
  158. // (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.
  159. (format altaction_%1 $SNIPER) = [ setscope 1; onrelease [ setscope 0 ] ] // Sniper
  160. // (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
  161. // (format altaction_%1 $GRENADES) = attack // Grenade // with this comment, you throw the nade and the nade is unselected : Brahma
  162. oldsens = $sensitivity
  163. const zoom [
  164. if (= $arg1 1) [
  165. if (! (=f $sensitivity (scopesens))) [
  166. oldsens = $sensitivity
  167. // avoid error if using 0.001 as sensitivity
  168. newsens = (scopesens)
  169. if (> (*f 1 1000) $newsens) [ if (< 1000 $newsens) [ sensitivity (scopesens) ] ]
  170. setscope 1
  171. ]
  172. ] [ sensitivity $oldsens; setscope 0 ]
  173. ]
  174. delta_game_0 = [ if (= $arg1 1) [ shiftweapon 1 ] [ shiftweapon -1 ] ] // Cycle through weapons
  175. delta_game_1 = [ if (checkrange (+ $gamma $arg1) 30 300) [ gamma (+ $gamma $arg1) ] ] // Tweak gamma
  176. delta_game_2 = [ if (checkrange (+ $fov $arg1) 75 120) [ fov (+ $fov $arg1) ] ] // Tweak fov
  177. delta_spect_0 = [ changefollowplayer $arg1 ]
  178. // Map editing using the mousewheel...
  179. modifier = 0
  180. const domodifier [ modifier = $arg1; onrelease [ modifier = 0 ] ]
  181. const universaldelta [
  182. if $editing [ s = edit ] [
  183. if (player1 alive) [ s = game ] [ s = spect ]
  184. ]
  185. (concatword delta _ $s _ $modifier)
  186. ]
  187. // To utilize the below, you will need to bind "domodifier X"
  188. // (replace X with the number of the delta_edit) to a key. To
  189. // use them, simply hold the key that the "domodifier" is bound
  190. // to and then scroll backwards/forwards while looking at the
  191. // floor/ceiling.
  192. delta_edit_0 = [ editheight $flrceil $arg1 ] // Move cubes...
  193. delta_edit_1 = [ if $flrceil [ vdelta $arg1 ] [ vdelta (- 0 $arg1) ] ] // Change heightfielding...
  194. delta_edit_2 = [ edittex $flrceil $arg1 ] // Change floor/ceiling textures...
  195. delta_edit_3 = [ edittex (+ $flrceil 1) $arg1 ] // Change wall/upper-wall textures...
  196. delta_edit_4 = [ equalize $flrceil ] // Equalize floor/ceiling...
  197. delta_edit_5 = [ entproperty 0 $arg1 ] // Changes the first value on entities...
  198. delta_edit_6 = [ entproperty $editaxis $arg1 ] // Move map entity...
  199. delta_edit_7 = [ entproperty 1 $arg1 ] // Changes the second value on entities...
  200. delta_edit_8 = [ entproperty 2 $arg1 ] // Changes the third value on entities...
  201. delta_edit_9 = [ entproperty 3 $arg1 ] // Changes the fourth value on entities...
  202. delta_edit_10 = [ if (checkrange (+f $flyspeed (divf $arg1 4)) 1 5) [ flyspeed (+f $flyspeed (divf $arg1 4)); echo $flyspeed ] ] // Tweak flyspeed
  203. delta_edit_11 = [ if (> $arg1 0) [ expandselection 1 ] [ shrinkselection 1 ] ] // Expand/shrink the current selection
  204. // HUD toggles
  205. const toggleshowmap [ showmap 1; onrelease [ showmap 0 ] ]
  206. // convenient connecting from the serverbrowser
  207. // sbconnect arg list:
  208. // arg1 IP, arg2 port,
  209. // arg3 1: server full
  210. // arg4 1: password protected
  211. // arg5 1: private mode, 2: match mode
  212. // arg6 1: banned, 2: blacklisted 3: both
  213. // arg7 "server description"
  214. // TODO: interpret a#3,4,5,6 [ft:any1:2010apr04]
  215. forceinit [sbdns sbport sbdesc sbmsg sbpwd] []
  216. const sbconnect [
  217. sbdns = $arg1; sbport = $arg2; sbdesc = $arg7; forceinit [sbpwd sbmsg] []
  218. if (>= $arg5 1) [
  219. sbmsg = [This server is set to private.]; showmenu [password required]
  220. ] [
  221. if (>= $arg6 1) [
  222. sbmsg = [You are banned from this server.]; showmenu [password required]
  223. ] [
  224. if (= $arg4 1) [
  225. sbmsg = [This server is password-protected.]; showmenu [password required]
  226. ] [
  227. echo connecting to $arg7; connect $arg1 $arg2;
  228. ]
  229. ]
  230. ]
  231. ]
  232. // answer last PM
  233. const quickanswer [ if (>= $lastpm 0) [ saycommand (concat /pm $lastpm []) ] [ saycommand (concat /pm []) ] ]
  234. // For those players who use IRC too much...
  235. const join [ connect $arg1 $arg2 $arg3 ]
  236. const reconnect [ if $numargs [ svpass = $arg1 ] [ svpass = [] ]; if $connected [ svdata = (curserver); afterdisconnect [ connect (at $svdata 0) (at $svdata 1) $svpass ] ] ]
  237. const dlmap [ getmap $arg1 [ sleep 2500 (concat map $arg1) ] ]
  238. const rndmap [ result (at $defaultmaps (rnd (listlen $defaultmaps))) ]
  239. const rrnd [ + (rnd (- $arg2 $arg1)) $arg1 ]
  240. const ++ [ if (checkalias $arg1) [ += $arg1 1 ] ]
  241. const -- [ if (checkalias $arg1) [ -= $arg1 1 ] ]
  242. const ++f [ if (checkalias $arg1) [ +=f $arg1 1 ] ]
  243. const --f [ if (checkalias $arg1) [ -=f $arg1 1 ] ]
  244. const listaverage [ if (listlen $arg1) [ tmp_sum = 0; loop gsl (listlen $arg1) [ +=f tmp_sum (at $arg1 $gsl) ]; result (divf $tmp_sum (listlen $arg1)) ] ]
  245. forceinit [cp_entbuf cp_entstr] NULL
  246. const get_ent_attrs [ cp_entbuf = (getenttype); loop gea $ENT_NUM_ATTRS [ add2list cp_entbuf (getentattr $gea) ] ]
  247. const copyent [
  248. if $editing [
  249. get_ent_attrs
  250. cp_entstr = (concatword (orange) "(" (at $cp_entbuf 0) [ ] (at $cp_entbuf 1) [ ] (at $cp_entbuf 2) [ ] (at $cp_entbuf 3) [ ] (at $cp_entbuf 4) ")" (white)) // Output (a string): (enttype param1 param2 param3 param4)
  251. echo (blue)Note: (white)The current closest entity: $cp_entstr - has been copied.
  252. ]
  253. ]
  254. const pasteent [
  255. if $editing [
  256. if (strcmp (at $cp_entbuf 0) mapmodel) [
  257. newent (at $cp_entbuf 0) (at $cp_entbuf 2) (at $cp_entbuf 3) (at $cp_entbuf 4)
  258. ] [
  259. newent (at $cp_entbuf 0) (at $cp_entbuf 1) (at $cp_entbuf 2) (at $cp_entbuf 3) (at $cp_entbuf 4)
  260. ]
  261. echo (blue)Note: (white)The previously copied entity: $cp_entstr - has been pasted.
  262. ]
  263. ]
  264. // genhex - Randomly generates a valid hexadecimal color value (e.g. 0x2FCAF1) - useful for finding fogcolours.
  265. const genhex [
  266. tmp_hex = 0x
  267. loop ghl 6 [
  268. if (rnd 2) [ tmp_hex = (concatword $tmp_hex (rnd 10)) ] [ tmp_hex = (concatword $tmp_hex (at [A B C D E F] (rnd 6))) ]
  269. ]
  270. echo (red)Trying hexadecimal color: (white) $tmp_hex
  271. result $tmp_hex
  272. ]
  273. // genwc - Randomly generates a valid watercolour value (e.g. 2 17 29) - useful for finding watercolours.
  274. const genwc [
  275. if $editing [
  276. tmp_wc = []
  277. loop gwl 3 [ add2list tmp_wc (rrnd 1 256) ]
  278. echo (red)Trying water color: (white) $tmp_wc
  279. watercolour (at $tmp_wc 0) (at $tmp_wc 1) (at $tmp_wc 2)
  280. ]
  281. ]
  282. // gencl - Randomly generates a valid coloured light.
  283. const gencl [
  284. if $editing [
  285. tmp_numargs = $numargs; tmp_cl = []
  286. loop gcl 3 [ add2list tmp_cl (rrnd 1 256) ]
  287. if $tmp_numargs [
  288. if (|| (!= (selx) 0) (!= (sely) 0)) [
  289. echo (red)Trying colored light: (white) $arg1 (at $tmp_cl 0) (at $tmp_cl 1) (at $tmp_cl 2)
  290. newent light $arg1 (at $tmp_cl 0) (at $tmp_cl 1) (at $tmp_cl 2)
  291. ] [ echo (red)Error: (white)If an argument "(radius)" is given for (concatword (blue) gencl (red) ,) you must select a cube first. ]
  292. ] [
  293. if (strcmp (getenttype) light) [
  294. echo (red)Trying colored light: (white) (getentattr 0) (at $tmp_cl 0) (at $tmp_cl 1) (at $tmp_cl 2)
  295. entset light (getentattr 0) (at $tmp_cl 0) (at $tmp_cl 1) (at $tmp_cl 2)
  296. ] [ echo (red)Error: (white)The current closest entity: (orange) (getenttype) (white)is not a light. ]
  297. ]
  298. ] [ echo (red)Error: (white)You must be in edit mode for (blue)gencl (white)to function. ]
  299. ]
  300. // /expandselection 1 // makes the current selection bigger by 1 cube on all sides
  301. const expandselection [
  302. if $numargs [
  303. et1 = $arg1
  304. if (> $et1 0) [
  305. ep1 = (selx)
  306. ep2 = (sely)
  307. eps1 = (selxs)
  308. eps2 = (selys)
  309. select (- $ep1 $et1) (- $ep2 $et1) (+ $eps1 (* $et1 2)) (+ $eps2 (* $et1 2))
  310. result 1
  311. ] [ result 0 ]
  312. ] [ result 0 ]
  313. ]
  314. // /shrinkselection 1 // makes the current selection smaller by 1 cube on all sides
  315. const shrinkselection [
  316. if $numargs [
  317. st1 = $arg1
  318. if (> $st1 0) [
  319. sp1 = (selx)
  320. sp2 = (sely)
  321. sps1 = (selxs)
  322. sps2 = (selys)
  323. sps1 = (- $sps1 (* $st1 2))
  324. sps2 = (- $sps2 (* $st1 2))
  325. if (&& (> $sps1 0) (> $sps2 0)) [
  326. select (+ $sp1 $st1) (+ $sp2 $st1) $sps1 $sps2
  327. result 1
  328. ] [ result 0 ]
  329. ] [ result 0 ]
  330. ] [ result 0 ]
  331. ]
  332. // megabind - Binds a key to many different actions depending on the current game state.
  333. const megabind [ if (> $numargs 5) [ bind $arg1 (format "if (watchingdemo) [ %1 ] [ if (|| $editing (= $gamemode 1)) [ %2 ] [ if $connected [ %3 ] [ if (curmodeattr bot) [ %4 ] [ %5 ] ] ] ]" $arg2 $arg3 $arg4 $arg5 $arg6) ] ]
  334. // storesets - Generates an alias (list) of the current values for the given CVARs.
  335. const storesets [
  336. if (> $numargs 1) [
  337. badargs = 0; $arg2 = []
  338. loop ssl (listlen $arg1) [
  339. if (isIdent (at $arg1 $ssl)) [
  340. add2list $arg2 (getalias (at $arg1 $ssl))
  341. ] [ badargs = 1; break ]
  342. ]
  343. if $badargs [ delalias $arg2; echo (red)Error: (white)Bad "argument(s)" given! ]
  344. ]
  345. ]
  346. // makeshift "?" operator for cubescript
  347. // ex: /? (> $maxroll 0) [voicecom negative D:] [voicecom yes :D]
  348. // /echo I am (? (>= (player1 health) 50) [result healthy] [result weak]) atm
  349. ? = [
  350. if (> $numargs 1) [
  351. if (> $numargs 2) [
  352. if $arg1 $arg2 $arg3
  353. ] [
  354. if $arg1 $arg2
  355. ]
  356. ]
  357. ]
  358. // switch - Takes an integer argument to determine which block of code to execute.
  359. // NOTE: This command can only handle up to 23 "cases" (24 arguments).
  360. switch = [
  361. if (&& (<= $numargs $MAX_ARGS) (checkrange $arg1 0 (- $MAX_ARGS 2))) [
  362. execute (getalias (format arg%1 (+ $arg1 2)))
  363. ]
  364. ]
  365. // cleanshot - Take a "clean" screenshot with no HUD items.
  366. const cs_sets [clockdisplay crosshairsize hidecompass hideconsole hidectfhud hidedamageindicator hidehudequipment hidehudmsgs hideradar hidespecthud hideteam hidevote hudgun specthudgun showstats showtargetname showgrid showclips accuracy]
  367. const cs_newsets [0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0]
  368. 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 ] ]
  369. const enablehud [ if (checkalias tmp_old_sets) [ loop ros (listlen $cs_sets) [ (at $cs_sets $ros) (at $tmp_old_sets $ros) ]; if $editing seteditshow ] ]
  370. const cleanshot [ disablehud; sleep 200 screenshot; sleep 500 enablehud ]
  371. // highestcn - Returns the highest valid client number available.
  372. const highestcn [
  373. hcn = -1
  374. if $connected [ nl = (+ $MAX_CLIENTS 1) ] [ if (curmodeattr bot) [ nl = 100 ] [ nl = 1 ] ]
  375. loop h $nl [
  376. if (isclient $h) [ hcn = $h ]
  377. ]
  378. result $hcn
  379. ]
  380. // convertcase - Zap lists of strings to lower/uppercase.
  381. const convertcase [
  382. if (> $numargs 1) [
  383. tmpCCO = []
  384. loop ccl $numargs [ if (> $ccl 0) [ tmpCCO = (concatword $tmpCCO [ ] (getalias (format arg%1 (+ $ccl 2)))) ] [ tmpCCO = (concatword $tmpCCO $arg2) ] ]
  385. if (!= $arg1 0) [ result (toupper $tmpCCO) ] [ result (tolower $tmpCCO) ]
  386. ]
  387. ]
  388. ingall = 0
  389. const ignoreall [ if $connected [ ingall = 1; loop ia (+ (highestcn) 1) [ ignore $ia ]; echo (blue)NOTE: (white)All clients currently on the server were ignored. ] ]
  390. const unignoreall [ if $connected [ ingall = 0; clearignored -1; echo (blue)NOTE: (white)All clients currently on the server were unignored. ] ]
  391. const ignoreteam [
  392. if (curmodeattr team) [
  393. _arg1 = (toupper $arg1)
  394. if (|| (strcmp $_arg1 CLA) (strcmp $_arg1 RVSF)) [
  395. loop itl (+ (highestcn) 1) [
  396. if (isclient $itl) [
  397. if (= (player $itl team) (at [0 1] (strcmp $_arg1 RVSF))) [ ignore $itl ]
  398. ]
  399. ]
  400. ] [
  401. if (checkrange $_arg1 0 1) [
  402. loop itl (+ (highestcn) 1) [
  403. if (isclient $itl) [
  404. if (= (player $itl team) $_arg1) [ ignore $itl ]
  405. ]
  406. ]
  407. ]
  408. ]
  409. ] ignoreall
  410. ]
  411. const ignoreenemy [ ignoreteam (at [0 1] (! (player1 team))) ]
  412. // Simple claim-admin script for one single-server.
  413. // Fill in the 3 aliases below, and uncomment the below line to activate.
  414. // bind F3 "customclaimadminscript"
  415. _CAS_serverip = "IP ADDRESS"
  416. _CAS_serverpass = "PASSWORD"
  417. _CAS_servername = "SERVER NAME"
  418. const customclaimadminscript [
  419. if (strcmp (curserver 1) $_CAS_serverip) [
  420. if (! (player1 role)) [ setadmin 1 $_CAS_serverpass ] [ setadmin 0 ]
  421. ] [ echo (red)Error: (white)you're not connected to $_CAS_servername servers ]
  422. ]
  423. // Execute other .cfgs/scripts.
  424. run on_quit
  425. run parsestring
  426. run dyngamma
  427. run survival
  428. run autosave
  429. run faq
  430. persistidents 1
  431. execdir scripts