Author Topic: Admin List  (Read 2602 times)

Is there a way to list all the admins and super admins in your server when you say
/listAdmins even if the admins are offline?

What you need to do is access $Pref::Server::AutoAdmin and $Pref::Server::AutoSuperAdmin. With these two, assuming they're separated with a comma and space, is do this (NOTE: This will only list the IDs; names are not stored. In order to get the names, you either have to store them to a file or pull from RTB's ID lookup system.):
Code: [Select]
package ListAdmins
{
function serverCmdlistAdmins(%client)
{
        if(%client.isHost)
        {
        %client.chatmessage("Admins:");
        %tokens = $Pref::Server::AutoAdmin;
        while(%tokens !$= "")
        {
                %tokens = nextToken(%tokens,"token",", ");
                %client.chatmessage(%token);
        }

        %client.chatmessage("Super Admins:");
        %tokens = $Pref::Server::AutoSuperAdmin;
        while(%tokens !$= "")
        {
                %tokens = nextToken(%tokens,"token",", ");
                %client.chatmessage(%token);
        }
        }
}
};
activatePackage(ListAdmins);

This is untested because I'm on my iPod.

Yeah. BluetoothBoy kinda nailed it, but what's cool is that you can do a check like this to get their name:

if(isObject(%bg = ("brickGroup_" @ %token)))
    %name = %bg.name;


note: if they haven't joined the server, their name has not been recorded and this will fail.

secondnote: there's no point in putting BluetoothBoy's code in a package. This is bad form, even though you can "technically" disable the function with deactivatePackage().
« Last Edit: September 14, 2013, 03:56:43 PM by $trinick »

that brickgroup trick is nifty

that brickgroup trick is nifty
I agree.

secondnote: there's no point in putting BluetoothBoy's code in a package. This is bad form, even though you can "technically" disable the function with deactivatePackage().
Yeah, I actually have no idea why I thought that needed to be in a package.

What does while mean? as in while(%tokens !$="")

What does while mean? as in while(%tokens !$="")

while(condition is true)
{
     run code
}
« Last Edit: September 14, 2013, 05:09:03 PM by elm »

What does while mean? as in while(%tokens !$="")
More in-depth explanation:

While the variable %token does not equal "", or an empty string, run the code inside of the while loop. %token itself is the string pulled from the server prefs containing the admin info.

While the variable %token does not equal ""
Better way to put it: while %token has a value.

Btw, I'm not trying to pick you off here, just trying to help the OP.

Better way to put it: while %token has a value.

Btw, I'm not trying to pick you off here, just trying to help the OP.
True, this is a better way of putting it. I really have no idea of the OP's experience in coding.

Yeah. BluetoothBoy kinda nailed it, but what's cool is that you can do a check like this to get their name:

if(isObject(%bg = ("brickGroup_" @ %token)))
    %name = %bg.name;


note: if they haven't joined the server, their name has not been recorded and this will fail.

secondnote: there's no point in putting BluetoothBoy's code in a package. This is bad form, even though you can "technically" disable the function with deactivatePackage().
if there is no user it will return BL_ID: <blidHere>
i used this method in my destructo wand+

if there is no user it will return BL_ID: <blidHere>
i used this method in my destructo wand+
Well, that's if bricks have been loaded under their name. If they haven't joined the server and they don't own any bricks, then the brickgroup will not exist and thus referencing .name will return "".

Better way to put it: while %token has a value.

Btw, I'm not trying to pick you off here, just trying to help the OP.

"" is a value - it's just an empty value. Not having a value is null.

MessageBox.Show("Is nothing (\"\") a value (not null)?\r\n" + (null == "" ? "Nope. It's not." : "Yes. It is."));
A similar exercise:
MessageBox.Show("Are you screwed?\r\n" + (2 + 2 == 4 ? "Nope, two plus two makes four." : "BIG BROTHER IS WATCHING, GET OUT OF THERE NOW!"));

"" is a value - it's just an empty value. Not having a value is null.

MessageBox.Show("Is nothing (\"\") a value (not null)?\r\n" + (null == "" ? "Nope. It's not." : "Yes. It is."));
A similar exercise:
MessageBox.Show("Are you screwed?\r\n" + (2 + 2 == 4 ? "Nope, two plus two makes four." : "BIG BROTHER IS WATCHING, GET OUT OF THERE NOW!"));

"" is null in Torque. Do you see a value between the two quotes? "null" is not a keyword in Torque, it's represented by "". $undefinedVariable == "".

"" is null in Torque. Do you see a value between the two quotes? "null" is not a keyword in Torque, it's represented by "". $undefinedVariable == "".

Yes, but then there's this oddity..

If you set $con::warnUndefinedVariables to true and then type echo($test);, it will display $test as being undefined. However, if you type echo($test = "");, there will be no "undefined" warning. Even if you set the variable to "", the variable still exists and takes up memory until you call deleteVariables("$test");, so it's not exactly null.