Raised This Month: $ Target: $400
 0% 

Checking if VAC is working


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 04-09-2006 , 06:32   Checking if VAC is working
Reply With Quote #1

I want to catch if VAC is working with a plugin, so I can shutdown server, (and let serverdoc restart it) to make VAC work again.

Anybody knows how to do it?
__________________
Released six formerly private plugins. Not active here since ages.
MaximusBrood is offline
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 04-10-2006 , 13:53  
Reply With Quote #2

Any Idea?
__________________
Released six formerly private plugins. Not active here since ages.
MaximusBrood is offline
wouter
Senior Member
Join Date: Feb 2005
Location: Belgium
Old 04-10-2006 , 13:58  
Reply With Quote #3

well it stands in HLSW so i guess its a cvar?
Code:
secure "1"
wouter is offline
KoST
Senior Member
Join Date: Jul 2005
Old 04-10-2006 , 15:07  
Reply With Quote #4

i wrote this php script to query my server via rcon, and modified it a bit:

its output:
"SERVER SECURE !!"
or
"SERVER NOT SECURE !!"

just enter the ip and port of the server you want to query below:
Code:
<?php
	// set the ip and port of server:
   define (RCON_PORT,27015); // server port
   define (RCON_IP,"111.222.333.444"); // server ip
	//-------------------------------------------------------------------------------
   
   define (A2S_SERVERQUERY_GETCHALLENGE,toStream(array(0xFF,0xFF,0xFF,0xFF,0x57)));
   define (A2S_INFO,toStream(array(0xFF,
   0xFF,0xFF,0xFF,0x54,0x53,0x6F,0x75,0x72,0x63,0x65,0x20,0x45,
   0x6E,0x67,0x69,0x6E,0x65,0x20,0x51,0x75,0x65,0x72,0x79,0x00)));
   define (A2S_PLAYER,toStream(array(0xFF,0xFF,0xFF,0xFF,0x55)));
   define (A2S_RULES,toStream(array(0xFF,0xFF,0xFF,0xFF,0x56)));

   $info=array();   
   $players=array();

   $raw=QueryServer(A2S_SERVERQUERY_GETCHALLENGE);
   $raw=QueryServer(A2S_INFO);
   $raw=QueryServer(A2S_PLAYER.$info['challenge']);
   $raw=QueryServer(A2S_RULES.$info['challenge']);
   
   //print_r($info);                  
   if ($info["Secure"]==1){
	   echo "SERVER SECURE !!";
   }else{
   	   echo "SERVER NOT SECURE !!";
   }




   
   function Rcon($command){
       return trim(QueryServer(toStream(array(0xFF,0xFF,0xFF,0xFF)).$command,true));
   }
   
   function QueryServer($request,$isRconCommand=false){
      global $players,$info;
      $fp = fsockopen("udp://".RCON_IP,RCON_PORT, $errno, $errstr);
      if (!$fp) {
       echo "Fehler: $errno - $errstr
\n";
         return false;   
      } else {
         fwrite($fp,$request);
         $result=fread($fp, 100000);
         fclose($fp);

         $type=substr($result,4,1);
         
         $result=substr($result,5);
         if ($isRconCommand){
            //echo "[RCON]->".$result;
            return $result;
            switch ($type){
            
            }
         }


            switch ($type){
               case 'A':
                  //echo "challenge number:".$result[0]+$result[0]*256+$result[0]*256*256+$result[0]*256*256*256;
                  $info['challenge']=$result;
               break;
               case 'm':

                  $info['ip']=GetResultVal($result,'string');
                  $info['hostname']=GetResultVal($result,'string');
                  $info['map']=GetResultVal($result,'string');
                  $info['game']=GetResultVal($result,'string');
                  $info['description']=GetResultVal($result,'string');
   
                  $info['numPlayers']=GetResultVal($result);
                  $info['maxPlayers']=GetResultVal($result);
                  $info['version']=GetResultVal($result);
                  if (GetResultVal($result)==ord('d')){
                     $info['dedicated']=true;
                  }else{
                     $info['dedicated']=false;
                  }
                  if (GetResultVal($result)==ord('l')){
                     $info['os']='Linux';
                  }else{
                     $info['os']='Windows';
                  }
                  if (GetResultVal($result)==1){
                     $info['pwd']=true;
                  }else{
                     $info['pwd']=false;
                  }
                  if (GetResultVal($result)==1){
                     $info['IsMod']=true;
                  }else{
                     $info['IsMod']=false;
                  }
                  
   
                  $info['URLInfo']=GetResultVal($result,'string');
                  $info['URLDL']=GetResultVal($result,'string');
                  $info['Unused']=GetResultVal($result,'string');
                  $info['ModVersion1']=GetResultVal($result);
                  $info['ModVersion2']=GetResultVal($result);
                  $info['ModVersion3']=GetResultVal($result);
                  $info['ModVersion4']=GetResultVal($result);
                  $info['ModSize1']=GetResultVal($result);
                  $info['ModSize2']=GetResultVal($result);
                  $info['ModSize3']=GetResultVal($result);
                  $info['ModSize4']=GetResultVal($result);
                  
                  $info['SvOnly']=GetResultVal($result);
   
   
   
                  $info['ClDLL']=GetResultVal($result);   
   
                  $info['Secure']=GetResultVal($result);
                  $info['numBots']=GetResultVal($result);
                  $info['realPlayers']=$info['numPlayers']-$info['numBots'];
   
      
   
               break;
   
               case 'D':
                  $n=GetResultVal($result);
                  if ($n!=$info['numPlayers']){
                     echo "sombody joining...";
                  }
                  $players=array();
                  for ($s=0;$s<$n;$s++){
                     $index=GetResultVal($result);
                     $cur=&$players[$index];
                     $cur['name']=GetResultVal($result,'string');
                     $cur['frags']=GetResultVal($result);
                     $frags=GetResultVal($result);
                     $frags=GetResultVal($result);
                     $frags=GetResultVal($result);
   
                     $time=GetResultVal($result);
                     $time=GetResultVal($result);
                     $time=GetResultVal($result);
                     $time=GetResultVal($result);
                  }
               break;
   
               case 'y':
                  //echo "LKJ";
                  $val1=GetResultVal($result);
                  $val1=GetResultVal($result);
                  $n=$val1+$val2*256;
                  for ($s=0;$s>$n;$s++){
                     echo "rule: ".GetResult($result,'string')."
";
                     echo " val: ".GetResult($result,'string')."
";
                  }
               break;
               
               default:
                  //echo "TAPE: ".$type;
               break;
            }
         return true;
      }

      return false;   
   }

   function toStream($arr){
      $tmp="";
      foreach ($arr as $val){
         $tmp.=chr($val);
      }
      return $tmp;
   }


   function GetResultVal(&$result,$mode='byte'){
      if ($mode=='byte'){
         $tmp=ord(substr($result,0,1));
         $result=substr($result,1);
         return $tmp;
      } else if ($mode=='string'){
         $a=explode(chr(0),$result,2);
         $result=$a[1];
         return $a[0];
      }
   }    
   
?>
KoST is offline
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 04-10-2006 , 15:29  
Reply With Quote #5

Allright, I'll edit the script to only check for secure mode, and when it finds the server insecure, it will connect to server with rcon and shut it down.

---

Only one question left, how to launch the script every minute or so?
If that isn't possible, I can always make a link in my server's motd to the script, but that isn't very neat
__________________
Released six formerly private plugins. Not active here since ages.
MaximusBrood is offline
KoST
Senior Member
Join Date: Jul 2005
Old 04-10-2006 , 16:40  
Reply With Quote #6

here is the stuff you will need to use rcon password/challenge:

this example executes the 'status' command:
Code:
   $rcon_challenge=substr(Rcon('challenge rcon'),14);
   echo Rcon('rcon '.$rcon_challenge.' "'.RCON_PASSWORD.'" status');
let me know if you got it working.. or if there are further problems..
KoST is offline
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 04-10-2006 , 16:45  
Reply With Quote #7

I know my PHP, but thanks
__________________
Released six formerly private plugins. Not active here since ages.
MaximusBrood is offline
KoST
Senior Member
Join Date: Jul 2005
Old 04-10-2006 , 16:48  
Reply With Quote #8

thats how we like it !
KoST is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 04-10-2006 , 19:20  
Reply With Quote #9

This would be soooo much easier with an AMXx plugin.

Check to see if secure == 1
if it does, return, if not, shutdown.

DONE.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 04-11-2006 , 02:54  
Reply With Quote #10

Quote:
Originally Posted by Twilight Suzuka
This would be soooo much easier with an AMXx plugin.

Check to see if secure == 1
if it does, return, if not, shutdown.

DONE.
Now you tell me how to do that, since there is no cvar whatsoever that can tell if VAC is on or off.
And no, 'sv_secure' and 'secure' don't work
__________________
Released six formerly private plugins. Not active here since ages.
MaximusBrood is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:33.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode