KILL_ALL_SCRIPTS

Something else for Armagetron? Goody!
Post Reply
User avatar
Galaxip
Average Program
Posts: 57
Joined: Wed Aug 24, 2016 10:49 pm

KILL_ALL_SCRIPTS

Post by Galaxip »

i've been working a lot with scripts lately and often have multiple scripts running at the same time

I needed a way to kill all running scripts in one shot to save time while developing stuff so ive added KILL_ALL_SCRIPTS command to rConsoleCout.cpp

Its basically a clone of LIST_SCRIPTS but instead of displaying the script names it kills them

I know is a messy way to do it but I just wanted something quick that would work, Im sure someone could do better :D

heres the code if anyone needs it, just paste it in. i put it after the other script functions just before the #endif /* KRAWALL_SERVER */

Code: Select all

// ********************************
// *** Galaxip KILL_ALL_SCRIPTS ***
// ********************************

void sr_killAllScriptsCommand( std::istream & s )
{
	int numberScripts = 0;
	for( int i = sr_inputStreams.Len()-1; i >= 0; --i )
	{
	rScriptStream * script = dynamic_cast< rScriptStream * >( (rStream*)sr_inputStreams[i] );
	if( script )
		{
    sr_KillScript( script->GetName() );
		numberScripts++;
		}
	}
	if (!numberScripts)
		con << "No scripts are currently running.\n";
}

static tConfItemFunc sr_killAllScriptsFunc( "KILL_ALL_SCRIPTS", sr_killAllScriptsCommand );
static tAccessLevelSetter sr_killAllScriptsALS( sr_killAllScriptsFunc, tAccessLevel_Owner );
Image Image Image

User avatar
aP|Nelg
Match Winner
Posts: 563
Joined: Wed Oct 22, 2014 10:22 pm
Contact:

Re: KILL_ALL_SCRIPTS

Post by aP|Nelg »

I believe this already existed in sty+ct+ap, though in typical Armagetron fashion probably not documented anywhere :mrgreen:
EDIT: Yes, as of 2014 in revision 1010: https://bazaar.launchpad.net/~armagetro ... leCout.cpp

User avatar
Galaxip
Average Program
Posts: 57
Joined: Wed Aug 24, 2016 10:49 pm

Re: KILL_ALL_SCRIPTS

Post by Galaxip »

ah nice, it wasnt available in the sty+ct build im using

i just had a look, much neater than mine, it closes the script directly instead of passing the script name to killscript

also my version displays the script names while it killing them (too much spam :P)

I like this, going to change mine to match

BTW i think line 758 is wrong and should read

static tAccessLevelSetter sr_killAllScriptALS( sr_killAllScriptsConf, tAccessLevel_Owner );
Image Image Image

User avatar
aP|Nelg
Match Winner
Posts: 563
Joined: Wed Oct 22, 2014 10:22 pm
Contact:

Re: KILL_ALL_SCRIPTS

Post by aP|Nelg »

Galaxip wrote:
Tue May 26, 2020 4:43 pm
BTW i think line 758 is wrong and should read

static tAccessLevelSetter sr_killAllScriptALS( sr_killAllScriptsConf, tAccessLevel_Owner );
It looks to have changed later. I, for some reason, decided to hunt down (well, bzr blame) the revision it was added.
This is the current source: https://bazaar.launchpad.net/~armagetro ... t.cpp#L739

I probably shouldn't admit to this, but BBCode links keep throwing me off. I keep wanting to try [a href=], like in html, instead of just [url=$link]. I guess I'm one of those web developer noobs now... next I'll be trying to use Javascript in a certain C++ application :P

Post Reply