Scripts
Bear in mind there are servers with high maxclients that even the server can't handle.
Thanks given by:
(17 Jan 11, 03:21AM)Gibstick Wrote: Wolf: write me a script that looks at the scoreboard

I just don't get it. Why would I do this if I can press TAB and take a 1 second glance at the scoreboard.
Thanks given by:
It's meant to be used in bigger and better scripts, it's just a tool. Similar to how curweapon returns the numerical value of the weapon you're holding, or how curserver returns the IP and port of the server you're on, this returns the # of players on the server. I'm similarly dumbfounded with why this hasn't already been implemented in cubescript. xD

If someone needed to loop a body of code the exact number of times as there are players on the server, it'd be a simple:
loop blah (curplayers) []
...which wasn't (at least as easily) possible before.

The "whoisall" (and others like it) script will be more efficient now, because it won't always be looping 21 times, it'll loop only exactly the number of times it has to:
loop d (curplayers) [whois $d]
Thanks given by:
Oh, ok. I get it now.
Thanks given by:
Nice. Will it be added to tools.cfg?
Thanks given by:
I showed it to V-Man a while back and I'm pretty sure he was thinking about adding it, let's throw stuff at him until he does.

* Bukz throws a desk chair @ V-Man :P
Thanks given by:
* eftertanke throws a foot rest @ V-Man :P
Thanks given by:
Months of scripting, and I still don't see anyone use code such as
if $connected []

instead of
if (= $connected 1)

Why Bukz? Is it habit?
Thanks given by:
Maybe it was something else causing them, but I was getting missing ) errors without it. :P
Thanks given by:
loop k (curplayers) [kick $k FIRE_IN_THE_HOLE]
Thanks given by:
* V-Man throws flower petals at V-Man :P

All right youse guys.
With a bunch of help from Wifey, I was able to add bot-player-counting capabilities to the script. I'm including the modified/expanded version of "curplayers" in this update of tools.cfg. :D
Thanks given by:
Script Request: (I tried to script it but i allways get an epic fail). A countdown time when you (or teammatet) drop the flag in ctf mode (30 seconds?). The countdown must stop if someone gets the flag again.
Help: countdown must be diplayed when in log there's a "you dropped the flag" or "xxxxx dropped the enemy flag.
It will be cool if from 30 to 20 displayed in green, from 20 to 10 orange and from 10 to 0 red.
Thanks given by:
/Bind 9 [paused 0 onrelease; Me UN-PAUSED] Bind 0 [paused 1 onrelease; Me PAUSE]

This is a pause and un pause script i wrote for offline bot games and i use it myself. it pauses the game when you press 0 and unpauses when you hit 9.

i know its nooby but i find it handy for when your playing bots and somthing in real life pops up, like food and toilet breaks. lol
Thanks given by:
Save one of your keys and use:
/bind 0 [if $paused [paused 0; echo Unpaused] [paused 1; echo Paused]]
...instead. :)

And yet another way to make playing custom maps with bots easier:
// Custom bot maps menu item script by DES|Bukz
// Requires tools.cfg - http://forum.cubers.net/thread-1776.html
alias custommaps [ac_MAP1 ac_MAP2 ac_MAP3 ac_MAP4 ac_MAP5]

add2menu botmaps [
    menuitem [] -1
    menuitem [Custom Bot Maps] [showmenu "Custom Bot Maps"]
]

newmenu "Custom Bot Maps"
genbotmaps $custommaps

This script requires V-Man's tools.cfg. You have to edit alias "custommaps" to add your own list of map names before using the script, for example:
alias custommaps [ac_edifice ac_fracht ac_egypt]

The new menu will show up in the existing "botmaps" menu:

[Image: mapsp.jpg]

Thanks given by:
@VallDiGna:
Flag Countdown
:D Just for you!
Thanks given by:
Thanks a lot V-Man!!
I'll change it a little cuz i'm interested just when my team drops :D
Strangly i had to paste all tools.cfg on autoexec.cfg because if a execute tools.cfg didn't work. Anyway sometimes countdown goes under 0 with negative numbers. I'm gonna test it more, thanks again
Edit: You forget this cases:
if_conline_has "returned the enemy flag" [alias flag_is_down 0] []
if_conline_has "you lost the flag" [alias flag_is_down 1] []
Thanks given by:
(19 Jan 11, 11:06AM)VallDiGna Wrote: ...
Strangly i had to paste all tools.cfg on autoexec.cfg because if a execute tools.cfg didn't work.
Did you put "execute tools.cfg" or "exec tools.cfg"? The latter is correct and execute won't work.

Thanks given by:
(17 Jan 11, 01:01PM)Gibstick Wrote:
loop k (curplayers) [kick $k FIRE_IN_THE_HOLE]

Nnno!
loop k (curplayers) [kick $k "FIRE IN THE HOLE"]
Hehe. I always hate that.
Thanks given by:
Gibstick , yes i put it, but i think the problem was with the 'exec config/countdownflag.cfg' dunno why
Thanks given by:
You should put scripts other than tools.cfg in a folder (for example, "scripts") and execute that folder at the end of autoexec.cfg:
exec config\tools.cfg
execdir scripts
This will ensure that tools.cfg is executed first, and any scripts that depend on it are not neglected.
Thanks given by:
(19 Jan 11, 01:18PM)eftertanke Wrote: Nnno!
loop k (curplayers) [kick $k "FIRE IN THE HOLE"]
Hehe. I always hate that.

I was just mocking one of Bukz scripts x)
Thanks given by:
To supplement Bukz' "curplayers" script:
// (validcnumlist) returns a list of valid client numbers
alias validcnumlist [
validcnums = []
if $connected [
  loop n 21 [if (= (at (pstat_score $n) 4) -1) [] [add2list validcnums $n]]
  result $validcnums
] [
  loop n 41 [if (strcmp (findpn $n) "") [] [add2list validcnums $n]]
  result $validcnums
]]
and:
alias teamcount [
tmp_count = 0
loop p (curplayers) [
if (= (at (pstat_score (if $connected [at (validcnumlist) $p] [$p])) 4) $arg1) [+= tmp_count 1] []
]
result $tmp_count
]
and:
// kickbots (cn) (cn) (cn) (cn) (cn) (cn) ... -- kick multiple bots by client number
alias kickbots [
loop o $numargs [
  kickbot (findpn (getalias (concatword "arg" (+ $o 1))))
]
]
These will be included in the next release of tools.cfg, which I'll retain for later.



@VallDiGna:
Haha, how'd those escape my notice?!
I've updated the flag countdown script to cover the missing cases you mentioned. Thanks!
Thanks given by:
Auto-Ignore script - Automatically ignore clients with wildcard (e.g. clantag) support.
Password Generator script - Server admin tool to easily generate random, secure, admin and deban passwords.

...and some more junk... :P

// curhighestcn - Returns the highest client number in the current game. - by DES|Bukz
alias curhighestcn [
    hcn = 0
    if $connected [
        loop q 21 [
            if (strcmp (findpn $q) "") [] [
                hcn = $q
            ]
        ]
    ] [
        loop q 41 [
            if (strcmp (findpn $q) "") [] [
                hcn = $q
            ]
        ]
    ]
    result $hcn
]

// curenemies - Returns the current number of enemies the user may have ATM. - by DES|Bukz
// Requires tools.cfg & the "curhighestcn" script.
alias curenemies [
    tmpenemies = 0
    if (|| (= $connected 1) (= (curmodeattr bot) 1)) [
        if (= (curmodeattr team) 0) [ // FFA
            tmpenemies = (- (curplayers) 1)
            result $tmpenemies
        ] [ // Team
            if (= (curteam) 0) [ // CLA
                loop a (+ (curhighestcn) 1) [
                    if (= (at (pstat_score $a) 4) 1) [+= tmpenemies 1] []
                ]
                result $tmpenemies
            ] [ // RVSF
                loop b (+ (curhighestcn) 1) [
                    if (= (at (pstat_score $b) 4) 0) [+= tmpenemies 1] []
                ]
                result $tmpenemies
            ]
        ]
    ] [result -1]
]

// curdeaths - Returns the number of deaths a client has in the current game. - by DES|Bukz
// Returns -1 if an invalid client number was given.
alias curdeaths [
    tmpdeaths = 0
    if (strcmp (findpn $arg1) "") [result -1] [
        tmpdeaths = (at (pstat_score $arg1) 2)
        result $tmpdeaths
    ]
]

// curfrags - Returns the number of frags a client has in the current game. - by DES|Bukz
// Returns -1 if an invalid client number was given.
alias curfrags [
  tmpfrags = 0
  if (strcmp (findpn $arg1) "") [result -1] [
    tmpfrags = (at (pstat_score $arg1) 1)
    result $tmpfrags
  ]
]

// curratio - Returns the given clients ratio in a floating point decimal by DES|Bukz
// Returns -1 if an invalid client number was given.
alias curratio [
  if (strcmp (findpn $arg1) "") [result -1] [
    alias tmpfrags (at (pstat_score $arg1) 1)
    alias tmpdeaths (at (pstat_score $arg1) 2)
    if (< $tmpdeaths 2) [
      alias tmpratio (concatword $tmpfrags .0)
    ] [
      alias tmpratio (divf $tmpfrags $tmpdeaths)
    ]
    result $tmpratio
  ]
]

// curscore - Returns the current score (in points) that a given client has ATM by DES|Bukz
alias curscore [
  if (strcmp (findpn $arg1) "") [] [
    tmpscore = (at (pstat_score $arg1) 3)
    result $tmpscore
  ]
]

docsection [Miscellaneous];

docident [curenemies] [Returns the current number of enemies you have in the game.];
docexample [/echo (curenemies)] [Output: If you currently have 4 enemies, outputs 4.];

docident [curhighestcn] [Returns the highest valid client number found in the current game.];
docexample [/echo (curhighestcn)] [Output: If the highest cn is currently 19, outputs 19.];

docident [curdeaths] [Returns the current number of deaths a client currently has.];
docargument [C] [A valid client number.];
docexample [/echo (curdeaths 5)] [Output: If cn 5 currently has 14 deaths, outputs 14.];
docremark [Returns -1 if an invalid client number was given.];

docident [curfrags] [Returns the current number of frags a client currently has.];
docargument [C] [A valid client number.];
docexample [/echo (curfrags 5)] [Output: If cn 5 currently has 25 frags, outputs 25.];
docremark [Returns -1 if an invalid client number was given.];

docident [curratio] [Returns the current ratio (frags / deaths) of a client.];
docargument [C] [A valid client number.];
docexample [/echo (curratio 5)] [Output: If cn 5 currently has 8 frags and 4 deaths, outputs 2.0.];
docremark [Returns -1 if an invalid client number was given.];

docident [curscore] [Returns the current score of a client.];
docargument [C] [A valid client number.];
docexample [/echo (curscore 5)] [Output: If cn 5 currently has 125 points, outputs 125.];
docremark [Returns -1 if an invalid client number was given or if not currently connected to a server.];

Summary:

curhighestcn - Returns the highest valid cn in the current game.
curenemies - Returns your current number of enemies.
curdeaths - Returns the given client's current number of deaths.
curfrags - Returns the given client's current number of frags.
curratio - Returns the given client's current ratio (frags / deaths).
curscore - Returns the given client's current score (in points).

Lots of new toys for you cubescripters out there! HF! More to come, keep checking this post.
Thanks given by:
:D
My turn!
Delete elements in a list in a given alias:
alias delfromlistend [
delalias tmp_list
loop df (- (listlen $arg1) $arg2) [
add2list tmp_list (at $arg1 $df)
]
result (getalias tmp_list)
] // echo (delfromlistend $testlist 3)

alias delfromliststart [
delalias tmp_list
loop df (- (listlen $arg1) $arg2) [
add2list tmp_list (at $arg1 (+ $df $arg2))
]
result (getalias tmp_list)
] // echo (delfromliststart $testlist 3)

alias delfromlist [
delalias tmp_list
loop df (listlen $arg1) [
if (strcmp (at $arg1 $df) $arg2) [] [
  add2list tmp_list (at $arg1 $df)
  ]
]
result (getalias tmp_list)
] // echo (delfromlist $testlist k)

alias delfromlist_mult [
alias tmp_list1 $arg1
loop mu (listlen $arg2) [alias tmp_list1 (delfromlist $tmp_list1 (at $arg2 $mu))]
result (getalias tmp_list1)
] // echo (delfromlist_mult $testlist [a c e g i k])
Summary:
delfromlistend - delete a given number of list elements from the end of a given list
delfromliststart - delete a given number of list elements from the beginning of a given list
delfromlist - delete a given element from a given list
delfromlist_mult - delete multiple arbitrary elements from a given list

Example, for those who remember this:
/alias testlist [I do not like CubeScript]
/echo $testlist
I do not like CubeScript
/echo (delfromlist_mult $testlist [do not])
I like CubeScript
Thanks given by:
(22 Jan 11, 04:18PM)DES|V-Man Wrote:
bind CAPSLOCK [sound 50; onrelease [sound 52]]

This is a script |DES|V-man kindly wrote for me to stop me pressing the capslock key while in game.
it makes the vote noise, so if i hear it and there is no vote, i will know i'v pressed the capslock key
Thanks given by:
Lack of credit FTW!
Thanks given by:
Win V-Man, simply...win.

delfromlist is EXACTLY what I need to allow people to remove specific entires from their auto-ignore list when using the auto-ignore script.

You couldn't of released it just a few hours before eh?! :P

We'll see another update to tools.cfg soon me hopes? :D:D

Edit:

VenteX, sorry for the confusion, but what are you referring to/who are you directing that at?
Thanks given by:
I've updated the delfromlist scripts to behave more broadly, like other command-like aliases. They now take a list and output a result, so you can do more with it like echo, save a new alias, etc. But you don't change the original alias (if the list is in an alias), unless you direct it to. :D
And I'll update tools.cfg when I feel more decisive about whether the world is ready for a certain script.

VenteX is disappointed that he didn't get credit for the idea to have the vote sound in CAPSLOCK. All I did was put the numbers in.
Thanks given by:
can some one make me a teabag scipt, please use t :)
Thanks given by:
Sorry, crouch is a keybind only command. If you type /crouch in-game it won't do anything.

Edit: although if you are crouched and type /crouch, you will stand up.
Thanks given by: