PDA

View Full Version : How to make a AntiCamperMod For SD



STAUFFi
31st January 2013, 21:30
Hey Guys
I make now a sd mod.
and want make a anticampermod.
When you camp 20 sec or 15 sec.
You will be dead.
killtube can help me?

Mitch
31st January 2013, 21:50
antiCamp()
{
self endon("killed_player");

count = 0;
time = 15;

for(;;)
{
origin = self.origin;

wait 1;

if(self.origin == origin)
count++;
else
count = 0;

if(count == time)
self suicide();
}
}


For standalone


init()
{
thread onPlayerConnect();
}

onPlayerConnect()
{
level endon("intermission");

for(;;)
{
level waittill("connecting", player);
player thread onPlayerSpawned();
}
}

onPlayerSpawned()
{
self endon("disconnect");
level endon("intermission");

for(;;)
{
self waittill("spawned_player");
self thread antiCamp();
}
}

Earliboy
31st January 2013, 21:53
I don't got much time, i could answer tommorow.
But just work with self.campingPos = self.origin; and then check the distance within time.

EvoloZz
1st February 2013, 13:56
antiCamp()
{
self endon("killed_player");

count = 0;
time = 15;

for(;;)
{
origin = self.origin;

wait 1;

if(self.origin == origin)
count++;
else
count = 0;

if(count == time)
self suicide();
}
}


For standalone


init()
{
thread onPlayerConnect();
}

onPlayerConnect()
{
level endon("intermission");

for(;;)
{
level waittill("connecting", player);
player thread onPlayerSpawned();
}
}

onPlayerSpawned()
{
self endon("disconnect");
level endon("intermission");

for(;;)
{
self waittill("spawned_player");
self thread antiCamp();
}
}


With something like that you die immediately after spawn, at least I do

kung foo man
1st February 2013, 15:17
Try adding this:





antiCamp()
{
self endon("killed_player");

count = 0;
time = 15;

for(;;)
{
origin = self.origin;

wait 1;

if(self.origin == origin && self.sessionstate != "spectator")
count++;
else
count = 0;

if(count == time)
self suicide();
}
}

EvoloZz
1st February 2013, 15:39
Weird, still same

Earliboy
1st February 2013, 16:09
Well if you credit, u can use mine. I never used it, but when i tested it, it worked.

Its longer but it kills camper that camps in a small area.
May you need to fix the campdistance.

If u want to enable the timer, delete the // at "self thread campHudTimer ....




init()
{
self endon("disconnect");

//iprintln("CampTimer: Start Loading");

campDistance = 1200;
campTime = getCvarInt("scr_camptime");
if(campTime == "")
campTime = 30;
else if(campTime <= 5)
campTime = 10;

self.campTimer = 0;

while(true)
{
if(getCvar("scr_camptimer") == "0")
return;
wait .05;
if(!isAlive(self))
{
self.camping = undefined;
self.campTimer = 0;
self.camping = false;
continue;
}
else
{
if(!isDefined(self.camping))
{
self.camping = [];
for(i = 0; i < 5;i++)
self.camping[i] = self.origin;
//iprintln("CampTimer: Defined self.camping");
}
for(i = 0; i < 5;i++)
{
wait 1;
if(!isAlive(self))
break;

if(DistanceSquared(self.camping[i], self.origin) < (campDistance * campDistance))
{
//iprintln("CampTimer: Camping++ "+self.camptimer);
self.campTimer++;
self.camping = true;
//self thread campHudTimer(campDistance, (campTime - self.campTimer), i);
}
else
{
self.camping = undefined;
self.campTimer = 0;
self.camping = false;
}
}
if(self.campTimer > campTime)
{
self iprintlnBold("You Camped to long!");
self suicide(); //You can also just disable his weapon, or respawn him
return;
}
}
}
}

campHudTimer(campDistance, campTime, i)
{
self endon("disconnect");

self notify("kill_campHudTimer");
self endon("kill_campHudTimer");

if((isDefined(self.camping[i])) && (DistanceSquared(self.camping[i], self.origin) < (campDistance * campDistance)) && (isAlive(self)))
{
wait .05;
if(!isDefined(self.camptimer))
{
//iprintln("CampTimer: Defined campHudTimer");
self.camptimer = newClientHudElem(self);
self.camptimer.x = 6;
self.camptimer.y = 76;
self.camptimer.horzAlign = "left";
self.camptimer.vertAlign = "top";
self.camptimer setText(&"^1Camp Timer: ^3");
self.camptimer setClock(campTime, "hudStopwatch", 48, 48);
}
}
if(isdefined(self.camptimer))
self.camptimer destroy();
}



Download: Click Me (http://earli.de/scripts/cod2/cpp/camp_timer.gsc)

randall
1st February 2013, 19:45
Only an unimportant remark:
If the player has left, you dont destroy the camptimer hud and it will reserve space in the memory. (if i am right.. :D)

Mitch
1st February 2013, 20:37
Maybe this script will work better



antiCamp()
{
self endon("killed_player");
self endon("disconnect");
self notify("antiCamp");
self endon("antiCamp");

if(self.sessionstate != "playing")
return;

count = 0;
time = 15;
dmg = 5;

for(;;)
{
origin = self.origin;

wait 1;

if(self.origin == origin && self.sessionstate == "playing")
count++;
else
count = 0;

if(count >= time)
self thread [[level.callbackPlayerDamage]]( self, self, dmg , 1, "MOD_EXPLOSIVE", "none", self.origin, (0,0,0), "none", 0 );
}
}