CubeScript examples for reference.xml
#1
** THREAD RULES **

a) Any posts that aren't suggesting an example are to be deleted by mods or myself. Sorry, but this thread isn't for discussion.
b) Anyone obviously trolling this thread can happily enjoy a 48 hour ban (handed out on a discretionary basis by any mod).

Right, rules out of the way. I'm looking for some neat examples for the CubeScript reference. The rules for making these scripts are as follows:

a) No buggy/dodgy scripts.
b) No profanity, personalisation or fame usage allowed.
c) Scripts must be VERY simple in their creation (for example: references to the "alias" command must not use the equals sign; simple every-day commands should be used). This way, the scripts can be much easily interpreted by complete newbies (which is the intention of these examples).

The examples are to replace the terrible ones I've created on http://assault.cubers.net/docs/reference.html and the intention of these examples is to teach newbies how these parts of CubeScript work: "" [ ] () $command $arg1 ;

The best scripts will replace the current grassy scripts in the reference, which gets packaged with the next AC.

Use the following format to post your scripts:

[list]
[*][b]"" example:[/b]
[*][b]; example:[/b]
[*][b]$command example:[/b]
[*][b]$arg1 example:[/b]
[*][b]() example:[/b]
[*][b][] example:[/b]
[/list]
Thanks given by:
#2
Here'es an example of cubescript
alias "Truth" [name Truth; say Truth; name nickname]

or

alias "lies" [name Lies; say Lies; name nickname]

Also, here's one called "Hacker ban (CN)
Takes screenshot, gets ip, and bans player (thanks [SODA]___ME___)
alias "hb" [ hackercn = $arg1; vote 2; whois $arg1; sleep 500 [ban ( hackercn ) Hacking; sleep 500 [ screenshot ] ] ]
Thanks given by:
#3
Thanks Jg. That will sure come in handy to admins.

Here's mine.
[cubescript]
music "pingpong/03-pp-kamikadze.ogg" "90000" [echo Music finished.]
[/cubescript]
How it works:
Thanks given by:
#4
RandumKiwi, that list you made is great, it is the only thing I used to create my scripts. now if someone could PM me on how to make the "Code boxes".......
Sorry but I didn't understand the format of your example, perhaps an example with actual code and also how you want it formatted to be 100% clear, or I need more than 2.5 hours of sleep.

I seem to recall that bind differently (mostly for admins)

alias hb [ hackercn = $arg1; setadmin 1 *password*; vote 2; whois $arg1; sleep 500 [ban ( hackercn ) Hacking; sleep 500 [ screenshot ] ] ]


You need to change *password*

To make it work properly you need admin to cancel any current vote and make sure the vote passes. Without setadmin you must wait till no other vote is pending (or claim admin first).

to ban lets say cn4 just type /hb 4

the /hb calls the script, $arg1 is the cn number of the player you are wanting to ban (4 in this example).
I had to add hackercn = $arg1 because for some reason it would not pass the value properly to the ban statement. (think I know why but a proper explanation would be nice)

setadmin is needed to get full IP and make sure vote passes.

vote 2 is the same as pressing F2, if there is a vote pending and you have admin then pending vote fails.

whois $arg1 displays the IP of the cn you picked (4 in this example).

the next part is a problem for most and it has to do with nested sleep commands
sleep 500 [ban ( hackercn ) Hacking; sleep 500 [ screenshot ] ]
The first part sleep 500[----] gives the server time (500 milliseconds) to accept you as admin before doing anything inside of [ ]

next we have ban ( hackercn ) Hacking, this is the ban vote for the cn you picked (4 in this example) with the reason as Hacking. For some reason I am not sure of, when I used $arg1 here it would always be zero.

the last part sleep 500 [ screenshot ] gives the server time to ban the player then takes a screenshot.
Thanks given by:
#5
well i removed the setadmin part lol
Thanks given by:
#6
BTW, ME, It would also be nice for admins if the script could also get the demo at the end of the map.
Thanks given by:
#7
Will this sort of thing do?
[cubescript]
fizzbuzz = [ loop i 101 [
if (&& (= (mod $i 3) 0) (= (mod $i 5) 0)) [
echo "FizzBuzz" ] [
if (= (mod $i 3) 0) [
echo "Fizz" ] [
if (= (mod $i 5) 0) [
echo "Buzz" ] [
echo $i ]
]
]
]
]
[/cubescript]
Looking at this now, I have no idea why I did it this way.
Ah, yeah, this is echo, not printf. Newlines 'n' shiz.
Thanks given by:
#8
Ok, here is same bind but with demo download you will need to remain on server till game is over to get demo.
alias hb [ hackercn = $arg1; setadmin 1 *password*; vote 2; whois $arg1; sleep 500 [ban ( hackercn ) Hacking; sleep 500 [ screenshot; addOnLoadOnce [ sleep 3000 [ echo "##### Demo downloading #####"; getdemo ] ] ] ]
Thanks given by:
#9
Seems nobody understands what I was looking for. Thread closed.
Thanks given by: