Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
Collapse

Plutonium

  1. Home
  2. BO2 Modding Releases & Resources
  3. [Release] AFK Monitor

[Release] AFK Monitor

Scheduled Pinned Locked Moved BO2 Modding Releases & Resources
2 Posts 2 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Sorexundefined Offline
    Sorexundefined Offline
    Sorex
    Contributor
    wrote on last edited by Sorex
    #1

    AFK Monitor

    Developed by DoktorSAS

    Black ops II Zombies Version

    How to use it?

    1. Add to your init level thread endgame_fix();
    init(){
           level thread onPlayerConnect();
           level thread endgame_fix();
    }
    
    1. Add on your onPlayerConnect player thread player_is_afk();
    onPlayerConnect(){
        for(;;){
            level waittill("connected", player);
            player thread onPlayerSpawned();
            player thread player_is_afk();
        }
    }
    
    1. Add yo your code this functions
    player_is_afk(){ // Made by DoktorSAS
    	self endon("disconnect");
        level endon("end_game");
    	old_origin = self.origin;
    	old_angles = self getPlayerAngles();
    	seconds_to_be_afk = 5; // Change this value to change wait time to be afk
    	counter = 0;
    	wait 5; // Wait time to turn on AFK Script
    	for(;;){
    		old_origin = self.origin;
    		old_angles = self getPlayerAngles();
    		wait 1;
    		if(distance(old_origin, self.origin) <= 5 && old_angles == self getPlayerAngles() && counter < seconds_to_be_afk){
    			counter++;
    		}else if(counter == seconds_to_be_afk){
    			self thread maps/mp/gametypes_zm/_spectating::setspectatepermissions();
        		self.sessionstate = "spectator";
        		self thread print_to_all( self.name + " is ^1AFK^7, now the player is on Spectator");
        		old_origin = self.origin;
        		old_angles = self getPlayerAngles();
        		while(distance(old_origin, self.origin) <= 5 || old_angles != self getPlayerAngles()){
        			old_angles = self getPlayerAngles();
        			wait 0.05;
        		}
        		self.sessionstate = "playing";
        		counter = 0;
    		}else if(counter > seconds_to_be_afk)
    			counter = 0;
    	}
    }
    endgame_fix(){
    	self endon("disconnect");
        level endon("end_game");
        level waittill("connected", player);
        for(;;){
        	wait 1;
        	counter = 0;
        	foreach(player in level.players){
        		if(player.sessionstate == "spectator" || !isAlive(player))
        			counter++;
        	}
        	if(counter == level.players.size)
        		level notify("end_game");
        }
    }
    print_to_all( msg ){
    	foreach( player in level.players)
    		player iprintln( msg );
    }
    
    

    How to change time to be AFK?

    On the code there a variable called seconds_to_be_afk just chaneg the value of this variable to change the time to put afk status a player

    Multiplayer

    Cooming soon
    
    THS.Shiniriundefined 1 Reply Last reply
    2
    • Sorexundefined Sorex

      AFK Monitor

      Developed by DoktorSAS

      Black ops II Zombies Version

      How to use it?

      1. Add to your init level thread endgame_fix();
      init(){
             level thread onPlayerConnect();
             level thread endgame_fix();
      }
      
      1. Add on your onPlayerConnect player thread player_is_afk();
      onPlayerConnect(){
          for(;;){
              level waittill("connected", player);
              player thread onPlayerSpawned();
              player thread player_is_afk();
          }
      }
      
      1. Add yo your code this functions
      player_is_afk(){ // Made by DoktorSAS
      	self endon("disconnect");
          level endon("end_game");
      	old_origin = self.origin;
      	old_angles = self getPlayerAngles();
      	seconds_to_be_afk = 5; // Change this value to change wait time to be afk
      	counter = 0;
      	wait 5; // Wait time to turn on AFK Script
      	for(;;){
      		old_origin = self.origin;
      		old_angles = self getPlayerAngles();
      		wait 1;
      		if(distance(old_origin, self.origin) <= 5 && old_angles == self getPlayerAngles() && counter < seconds_to_be_afk){
      			counter++;
      		}else if(counter == seconds_to_be_afk){
      			self thread maps/mp/gametypes_zm/_spectating::setspectatepermissions();
          		self.sessionstate = "spectator";
          		self thread print_to_all( self.name + " is ^1AFK^7, now the player is on Spectator");
          		old_origin = self.origin;
          		old_angles = self getPlayerAngles();
          		while(distance(old_origin, self.origin) <= 5 || old_angles != self getPlayerAngles()){
          			old_angles = self getPlayerAngles();
          			wait 0.05;
          		}
          		self.sessionstate = "playing";
          		counter = 0;
      		}else if(counter > seconds_to_be_afk)
      			counter = 0;
      	}
      }
      endgame_fix(){
      	self endon("disconnect");
          level endon("end_game");
          level waittill("connected", player);
          for(;;){
          	wait 1;
          	counter = 0;
          	foreach(player in level.players){
          		if(player.sessionstate == "spectator" || !isAlive(player))
          			counter++;
          	}
          	if(counter == level.players.size)
          		level notify("end_game");
          }
      }
      print_to_all( msg ){
      	foreach( player in level.players)
      		player iprintln( msg );
      }
      
      

      How to change time to be AFK?

      On the code there a variable called seconds_to_be_afk just chaneg the value of this variable to change the time to put afk status a player

      Multiplayer

      Cooming soon
      
      THS.Shiniriundefined Offline
      THS.Shiniriundefined Offline
      THS.Shiniri
      wrote on last edited by THS.Shiniri
      #2

      Sorex

      As far as recognizing if someone is afk and putting him into spectator works flawless

      But the player does not join in when any input is given tho. And if the round ends and the afk player will be respawned he spawns without his old equipment

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Donate