One of the many, but here's mine:
Code:
onPlayerSpawn()
{
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--; //decrease next camp time.
if( MaxCampTime != DefaultCampTime && ( getTime() - LastCampTime ) > CampResetTime )
MaxCampTime = DefaultCampTime; //reset camp time
}
}
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( " " );
}
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;
}