[Release] AFK Monitor

Topic created · 1 Posts · 366 Views
  • 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
    
Log in to reply