Xonotic Forums
[SOLVED] How does the defer command work? - Printable Version

+- Xonotic Forums (https://forums.xonotic.org)
+-- Forum: Support (https://forums.xonotic.org/forumdisplay.php?fid=3)
+--- Forum: Xonotic - Help & Troubleshooting (https://forums.xonotic.org/forumdisplay.php?fid=4)
+--- Thread: [SOLVED] How does the defer command work? (/showthread.php?tid=6159)



How does the defer command work? - nightspawn9911 - 04-26-2016

At the end of a multiplayer death match, "user wins" is written to the console signifying that the round has ended. I've been experimenting with autoexec.cfg and I'd like to start using the defer cmd.

I want to wait for the line I mentioned above and, when it is detected, fire a series of subcmds. I have three in mind; they are teamstatus, something that will print all the lines on the console to a private server of mine, and quit (in that order).

Is it possible to complete such a task and if so could you give me an idea of how it can be implemented?


RE: How does the defer command work? - Mario - 04-26-2016

defer is a bit of a strangely functioning command;
The entire command line is executed at the same time, so multiple defers will trigger at the same time.
The easiest way to work around this is to increase the time for each consecutive defer, e.g. alias sv_hook_gameend "teamstatus; defer 1 \"condump mylog.txt\"; defer 2 quit"


RE: How does the defer command work? - nightspawn9911 - 07-08-2016

Hi mario, sorry it's been a really long time since I asked this question but I've tried to implement what you said to no avail... I can't find many resources that include examples of how this code works so it's hard for me to learn therefore I can't spot the error myself. Could you explain for instance how defer would work with only just 1 defer? say I wanted to just quit at game end? If you have better things to do than teach me how to code I'd understand haha but maybe you have a good resource though that you could include so I could learn on my own? Thanks


RE: How does the defer command work? - Mario - 07-08-2016

If you just want to close the server when the match ends, then an alternative method could be to quit when the match ends via quit_and_redirect. Setting it to "self" may work best.
Options like that can be found via CACS: http://xonotic.org/tools/cacs

As for how to use the console for scripting, nowhere explains every detail, but some tips are available:
http://forums.xonotic.org/showthread.php?tid=2987


RE: How does the defer command work? - nightspawn9911 - 07-18-2016

This is what ended up working for me...

alias cl_hook_gameend "teamstatus; defer 1 \"condump mylog.txt\"; defer 2 quit"

I just had to change the hook_gameend part. Couldn't have done it without you, thanks a bunch!