PDA

View Full Version : COD2 camper script



girdap
9th June 2021, 01:47
Cod2 1.3 patch//

Hello, KillTube

i am need a camper script on CTF gametype, (camp after death) except for the flag carrier. I should be able to set the duration and activation with the command. (scr_campertime 6, scr_camper 0/1). How can I do it ? Thanks.

IzNoGoD
9th June 2021, 15:40
Why not set the activation through the same cvar? scr_campertime 0 has no other purpose than to disable it.

girdap
9th June 2021, 18:23
Why not set the activation through the same cvar? scr_campertime 0 has no other purpose than to disable it.

it doesn't matter, this is a solution :)

girdap
12th June 2021, 19:33
Is there anyone who can help? I really need it.

IzNoGoD
12th June 2021, 20:32
This forum tends to perform poorly when asked for full scripts for free.

However, if you try yourself we're pretty good at helping when you hit roadblocks.

As a sidenote: this script would be pretty boring to write.

maxdamage99
15th June 2021, 12:43
Script is really very boring, but besides, there are a lot of nuances to consider.
Try something like this


/* start this (self ...();) when play connected on server */
onPlayerConnect()
{
self checkLoop();
}

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

/* cfg */
waitTime = .1; //maybe .25;

//ALL "CAMP_SECS_*" vars must be multiples of "waitTime" (4 / 0.1 & 6 / 0.1 == true => good)
CAMP_RADIUS = 100;
CAMP_SECS_WARN = 4;
CAMP_SECS_PUNISH = 6;

self waittill("spawned"); //check your SpawnPlayer in gametype.gsc, need self notify("spawned") or remove this line

self.previousPosition = self.origin;
self.campTik = 0;
while (1)
{
if (isAlive(self) && (team == "allies" || team == "axis"))
{
if (distance(self.previousPosition, self.origin) > CAMP_RADIUS)
{
self.previousPosition = self.origin;
self.campTik = 0;
}
else
self.campTik++;

campingTime = (self.campTik * waitTime);
if (campingTime == CAMP_SECS_WARN)
self iprintlnBold("stop camp or be kill!");

if (campingTime == CAMP_SECS_PUNISH)
{
self.campTik = 0;
self iprintlnBold("Camper!");
self suicide();
}
}

wait waitTime;
}
}

no tested, maybe some syntax error or dont work :D

girdap
20th June 2021, 12:19
Script is really very boring, but besides, there are a lot of nuances to consider.
Try something like this


/* start this (self ...();) when play connected on server */
onPlayerConnect()
{
self checkLoop();
}

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

/* cfg */
waitTime = .1; //maybe .25;

//ALL "CAMP_SECS_*" vars must be multiples of "waitTime" (4 / 0.1 & 6 / 0.1 == true => good)
CAMP_RADIUS = 100;
CAMP_SECS_WARN = 4;
CAMP_SECS_PUNISH = 6;

self waittill("spawned"); //check your SpawnPlayer in gametype.gsc, need self notify("spawned") or remove this line

self.previousPosition = self.origin;
self.campTik = 0;
while (1)
{
if (isAlive(self) && (team == "allies" || team == "axis"))
{
if (distance(self.previousPosition, self.origin) > CAMP_RADIUS)
{
self.previousPosition = self.origin;
self.campTik = 0;
}
else
self.campTik++;

campingTime = (self.campTik * waitTime);
if (campingTime == CAMP_SECS_WARN)
self iprintlnBold("stop camp or be kill!");

if (campingTime == CAMP_SECS_PUNISH)
{
self.campTik = 0;
self iprintlnBold("Camper!");
self suicide();
}
}

wait waitTime;
}
}

no tested, maybe some syntax error or dont work :D

Error script :) can you help?

1677

and did I write in the right place?

IzNoGoD
21st June 2021, 16:55
Error script :) can you help?

1677

and did I write in the right place?

Replace by self.sessionteam

girdap
21st June 2021, 19:28
Replace by self.sessionteam

I can't say I understand very well :/

maxdamage99
22nd June 2021, 13:05
I can't say I understand very well :/

:D


self thread scriptfolder/_camper::checkLoop();

girdap
22nd June 2021, 19:04
:D


self thread scriptfolder/_camper::checkLoop();


Thankssss !! it's work.. :) :) :)

////

I wrote the following to interfere with the camp times from the console. The script is running, but I cannot interfere with the times from the console.what to do for this.



level.campradius = 170;
if (getcvar("campradius")!= "" && getcvarint("campradius") > 400)
level.campradius = getcvarint("campradius");

level.campsecswarn = 5;
if (getcvar("campsecswarn")!= "" && getcvarint("campsecswarn") > 20)
level.campsecswarn = getcvarint("campsecswarn");

level.campsecspunish = 9;
if (getcvar("campsecspunish")!= "" && getcvarint("campsecspunish") > 20)
level.campsecspunish = getcvarint("campsecspunish");

maxdamage99
23rd June 2021, 07:18
add in checkLoop()


/* ... */

//ALL "CAMP_SECS_*" vars must be multiples of "waitTime" (4 / 0.1 & 6 / 0.1 == true => good)
CAMP_RADIUS = level.campradius;
CAMP_SECS_WARN = level.campsecswarn;
CAMP_SECS_PUNISH = level.campsecspunish;

/* ... */


i think this better:



level.campradius = 170;
if (getcvar("campradius")!= "" && getcvarint("campradius") > 400)
level.campradius = getcvarint("campradius");

level.campsecswarn = 5;
if (getcvar("campsecswarn")!= "" && getcvarint("campsecswarn") > 20)
level.campsecswarn = getcvarint("campsecswarn");

level.campsecspunish = 9;
if (getcvar("campsecspunish")!= "" && getcvarint("campsecspunish") >= level.campsecswarn)
level.campsecspunish = getcvarint("campsecspunish");


but i make this like it, only:



/* ... */

//ALL "CAMP_SECS_*" vars must be multiples of "waitTime" (4 / 0.1 & 6 / 0.1 == true => good)
CAMP_RADIUS = getcvarint("campradius");
CAMP_SECS_WARN = getcvarint("camsecswarn");
CAMP_SECS_PUNISH = getcvarint("campsecspunish");

/* ... */

and init cvars from .cfg. mb make check on radius > 100 && campsecswarn > 0 && campsecswarn >= campsecspunish

girdap
23rd June 2021, 14:08
Thank you so much. I completed everything. Finally..
Where and how do I add this script so that flag bearers are not affected by the camp.



attachFlag()
{
if(isdefined(self.flagAttached))
return;

if(self.pers["team"] == "allies")
flagModel = "xmodel/prop_flag_" + game["axis"] + "_carry";
else
flagModel = "xmodel/prop_flag_" + game["allies"] + "_carry";

self attach(flagModel, "J_Spine4", true);
self.flagAttached = true;

self thread createHudIcon();
}

maxdamage99
24th June 2021, 07:38
self.flagAttacher

this flag saw player has flag or no, add it in checkLoop()


/* ... */
while (1)
{
if (isAlive(self) && !self.flagAttached && (team == "allies" || team == "axis"))
{

/* ... */

girdap
24th June 2021, 10:48
self.flagAttacher

this flag saw player has flag or no, add it in checkLoop()


/* ... */
while (1)
{
if (isAlive(self) && !self.flagAttached && (team == "allies" || team == "axis"))
{

/* ... */


Thanks. i am getting error :


https://i.hizliresim.com/e9ujf7y.PNG

kung foo man
24th June 2021, 12:26
Instead of while (1) you can check while (isDefined(self)) or use endon at top of method

maxdamage99
24th June 2021, 12:59
my code is resistant to this if you have properly organized code (default, standard from .iwd) and use "thread"

try set self.flagAttached = false by default

p.s: and try fix some by self, if you write all time when has error - you not learning :)

girdap
24th June 2021, 14:25
Instead of while (1) you can check while (isDefined(self)) or use endon at top of method

After doing this:



if (isAlive(self) && !self.flagAttached && self.pers["team"] == "allies" || self.pers["team"] == "axis")

should i do like this?



my code is resistant to this if you have properly organized code (default, standard from .iwd) and use "thread"

try set self.flagAttached = false by default

p.s: and try fix some by self, if you write all time when has error - you not learning


use .iwd, this is how i do it.

https://i.hizliresim.com/frgdxdl.PNG

I have no clue how this is done.

I'm trying to solve the errors myself, I'm testing. If I can't solve it, I write it here, not every mistake.

for example
(team == "allies" || team == "axis")) fixed the error like this
self.pers["team"] == "allies" || self.pers["team"] == "axis")

////

this is the last edit. I couldn't fix the flag bearer.


self.previousPosition = self.origin;
self.campTik = 0;
while (1)
{
if (isAlive(self) && !self.flagAttached && self.pers["team"] == "allies" || self.pers["team"] == "axis")
{
if (distance(self.previousPosition, self.origin) > level.campradius)
{
self.previousPosition = self.origin;
self.campTik = 0;
}
else
self.campTik++;

campingTime = (self.campTik * waitTime);
if (campingTime == level.campsecswarn)
self iprintlnBold("stop camp or be kill!");

if (campingTime == level.campsecspunish)
{
self.campTik = 0;
self iprintlnBold("Camper!");
self suicide();
}
}

wait waitTime;
}
}

this is the last one.

IzNoGoD
24th June 2021, 15:39
self.previousPosition = self.origin;
self.campTik = 0;
while (1)
{
if (isAlive(self) && (!isDefined(self.flagAttached) || !self.flagAttached) && self.pers["team"] == "allies" || self.pers["team"] == "axis")
{
if (distance(self.previousPosition, self.origin) > level.campradius)
{
self.previousPosition = self.origin;
self.campTik = 0;
}
else
self.campTik++;

campingTime = (self.campTik * waitTime);
if (campingTime == level.campsecswarn)
self iprintlnBold("stop camp or be kill!");

if (campingTime == level.campsecspunish)
{
self.campTik = 0;
self iprintlnBold("Camper!");
self suicide();
}
}

wait waitTime;
}
}

girdap
24th June 2021, 20:33
Thanksss!! script finished. works flawlessly.

thank so much IzNoGoD and maxdamage99

they were very helpful, thank you.