Script anticamp

Hi everyone, I don’t want to abuse you, but could you help me finish this anticamp script?
And how can I configure it so that it does not affect the sniper and what the seconds look like for it to send a message to move

There are two scripts, but I don’t know which of the two I can use better

//to be threaded by a player on spawn.
main()
{
if(getdvarint(“scr_anticamp” == 0)
return;
wait 5; //spawn wait
self thread AntiCamp();
}

AntiCamp()
{
level endon( “game_ended” );
self endon( “disconnect” );
self endon( “joined_spectators” );
self endon ( “death” );

DefaultCampTime = getdvarint(“scr_maxcamptime” //10
MaxCampTime = DefaultCampTime;
MinCampTime = getdvarint(“scr_mincamptime” //6
CampDistance = getdvarint(“scr_campdistance” //50
CampPunishTime = getdvarint(“scr_camppunishtime” //5
CampResetTime = (getdvarint(“scr_campresettime” - 1) * 1000; //16
LastCampTime = 0;

if(!isdefined(self.pers[“camppunishment”]))
self.pers[“camppunishment”] = 0;

L = 0;
s = 0;

for(c=0;;c++)
{
old = self.origin;
wait 1;
new = self.origin;

L = (distance(new,old));

if (L > CampDistance)
c = 0;
else if(s > (CampPunishTime - 1))
{
self.pers[“camppunishment”]++;
//some punishment based on how much times already got punished?
self punish();
s = 0;
c = 0;
}
if(c > (MaxCampTime - 1))
{
if(s < CampPunishTime)
{
iprintln(self, " is Camping!"
//ping him on radar?
self iprintlnbold( “^1Stop Camping!” );
self iprintlnbold( “^1” + (CampPunishTime - s) + “^7 seconds remaining before punishment” );
}
LastCampTime = gettime();
s++;
}
else
s = 0;
if(s == 1 && MaxCampTime > MinCampTime)
MaxCampTime–;
if( MaxCampTime != DefaultCampTime && ( getTime() - LastCampTime ) > CampResetTime )
{
//reset
MaxCampTime = DefaultCampTime;
}
}
}

isInSpace(front, right, left, rear, bottom, ceiling)
{
if( isdefined( bottom ) && isdefined( ceiling ))
if(self.origin[1] < front && self.origin[1] > rear && self.origin[0] > right && self.origin[0] < left && self.origin[2] < ceiling && self.origin[2] > bottom )
return true;
if(self.origin[1] < front && self.origin[1] > rear && self.origin[0] > right && self.origin[0] < left )
return true;
return false;
}

punish()
{
level endon( “game_ended” );
self endon( “disconnect” );
self endon( “joined_spectators” );
self endon ( “death” );

originX = self.origin[0];
originY = self.origin[1];
camparea = getdvarint( “scr_camparea” ); //120

up = originY + camparea;
right = originX - camparea;
left = originX + camparea;
down = originY - camparea;

self iprintlnbold( " " );
self iprintlnbold( " " );
self iprintlnbold( " " );
self iprintlnbold( “Move out of your camp area!” );
self iprintlnbold( “^1Your weapons are disabled while inside.” );
self disableweapons();
while( self isInSpace(up, right, left, down) )
wait .05;
self enableweapons();
self iprintlnbold( " " );
self iprintlnbold( " " );
self iprintlnbold( " " );
}

watch_anti_camp()
{
self endon(“disconnect”
self endon(“death”
self endon(“joined_spectators”
level endon(“game_ended”
if(getintdvar(“scr_anticamp”!=1)
return;
self.camping = 0;
if(!isDefined(self.bar))
{
self.bar = self maps\mp\gametypes_hud_util::createBar((1,1,1), 64, 8);
self.bar maps\mp\gametypes_hud_util::setPoint(“CENTER”, undefined, 0, 230);
}
while(isAlive(self))
{
oldorg = self.origin;
wait .03;
if(distance(oldorg, self.origin) < 3.5)
self.camping += 0.005;
else
self.camping -= 0.0055;
if(self.camping > 1)
self.camping = 1;
else if(self.camping < 0)
self.camping = 0;
self.bar maps\mp\gametypes_hud_util::updateBar(self.camping);
if(self.camping == 1)
{
self iprintlnbold(“^9Move or you will be killed!”
oldorg = self.origin;
wait 2;
if(distance(oldorg, self.origin) < 150)
{
self suicide();
}
}
}
}

Not going to rewrite or help with getting these script running but I will say an easy way to disable the script on sniper weapons is:

weap = self getCurrentWeapon();
if(weap == "m40a3_mp" || weap == "m21_mp" || weap == "dragunov_mp" || weap == "remington700_mp" || weap == "barrett_mp" || weap == "m40a3_acog_mp" || weap == "m21_acog_mp" || weap == "dragunov_acog_mp" || weap == "remington700_acog_mp" || weap == "barrett_acog_mp")
return;
else

but thats as far as I am helping with these incomplete scripts.
There may be an easier way to decide on sniper weapons but the code above works

no MAd, he didn’t understand me it seems. the favor he was requesting. It is that if you could see those 2 scrip and give me your professional opinion, if they are good or bad…
and in the case that they were fine… how can it be done so that the anticamp script does not affect the snipers. because the snipers can camp.
Do you get me. please your professional help

See if this fits your needs:

#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" );
	weap = self getCurrentWeapon();
	if(weap == "m40a3_mp" || weap == "m21_mp" || weap == "dragunov_mp" || weap == "remington700_mp" || weap == "barrett_mp" || weap == "m40a3_acog_mp" || weap == "m21_acog_mp" || weap == "dragunov_acog_mp" || weap == "remington700_acog_mp" || weap == "barrett_acog_mp")
	return;
	else
	self thread excludeBots();
	}
}

excludeBots()
{
	self endon( "disconnect" );
	guid = self getGuid();
	if ( guid == "0" ) // bots guid to remove them from the camp script due to them getting stuck and constant warnings
	return;
	else
	self thread camper();
}

camper()
{
	self endon( "death" );
	self endon( "disconnect" );
	self endon( "joined_spectators" );
	level endon( "game_ended" );
	my_camp_time = 0;
	have_i_been_warned = false;
	max_distance = 80;  //change to suit
	camp_time = 110; 	//change to suit

	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;
				have_i_been_warned = false;
			}
		
			if( my_camp_time == camp_time && !have_i_been_warned )
			{
			self iprintlnbold("^1Camping Without Sniper Is Not Allowed!!"); // displayed to player
			
        			have_i_been_warned = true;
			iprintln (""+self.name+" ^3is Camping");  // displayed bottom left
			}

			if( my_camp_time == ( camp_time + 10 ) && have_i_been_warned )
			{
			self iprintlnbold("^2Autokick For Camping In Progress");  // displayed to player
			wait 2;
			iprintln (""+self.name+" ^3Kicked for Camping"); // displayed bottom left
			kick(self getEntityNumber(),"^1Kicked for Camping!!");
      		return;
			}
	}
}

If you don’t want to kick but to respawn them then change bottom section to:

if( my_camp_time == ( camp_time + 10 ) && have_i_been_warned )
			{
			self iprintlnbold("^2Time To Die");  // displayed to player
			wait 2;
			iprintln (""+self.name+" ^3Killed for Camping"); // displayed bottom left
			self suicide();
      		return;
			}
	}

I don’t know how to thank you for all your help. Thank you for investing your time in helping me… it really is that people like you, I wish there were millions. They help without expecting anything in return. I congratulate you for being who you are.

I set it up with the script and it worked and now I’m learning what it does and what things can be modified.
what I learned was that I was able to lower the time. You put 110, I think those are seconds and I lowered them to 30.

Is there a way to implement immunity in the script.

for example this is a big brother TK line that only affects players of that rank below

    <set name="warn_level">2</set>

do you mean so certain players are not affected by the script.

If so enter their GUID in the exclude bots section

eg.

if ( guid == "0" || guid == "admin1guid" || guid == "admin2guid" )

But if you want to do it on rank then there will be a way if you can get a players rank.

I don’t know the code for that.

I don’t know what more words of gratitude I can say… you are a great person… thank you very much. You can’t even imagine the happiness you leave me when you see how you help me.

Of course you’re right, that’s how I have VIP users, with their guid, for example.

// Numbers MUST be in order, you cannot jump from vip_0 to vip_2

set vip_0 “guid”
set vip_1 “guid”

what i could never check

if the slot reservation for the GUIDS were written correctly, oh if the slot reservation for the clan tag was placed like this. or is it spelled another way

set scr_reservedslots_guids_100 “2310346614837217657=100;2310346613323429921=100;2310346616373566401=100;2310346613469256425=100”
set scr_reservedslots_clantags “cod4x”

hola MAD, lo ingrese y me da este error

----- Server Shutdown -----

With the reason: Server fatal crashed: script compile error

bad token ‘�’

if ( guid == “0” || guid == “2310346614837217657” || guid == “2310346613323429921” || guid == “2310346616373566401” || guid == “2310346613469256425” ) // bots guid para eliminarlos del script de campamento debido a que se quedaban atascados y recibían constantes avisos

(see console for details)

^1Error: ******* script compile error *******
^1Error: bad token ‘�’: (file ‘maps/mp/gametypes/_camper.gsx’, line 37)
if ( guid == “0” || guid_1 == “” || guid_2 == “” || guid_3 == “” || guid_4 == “” ) // bots guid para eliminarlos del script de campamento debido a que se quedaban atascados y recibían constantes avisos
*


----- Server Shutdown -----
With the reason: Server fatal crashed: script compile error
bad token ‘�’
if ( guid == “0” || guid_1 == “” || guid_2 == “” || guid_3 == “” || guid_4 == “” ) // bots guid para eliminarlos del script de campamento debido a que se quedaban atascados y recibían constantes avisos
(see console for details)

This is the correct way:

if ( guid == "0" || guid == "2310346614837217657" || guid == "2310346613323429921" || guid == "2310346616373566401" || guid == "2310346613469256425" )

But don’t know why you get the error.

When I am at my PC later I will test it

Thank you very much for everything as always, you are great

ok the problem is when you copy and paste from here the " dont appear as they should.

replace the " " from around the guid’s and you will be fine

I suspect thats why they have code boxes so it copies exactly lol

I have edited my posts and put the code in code boxes

you can copy from the code boxes now and you will be fine

1 Like

I got killed for camping on your server… nice one :grin:

1 Like

It is an honor that you visited us. As always, thank you so much for all your support.