It is currently Thu May 01, 2025 2:34 pm

RUNNING WITH RIFLES Multiplayer

test

Game servers 59 List provided by EpocDotFr | Players online 246


All times are UTC




Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: In game Admin commands
PostPosted: Thu May 23, 2013 5:26 pm 
Offline
User avatar

Joined: Mon Feb 25, 2013 12:24 pm
Posts: 283
OK, had a wee look at the new script files, and configured the admin_settings.php to only have my ingame name in it. I then opened up the basic_command_handler.php to see what commands there were and fired up the game to have go.

I take it all I do is in game press Enter to open the chat command, then type "/test" to get the server to respond with "test yourself" because if that's the case then I cannot get it working at all, lol. I can see the script recognise that my player is saying "/TEST" but that it it, nothing else happens. Does it need to be enabled first or something?

_________________
Image


Top
 Profile  
 
PostPosted: Thu May 23, 2013 5:39 pm 
Offline
Site Admin

Joined: Mon Jun 27, 2011 11:59 am
Posts: 2856
{SAS}DocStone wrote:
OK, had a wee look at the new script files, and configured the admin_settings.php to only have my ingame name in it. I then opened up the basic_command_handler.php to see what commands there were and fired up the game to have go.

I take it all I do is in game press Enter to open the chat command, then type "/test" to get the server to respond with "test yourself" because if that's the case then I cannot get it working at all, lol. I can see the script recognise that my player is saying "/TEST" but that it it, nothing else happens. Does it need to be enabled first or something?


If I'm not mistaken, gamemode_classic.php doesn't create the basic command handler object by default, I may have only added it in Invasion as I needed and tried it there. There should be about two lines you need to copy from gamemode_invasion.php to activate it in classic, include("blahblah/basic_command_handler.php") high up and then add_tracker(new BasicCommandHandler()) a few lines below.


Top
 Profile  
 
PostPosted: Thu May 23, 2013 5:58 pm 
Offline
User avatar

Joined: Mon Feb 25, 2013 12:24 pm
Posts: 283
Tut tut :D

Will have a look and try not to break things, Again. :D

_________________
Image


Top
 Profile  
 
PostPosted: Thu May 23, 2013 6:29 pm 
Offline
User avatar

Joined: Mon Feb 25, 2013 12:24 pm
Posts: 283
Cheers Pasik, got it working without breaking anything, so going to try adding new commands until I do :D

_________________
Image


Top
 Profile  
 
PostPosted: Thu May 23, 2013 6:32 pm 
Offline
Site Admin

Joined: Mon Jun 27, 2011 11:59 am
Posts: 2856
Haha, good luck! :)


Top
 Profile  
 
PostPosted: Thu May 23, 2013 7:14 pm 
Offline
User avatar

Joined: Mon Feb 25, 2013 12:24 pm
Posts: 283
OK, can now change to any map in game, I initially tried using the same commands as in the map_rotator_classic.php script but it wouldn't change ( I guess because it would need to include more than just the few lines in the change_map part, and needs more of the lines from the get_start_game_command bit) so I just reverted back to using the alias commands and it works a treat.

Now, trying to add a kick command and a max_soldiers command, but they would need a variable to be set, and as my php scripting ability is slightly worse than my defying gravity ability and on a par with my turn invisible ability I do know this is gonna need something a bit different, along the lines of
Code:
(check_command($message, "kick  ($player))) {
   $this->metagame->comms->send("kick ($player)")



Now, not having a clue how php handles variables (or anything else for that matter) feel free to laugh at me, lol, as the above may be complete crap, but after you dry away the tears, if you could point me in the right direction that would be ace :D

Cheers!

_________________
Image


Top
 Profile  
 
PostPosted: Thu May 23, 2013 7:41 pm 
Offline
Site Admin

Joined: Mon Jun 27, 2011 11:59 am
Posts: 2856
Kick command in the server is as unhelpful and simple as it gets, as it accepts the player_id as input parameter. It's up to the script to figure out the player_id using the name if kicking is wanted to be done using names.

Also, names can be difficult to type if they feature strange letters :)

One way would be to go with names anyway, which would mean that everything after "kick " in the incoming chat message would need to be considered as the name to match for, would need a bit of substr() there, then a query would be needed to get the player list from the server (unless you've been tracking player connections and disconnections in the script all a long, saving the player ids and names somewhere), then go through the player list checking for a match with the stuff got from the chat message.

Another possibility could be that you'd split kicking into two commands. The first you'd use to get player name - id pairs printed in-game to you only, e.g. /player_list which would do a bit of private chatting with you, and then do /kick id so that the id gets routed directly to server as a kick command.

Probably there are other ways too. I can code a little something for this but I'm not sure how admins like to kick people and what do they do with names they can't easily output with their keyboard layout :)


Top
 Profile  
 
PostPosted: Thu May 23, 2013 8:07 pm 
Offline
User avatar

Joined: Mon Feb 25, 2013 12:24 pm
Posts: 283
Hmm, OK, then adding a remote kick command may be slightly more complex than just sending to the console "Kick JackMayol", as that was all I assumed you would need to type in if you had direct access to the console.

Fine, ignore that for now, because you have much more important things to be working on than a kick command, lol.

At the moment I have included the following to change maps:

Code:
(check_command($message, "map1")) {
   $this->metagame->comms->send("map1")


I have a different one for each map, which outputs corresponding command direct to the console, which triggers the alias command which changes the map and reads the map1config.xml file that I already had set up from when I first installed the server, and so on for each numbered map: map1 gives map1, map2 gives map2 and so on, each one has it's own entry in the basic_command_handler.php file.

I now would like to add a command for max_soldiers, and I guess I could just add in a variety of commands so that 20, 50, 100, 150, 200, 250 etc are covered , which would look like follows:

Code:
(check_command($message, "max 100")) {
   $this->metagame->comms->send("max_soldiers 100")


Is there an easy way of replacing the number with a variable so that I can change the number to anything I want? So instead of 100 I could put in ($num), so if I typed in game /max 16 it would cause the script to put max_soldiers 16 into the console? Like this:

Code:
(check_command($message, "max ($num)")) {
   $this->metagame->comms->send("max_soldiers ($num)")


P.S. feel free to tell me to bugger off and learn PHP, lol, I know you have a lot on your plate :D

_________________
Image


Top
 Profile  
 
PostPosted: Thu May 23, 2013 8:13 pm 
Offline
Site Admin

Joined: Mon Jun 27, 2011 11:59 am
Posts: 2856
Here it is anyway :lol:

Code:
...

      } else if (check_command($message, "kick")) {
         $this->handle_kick($message);
      }

...

   // --------------------------------------------
   function handle_kick($message) {
      // TODO: just for debugging, this shows to everyone
      $this->metagame->comms->send("say kicking!");

      // get name given as parameter
      $name = substr($message, strlen("kick ") + 1);

      // ask for player list from the server
      $list_query_doc = new DOMDocument();
      $command =
         "<command class='make_query' id='player_list1'>\n" .
         "   <data class='players' />\n" .
         "</command>";
      $list_query_doc->loadXML($command);

      $player_id = -1;

      // send the query command now
      $list_doc = $this->metagame->comms->query($list_query_doc);
      if ($list_doc) {
         $player_list = $list_doc->getElementsByTagName("player");
         echo "* " . $player_list->length . " players found\n";

         // go through the player list and match for the given name
         for ($i = 0; $i < $player_list->length; $i++) {
            $player = $player_list->item($i);
            $name2 = $player->getAttribute("name");
            // case insensitive
            if (strcasecmp($name2, $name) === 0) {
               // found it
               $player_id = $player->getAttribute("player_id");
               break;
            }
         }
      } else {
         echo "failed?\n";
      }
      
      if ($player_id >= 0) {
         // ok player id, now kick
         $this->metagame->comms->send("kick " . $player_id);
      } else {
         echo "* couldn't find a match for " . $name . "\n";
         // TODO: use XML chat command for private message back to who ever sent the message
         $this->metagame->comms->send("say kick missed!");
      }
   }



Top
 Profile  
 
PostPosted: Thu May 23, 2013 8:20 pm 
Offline
User avatar

Joined: Mon Feb 25, 2013 12:24 pm
Posts: 283
Lollers! Thanks Pasik, really should get my finger out and learn this stuff, but I did that a long time ago with something similar and well, that's a long story to tell over a beer, lol, and not on an open forum :D :D

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group