Author Topic: Detecting the newest non admin player on the server  (Read 432 times)

Basically what I am trying to do is detect the newest non admin player and if there is no non admin players it will report that back. I have a method but I want to see if there is a better one.

Here is an example of the method I am currently using. It isn't the real thing it just shows what I'm doing.
Code: [Select]
bleh

The code works fine but all I am looking to know is that is there a better method for doing this?
« Last Edit: July 10, 2012, 11:00:08 AM by Danny Boy »

Why the hell do you use such cryptic function names?



Code: [Select]
function newestNonAdminClient()
{
     for ( %i = clientGroup.getCount() - 1 ; %i >= 0 ; %i-- )
     {
          %cl = clientGroup.getObject( %i );
         
          if ( !%cl.isAdmin && !%cl.isSuperAdmin )
          {
               return %cl;
          }
     }
     
     return -1;
}

Why the hell do you use such cryptic function names?
Like I said it is just an example. I typed random letters for the function because I am too lazy to go upstairs to my laptop to get the actual code.

Anyway thanks for the help

You don't need all those spaces, either.
If you're trying to save on filespace or get confused by too many curlybrackets:
function newestNonAdminClient() {
     for (%i = clientGroup.getCount() - 1;%i >= 0;%i--) {
          %cl = clientGroup.getObject(%i);
          if (!%cl.isAdmin && !%cl.isSuperAdmin)
               return %cl;
     }
     return -1;
}

(Yes, this is perfectly valid. If an if structure only runs one line you don't need to put a {} after it.)

If you're doing reserved slots, then this is the completely wrong approach.