AFK for Zombies

Topic created · 1 Posts · 153 Views
  • So the other Script by @Nathan31973 is what I want but his do not work. While @Sorex works.

    I tried mashing them together and yeah it kinda worked. The player is recognized AFK and as soon as he moves a few steps he is no longer afk.

    While AFK godmode & ignoreme is on.

    The Problem is they can shoot and still do not get hit by them. So I need a solution to disable the AFK = True status when a player melees shoots or aims.

    Current Code:

    init() // entry point
    {
        level thread onplayerconnect();
    }
    
    onplayerconnect()
    {
        for(;;)
        {
            level waittill("connected", player);
            player thread onplayerspawned();
    		player.clientid = level.clientid;
    		level.clientid++;
        }
    }
    
    onplayerspawned()
    {
    	level endon( "game_ended" );
    	self endon("disconnect");
    	self iprintlnbold("^2GSC loaded!");
    	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) <= 1 && old_angles == self getPlayerAngles() && counter < seconds_to_be_afk)
    		{
    			counter++;
    		}
    		
    		else if(counter == seconds_to_be_afk)
    		{
    			self.ignoreme = 1; // Zombies wont find the player
    			self enableInvulnerability(); // God mode is on
        		self thread print_to_all( self.name + " is ^1AFK");
        		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)
    		{
    		self.ignoreme = 0; // Zombies will find the player again
    		self disableInvulnerability(); // God mode is off
    		}
    		
    		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 );
    }
    
Log in to reply