Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: @ Easymeat, Anti-camp mod cod4, change time for specific weapon?

  1. #1

    Default @ Easymeat, Anti-camp mod cod4, change time for specific weapon?

    Heey Easymeat,

    If u have time could u change this mod so the sniper can camp for 50 seconds and the mg for 30?.

    is that doable?.

    Code:
    main() {
    	if(getdvarint("scr_anti_camping_enable") == 0)
    		return;
    	if(isDefined(self)) {
    		self thread AntiCamp();
    	}		
    }
    
    AntiCamp() {
    	level endon("game_ended");
    	self endon("disconnect");
    	self endon("joined_spectators");
    	self endon ("death");
    	
    	max_distance = getdvarint("scr_anti_camping_distance");
    	allowed_camp_time = getdvarint("scr_anti_camping_time");
    
    	if(!isDefined(max_distance)) max_distance = 100;
    	if(!isDefined(allowed_camp_time)) allowed_camp_time = 20;
    	
    	self.camp_timer = 0;
    	self.weapons_disabled = false;
    	while(1) {
    		old_position = self.origin;
    		wait 1;
    		
    		if(distance2d(old_position,self.origin) < max_distance )
    			self.camp_timer++;
    		else {
    			self.camp_timer = 0;
    			if(self.weapons_disabled) {
    				self enableWeapons();
    				self.weapons_disabled = false;
    			}
    		}
    		if(self.camp_timer == allowed_camp_time) {
    			self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "^2No camping allowed!", "^3You have ^55 seconds ^3to move", "", (1.0, 0.0, 0.0) );
    			self disableWeapons();
    			self playLocalSound(game["voice"][self.pers["team"]]+"new_positions");
    			self.weapons_disabled = true;
    		}			
    		if(self.camp_timer == (allowed_camp_time + 7))
    			self thread maps\mp\gametypes\_b3_poweradmin::_cmd_explode_threaded();
    	}
    }
    
    
    AntiAreaCamp() {
    	level endon("game_ended");
    	self endon("disconnect");
    	self endon("joined_spectators");
    	self endon ("death");
    	
    	second_distance = getdvarint("scr_areacamp_distance");
    	sec_allowed_camp_time = getdvarint("scr_areacamp_time");
    	
    	if(!isDefined(sec_allowed_camp_time)) sec_allowed_camp_time = 12;
    	if(!isDefined(second_distance)) second_distance = 1000;
    	
    	self.sec_camp_timer = 0;
    	self.camp_warned = "no";
    	for(;;) {
    		oPos = self.origin;
    		self.camp_warned = "no";
    		wait 1;
    		
    		while(distance2d(oPos, self.origin) < second_distance) {
    			self.sec_camp_timer++;
    			
    			if(self.sec_camp_timer > sec_allowed_camp_time && self.camp_warned == "yes") {
    				self thread maps\mp\gametypes\_b3_poweradmin::anti_camp_penalty(5);
    				self playLocalSound("breathing_hurt");
    				self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "", "^5No area Camping!", "", (1.0, 0.0, 0.0) );
    				self.camp_warned = "yip";
    				wait 7;
    			}
    			
    			if(self.sec_camp_timer > sec_allowed_camp_time && self.camp_warned == "no") {
    				self playLocalSound("breathing_hurt");
    				self thread maps\mp\gametypes\_b3_poweradmin::anti_camp_penalty(1);
    				self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "^5No area Camping!", "^7You have ^55 ^7seconds to move!", "", (1.0, 0.0, 0.0) );
    				self.camp_warned = "yes";
    				wait 5;
    			}
    			
    			if(self.camp_warned == "yip") self.camp_warned = "no";
    			wait 1;
    		}
    		if(distance2d(oPos, self.origin) > second_distance) self.sec_camp_timer = 0;
    	}
    }
    greets slim

  2. #2

    Default

    It's doable you need to make a "if" statement to check for the weapons player has, then another to get the sniper & mg allowed camp time. something like this
    Code:
    main() {
    	if(getdvarint("scr_anti_camping_enable") == 0)
    		return;
    	if(isDefined(self)) 
    	{
    	******* ADD A WEAPONS CHECK HERE FOR SNIPERS ********
    	if(getdvar palyers weapon sniper) 
    	 {
    		self thread AntiCamp_sniper();
    		}
    			******* ADD A WEAPONS CHECK HERE FOR MG'S ********
    	if(getdvar palyers weapon MG'S) 
    	 {
    		self thread AntiCamp_mg();
    		}
        else
        {
        self thread AntiCamp();
        }
    	}		
    }
    AntiCamp() {
    	level endon("game_ended");
    	self endon("disconnect");
    	self endon("joined_spectators");
    	self endon ("death");
    	
    	max_distance = getdvarint("scr_anti_camping_distance");
    	allowed_camp_time = getdvarint("scr_anti_camping_time");
    
    	if(!isDefined(max_distance)) max_distance = 100;
    	if(!isDefined(allowed_camp_time)) allowed_camp_time = 20;
    	
    	self.camp_timer = 0;
    	self.weapons_disabled = false;
    	while(1) {
    		old_position = self.origin;
    		wait 1;
    		
    		if(distance2d(old_position,self.origin) < max_distance )
    			self.camp_timer++;
    		else {
    			self.camp_timer = 0;
    			if(self.weapons_disabled) {
    				self enableWeapons();
    				self.weapons_disabled = false;
    			}
    		}
    		if(self.camp_timer == allowed_camp_time) {
    			self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "^2No camping allowed!", "^3You have ^55 seconds ^3to move", "", (1.0, 0.0, 0.0) );
    			self disableWeapons();
    			self playLocalSound(game["voice"][self.pers["team"]]+"new_positions");
    			self.weapons_disabled = true;
    		}			
    		if(self.camp_timer == (allowed_camp_time + 7))
    			self thread maps\mp\gametypes\_b3_poweradmin::_cmd_explode_threaded();
    	}
    }
    
    AntiCamp_sniper() {
    	level endon("game_ended");
    	self endon("disconnect");
    	self endon("joined_spectators");
    	self endon ("death");
    	
    	max_distance = getdvarint("scr_anti_camping_distance");
    	allowed_camp_time = getdvarint("scr_anti_camping_sniper_time");
    
    	if(!isDefined(max_distance)) max_distance = 100;
    	if(!isDefined(allowed_camp_time)) allowed_camp_sniper_time = 20;
    	
    	self.camp_sniper_timer = 0;
    	self.weapons_disabled = false;
    	while(1) {
    		old_position = self.origin;
    		wait 1;
    		
    		if(distance2d(old_position,self.origin) < max_distance )
    			self.camp_sniper_timer++;
    		else {
    			self.camp_sniper_timer = 0;
    			if(self.weapons_disabled) {
    				self enableWeapons();
    				self.weapons_disabled = false;
    			}
    		}
    		if(self.camp_sniper_timer == allowed_camp_sniper_time) {
    			self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "^2No camping allowed!", "^3You have ^55 seconds ^3to move", "", (1.0, 0.0, 0.0) );
    			self disableWeapons();
    			self playLocalSound(game["voice"][self.pers["team"]]+"new_positions");
    			self.weapons_disabled = true;
    		}			
    		if(self.camp_sniper_timer == (allowed_camp_sniper_time + 7))
    			self thread maps\mp\gametypes\_b3_poweradmin::_cmd_explode_threaded();
    	}
    }
    
    AntiCamp_mg() {
    	level endon("game_ended");
    	self endon("disconnect");
    	self endon("joined_spectators");
    	self endon ("death");
    	
    	max_distance = getdvarint("scr_anti_camping_distance");
    	allowed_camp_time = getdvarint("scr_anti_camping_mg_time");
    
    	if(!isDefined(max_distance)) max_distance = 100;
    	if(!isDefined(allowed_camp_mg_time)) allowed_camp_mg_time = 20;
    	
    	self.camp_mg_timer = 0;
    	self.weapons_disabled = false;
    	while(1) {
    		old_position = self.origin;
    		wait 1;
    		
    		if(distance2d(old_position,self.origin) < max_distance )
    			self.camp_mg_timer++;
    		else {
    			self.camp_mg_timer = 0;
    			if(self.weapons_disabled) {
    				self enableWeapons();
    				self.weapons_disabled = false;
    			}
    		}
    		if(self.camp_mg_timer == allowed_camp_mg_time) {
    			self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "^2No camping allowed!", "^3You have ^55 seconds ^3to move", "", (1.0, 0.0, 0.0) );
    			self disableWeapons();
    			self playLocalSound(game["voice"][self.pers["team"]]+"new_positions");
    			self.weapons_disabled = true;
    		}			
    		if(self.camp_mg_timer == (allowed_camp_mg_time + 7))
    			self thread maps\mp\gametypes\_b3_poweradmin::_cmd_explode_threaded();
    	}
    }
    Just need to hook up the get weapons part of the script, or rework the camp times for snipers and mg but you still need to check for weapons first, that would make for a smaller cleaner script.

  3. #3

    Default

    something like this should work to get the weapons if it works then just take the sniper section and change sniper to mg along with the weapons at end of script and add it to this gsc I haven't tested it no server.

    Code:
    main() 
    {
    	if(WeaponType(self getcurrentweapon(),"sniper"))
    	{
    	self.thread Sniper();
    	}
    	else
    	{
    	if(getdvarint("scr_anti_camping_enable") == 0)
    		return;
    	if(isDefined(self)) {
    		self thread AntiCamp();
    	}		
    }
    }
    AntiCamp() {
    	level endon("game_ended");
    	self endon("disconnect");
    	self endon("joined_spectators");
    	self endon ("death");
    	
    	max_distance = getdvarint("scr_anti_camping_distance");
    	allowed_camp_time = getdvarint("scr_anti_camping_time");
    
    	if(!isDefined(max_distance)) max_distance = 100;
    	if(!isDefined(allowed_camp_time)) allowed_camp_time = 20;
    	
    	self.camp_timer = 0;
    	self.weapons_disabled = false;
    	while(1) {
    		old_position = self.origin;
    		wait 1;
    		
    		if(distance2d(old_position,self.origin) < max_distance )
    			self.camp_timer++;
    		else {
    			self.camp_timer = 0;
    			if(self.weapons_disabled) {
    				self enableWeapons();
    				self.weapons_disabled = false;
    			}
    		}
    		if(self.camp_timer == allowed_camp_time) {
    			self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "^2No camping allowed!", "^3You have ^55 seconds ^3to move", "", (1.0, 0.0, 0.0) );
    			self disableWeapons();
    			self playLocalSound(game["voice"][self.pers["team"]]+"new_positions");
    			self.weapons_disabled = true;
    		}			
    		if(self.camp_timer == (allowed_camp_time + 7))
    			self thread maps\mp\gametypes\_b3_poweradmin::_cmd_explode_threaded();
    	}
    }
    
    
    AntiAreaCamp() {
    	level endon("game_ended");
    	self endon("disconnect");
    	self endon("joined_spectators");
    	self endon ("death");
    	
    	second_distance = getdvarint("scr_areacamp_distance");
    	sec_allowed_camp_time = getdvarint("scr_areacamp_time");
    	
    	if(!isDefined(sec_allowed_camp_time)) sec_allowed_camp_time = 12;
    	if(!isDefined(second_distance)) second_distance = 1000;
    	
    	self.sec_camp_timer = 0;
    	self.camp_warned = "no";
    	for(;;) {
    		oPos = self.origin;
    		self.camp_warned = "no";
    		wait 1;
    		
    		while(distance2d(oPos, self.origin) < second_distance) {
    			self.sec_camp_timer++;
    			
    			if(self.sec_camp_timer > sec_allowed_camp_time && self.camp_warned == "yes") {
    				self thread maps\mp\gametypes\_b3_poweradmin::anti_camp_penalty(5);
    				self playLocalSound("breathing_hurt");
    				self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "", "^5No area Camping!", "", (1.0, 0.0, 0.0) );
    				self.camp_warned = "yip";
    				wait 7;
    			}
    			
    			if(self.sec_camp_timer > sec_allowed_camp_time && self.camp_warned == "no") {
    				self playLocalSound("breathing_hurt");
    				self thread maps\mp\gametypes\_b3_poweradmin::anti_camp_penalty(1);
    				self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "^5No area Camping!", "^7You have ^55 ^7seconds to move!", "", (1.0, 0.0, 0.0) );
    				self.camp_warned = "yes";
    				wait 5;
    			}
    			
    			if(self.camp_warned == "yip") self.camp_warned = "no";
    			wait 1;
    		}
    		if(distance2d(oPos, self.origin) > second_distance) self.sec_camp_timer = 0;
    	}
    }
    
    Sniper() {
    	if(getdvarint("scr_anti_camping_sniper_enable") == 0)
    		return;
    	if(isDefined(self)) {
    		self thread AntiCamp_Sniper();
    	}		
    }
    
    AntiCamp_Sniper() {
    	level endon("game_ended");
    	self endon("disconnect");
    	self endon("joined_spectators");
    	self endon ("death");
    	
    	if(WeaponType(self getcurrentweapon(),"sniper"))
    	{
    
    	max_distance = getdvarint("scr_anti_camping_sniper_distance");
    	allowed_camp_sniper_time = getdvarint("scr_anti_camping_sniper_time");
    
    	if(!isDefined(max_distance)) max_distance = 100;
    	if(!isDefined(allowed_camp_sniper_time)) allowed_camp_sniper_time = 20;
    	
    	self.camp_sniper_timer = 0;
    	self.weapons_disabled = false;
    	while(1) {
    		old_position = self.origin;
    		wait 1;
    		
    		if(distance2d(old_position,self.origin) < max_distance )
    			self.camp_sniper_timer++;
    		else {
    			self.camp_sniper_timer = 0;
    			if(self.weapons_disabled) {
    				self enableWeapons();
    				self.weapons_disabled = false;
    			}
    		}
    		if(self.camp_sniper_timer == allowed_camp_sniper_time) {
    			self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "^2No camping allowed!", "^3You have ^55 seconds ^3to move", "", (1.0, 0.0, 0.0) );
    			self disableWeapons();
    			self playLocalSound(game["voice"][self.pers["team"]]+"new_positions");
    			self.weapons_disabled = true;
    		}			
    		if(self.camp_sniper_timer == (allowed_camp_sniper_time + 7))
    			self thread maps\mp\gametypes\_b3_poweradmin::_cmd_explode_threaded();
    	}
    }
    
    
    AntiAreaCampSniper() {
    	level endon("game_ended");
    	self endon("disconnect");
    	self endon("joined_spectators");
    	self endon ("death");
    	
    	second_distance = getdvarint("scr_areacamp_sniper_distance");
    	sec_allowed_camp_sniper_time = getdvarint("scr_areacamp_sniper_time");
    	
    	if(!isDefined(sec_allowed_camp_sniper_time)) sec_allowed_camp_sniper_time = 12;
    	if(!isDefined(second_distance)) second_distance = 1000;
    	
    	self.sec_camp_sniper_timer = 0;
    	self.camp_warned = "no";
    	for(;;) {
    		oPos = self.origin;
    		self.camp_warned = "no";
    		wait 1;
    		
    		while(distance2d(oPos, self.origin) < second_distance) {
    			self.sec_camp_sniper_timer++;
    			
    			if(self.sec_camp_sniper_timer > sec_allowed_camp_sniper_time && self.camp_warned == "yes") {
    				self thread maps\mp\gametypes\_b3_poweradmin::anti_camp_penalty(5);
    				self playLocalSound("breathing_hurt");
    				self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "", "^5No area Camping!", "", (1.0, 0.0, 0.0) );
    				self.camp_warned = "yip";
    				wait 7;
    			}
    			
    			if(self.sec_camp_sniper_timer > sec_allowed_camp_sniper_time && self.camp_warned == "no") {
    				self playLocalSound("breathing_hurt");
    				self thread maps\mp\gametypes\_b3_poweradmin::anti_camp_penalty(1);
    				self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "^5No area Camping!", "^7You have ^55 ^7seconds to move!", "", (1.0, 0.0, 0.0) );
    				self.camp_warned = "yes";
    				wait 5;
    			}
    			
    			if(self.camp_warned == "yip") self.camp_warned = "no";
    			wait 1;
    		}
    		if(distance2d(oPos, self.origin) > second_distance) self.sec_camp_timer = 0;
    	}
    }
    
    WeaponType(weapon, type){
    
    	if(!isDefined(weapon)) return false;
    
    	switch(type){
    	
    		case "sniper":
    		switch(weapon){
    		
    			case "m40a3_mp":
    			case "m21_mp":
    			case "dragunov_mp":
    			case "barrett_mp"
    			case "remington700_mp": return true;
    			default: return false;
    		}
    	}
    	
    	return false;
    }
    Last edited by easymeat; October 7th, 2017 at 01:58 PM.

  4. #4

    Default

    Heey Easymeat,

    im running on this now:

    Code:
    #include maps\mp\_utility;
    #include maps\mp\gametypes\_hud_util;
    #include common_scripts\utility;
    
    init()
    {		
    
    	level thread onPlayerConnect();
    }
    onPlayerConnect()
    {
    	for( ;; )
    	{
    		level waittill( "connecting", player );
    		player thread onSpawnPlayer();
    		
    	}
    }
    
    onSpawnPlayer()
    {
    	self endon ( "disconnect" );
    	while( 1 )
    	{
    		self waittill( "spawned_player" );
    		//if(getDvar("g_gametype") != "war")
    		self thread Camp_Watcher();
    	}
    }
    
    
    Camp_Watcher()
    {
    	level endon("game_ended");
    	self endon("disconnect");
    	self endon("joined_spectators");
    	self endon ("death");
    
    
    	my_camp_time = 0;
    	have_i_been_warned = false;
    	max_distance = 200;
    	camp_time = 25;
    	camp_time_sniper = 50;
    	currentweapon = self GetCurrentWeapon();
    
    	while( 1 )
    	{
    		old_position = self.origin;
    		wait 1;
    	
    		new_position = self.origin;
    		distance = distance2d( old_position, new_position );
    	
    		if( currentweapon == "m21_mp" || currentweapon == "barrett_mp" || currentweapon == "dragunov_mp" || currentweapon == "m40a3_mp" || currentweapon == "remington700_mp" )
    		{	
    			if( distance < max_distance )
    				my_camp_time++;
    			else
    			{
    				my_camp_time = 0;
    				have_i_been_warned = false;
    			}
    		
    			if( my_camp_time == camp_time_sniper && !have_i_been_warned )
    			{
    			self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "^2No camping allowed!", "^3You have ^510 seconds ^3to move", "", (1.0, 0.0, 0.0) );
    			self disableWeapons();
    			self playLocalSound(game["voice"][self.pers["team"]]+"new_positions");
    			self.camp_warned = "yip";
    			wait 2;
          self enableWeapons();
    			have_i_been_warned = true;
    			}
    	
    			if( my_camp_time == ( camp_time_sniper + 10 ) && have_i_been_warned )
    			{
    				self thread maps\mp\gametypes\_b3_poweradmin::_cmd_explode_threaded();
    
    			}
    		}
    		else
    		{
    			if( distance < max_distance )
    				my_camp_time++;
    			else
    			{
    				my_camp_time = 0;
    				have_i_been_warned = false;
    			}
    		
    			if( my_camp_time == camp_time && !have_i_been_warned )
    			{
    			self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "^2No camping allowed!", "^3You have ^510 seconds ^3to move", "", (1.0, 0.0, 0.0) );
    			self disableWeapons();
    			self playLocalSound(game["voice"][self.pers["team"]]+"new_positions");
    			self.camp_warned = "yip";
    			wait 2;
          self enableWeapons();
    			have_i_been_warned = true;
    			
    			}
    	
    			if( my_camp_time == ( camp_time + 10 ) && have_i_been_warned )
    			{
    self thread maps\mp\gametypes\_b3_poweradmin::_cmd_explode_threaded();			
    			}
    
    		}
    	}
    }
    when u camp it takes your weapon away but gives it back in 1 sec, can u change it so it gives the weapon back when ur out of the camping area?

  5. #5

    Default

    or is it possible to do the same as in mohaa?., just let the mofo burn and decrease health and show where he is or smth?

  6. #6

    Default

    try changing this
    wait 2;
    self enableWeapons();

    with this

    if( distance < max_distance )
    my_camp_time++;
    wait 0.3;
    self enableWeapons();

  7. #7

    Default

    Shouldn't it be in the else? Btw it doesn't look like you need that if/else twice (or some of the other stuff).

    Edit: something like this? Sorry if it's wrong or has a bug in it, don't do CoD4 and can't test.
    Code:
    #include maps\mp\_utility;
    #include maps\mp\gametypes\_hud_util;
    #include common_scripts\utility;
    
    init()
    {		
    	level thread onPlayerConnect();
    }
    onPlayerConnect()
    {
    	for( ;; )
    	{
    		level waittill( "connecting", player );
    		player thread onSpawnPlayer();		
    	}
    }
    
    onSpawnPlayer()
    {
    	self endon ( "disconnect" );
    	while( 1 )
    	{
    		self waittill( "spawned_player" );
    		//if(getDvar("g_gametype") != "war")
    		self thread Camp_Watcher();
    	}
    }
    
    
    Camp_Watcher()
    {
    	level endon("game_ended");
    	self endon("disconnect");
    	self endon("joined_spectators");
    	self endon ("death");
    
    	my_camp_time = 0;
    	have_i_been_warned = false;
    	max_distance = 200;
    	currentweapon = self GetCurrentWeapon();
    
    	if( currentweapon == "m21_mp" || currentweapon == "barrett_mp" || currentweapon == "dragunov_mp" || currentweapon == "m40a3_mp" || currentweapon == "remington700_mp" )
    	{		
    		camp_time = 50;
    	}
    	else
    	{
    		camp_time = 25;
    	}
    
    	while( 1 )
    	{
    		old_position = self.origin;
    		wait 1;	
    		new_position = self.origin;
    
    		distance = distance2d( old_position, new_position );
    		if( distance < max_distance )
    			my_camp_time++;
    		else
    		{
    			my_camp_time = 0;
    			if( have_i_been_warned )
    			{
    				have_i_been_warned = false;
    				self enableWeapons();
    			}
    			continue; // is this allowed in cod4? (if not, just remove this as it's not needed)
    		}
    	
    		if( my_camp_time == camp_time )
    		{
    			self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "^2No camping allowed!", "^3You have ^510 seconds ^3to move", "", (1.0, 0.0, 0.0) );
    			self disableWeapons();
    			self playLocalSound(game["voice"][self.pers["team"]]+"new_positions");		
    			have_i_been_warned = true;			
    		}
    		else if( my_camp_time == ( camp_time + 10 ))
    		{
    			self thread maps\mp\gametypes\_b3_poweradmin::_cmd_explode_threaded();
    		}
    	}
    }
    Last edited by 1337Smithy; December 5th, 2018 at 11:47 AM.

  8. #8

    Default

    thanks easymeat will try it tonight

  9. #9

    Default

    didnt change anything easymeat

  10. #10

    Default

    Look at my reply, Slim. It'll probably work . Copy all of the code in the tag.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •