Zone where players can not save.

Have questions about CoD4 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

User avatar
Paragon
CJ Wannabe
CJ Wannabe
Posts: 28
Joined: May 9th, 2011, 8:35 am

Zone where players can not save.

Post by Paragon » June 20th, 2011, 9:12 am

Is is possible to make a zone on a map where players can't save ? ;s
And if it it , then how ?

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Zone where players can not save.

Post by IzNoGoD » June 20th, 2011, 9:41 am

Make the whole floor (or where ever a player can stand) into a trigger_multiple, with targetname "nosave".

Im not sure, but i think this removes the loading of positions too...

Then, add this script (the notify in here goes for cod2, not sure about cod4...)

Code: Select all

 main()
{
        level.trig_stopsave=getent("nosave","targetname");
        level thread waitforconnect();
}
 
waitforconnect()
{
        while(true)
        {
                level waittill("connecting",player);
                player thread waitforspawn();
        }
}
 
waitforspawn()
{
        self endon("disconnect");
        self.saving=true;
        while(true)
        {
                self waittill("spawned");
 
                self thread onspawn();
        }
}
 
onspawn()
{
        self endon("disconnect");
        self endon("spawned");
        if(!self.saving)
                self notify("end_saveposition_threads"); //plz change this to the correct notify
        while(true)
        {
                if(isdefined(self.sessionstate)&&self.sessionstate=="playing")
                {
                        if(self.saving&&self istouching(level.trig_stopsave))
                        {
                                self.saving=false;
                                self notify("end_saveposition_threads"); //change this too
                        }
                        else if(!self.saving&&!self istouching(level.trig_stopsave)&&self isonground())
                        {
                                self.saving=true;
                                self thread maps\mp\cj::monitorsaveload(); //im pretty sure this is not the correct thread.. drof?
                        }
                }
                wait 0.05;
        }
}
This code is not working, as i dont have access to the codjumper source code. Drofder might be able to help with the correct therads/notifies.
LMGTFY!

Its not a glitch... Its the future!

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Zone where players can not save.

Post by Drofder2004 » June 20th, 2011, 1:31 pm

This method will simply not work for CoD4, there are no save/load terminating notify commands (other than stock) and the load/save can be done through menu response (removing the need for melee).

The easiest method would be to do one of the following things:

1. Checkpoint
When you enter a no-save area, you are assigned a checkpoint as your savepoint. Problems being, you will have to set all 3 saves to the same point.

2. Memory
When entering a save point, you store a temp value of the old save point and you continue to spam this into the players save variable until they leave the point.

Number two is a mroe user friendly option and number one is more server friendly.

If I ever update the mod, I will add easy support for this, but it will not be any time soon.
Variables you may need:
self.cj["save"]["org1"]
self.cj["save"]["ang1"]
self.cj["save"]["org2"]
self.cj["save"]["ang2"]
self.cj["save"]["org3"]
self.cj["save"]["ang3"]
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Zone where players can not save.

Post by IzNoGoD » June 20th, 2011, 7:53 pm

Option 2 ftw

Code: Select all

  main()
{
        level.trig_stopsave=getent("nosave","targetname");
        level thread waitforconnect();
}
 
waitforconnect()
{
        while(true)
        {
                level waittill("connecting",player);
                player thread waitforspawn();
        }
}
 
waitforspawn()
{
        self endon("disconnect");
        self.spamming=false;
        while(true)
        {
                self waittill("spawned_player");
                self thread onspawn();
        }
}
 
onspawn()
{
        self endon("disconnect");
        self endon("spawned_player");
        while(true)
        {
                if(isdefined(self.sessionstate)&&self.sessionstate=="playing")
                {
                        if(!self.spamming&&self istouching(level.trig_stopsave))
                        {
                                self.cj["save_backup"]["org1"]=self.cj["save"]["org1"];
                                self.cj["save_backup"]["org2"]=self.cj["save"]["org2"];
                                self.cj["save_backup"]["org3"]=self.cj["save"]["org3"];
                                self.cj["save_backup"]["ang1"]=self.cj["save"]["ang1"];
                                self.cj["save_backup"]["ang2"]=self.cj["save"]["ang2"];
                                self.cj["save_backup"]["ang3"]=self.cj["save"]["ang3"];
                                self.spamming=true;
                                self thread spamsaves();
                        }
                        else if(!self.spamming&&!self istouching(level.trig_stopsave)&&self isonground())
                        {
                                self.spamming=false;
                                self notify("stop_spamming_saves");
                        }
                }
                wait 0.05;
        }
}
 
spamsaves()
{
        self endon("disconnect");
        self endon("stop_spamming_saves");
        while(true)
        {
                self.cj["save"]["org1"]=self.cj["save_backup"]["org1"];
                self.cj["save"]["org2"]=self.cj["save_backup"]["org2"];
                self.cj["save"]["org3"]=self.cj["save_backup"]["org3"];
                self.cj["save"]["ang1"]=self.cj["save_backup"]["ang1"];
                self.cj["save"]["ang2"]=self.cj["save_backup"]["ang2"];
                self.cj["save"]["ang3"]=self.cj["save_backup"]["ang3"];
                wait 0.05;
        }
}
Last edited by Drofder2004 on June 20th, 2011, 8:27 pm, edited 2 times in total.
Reason: Change 'Notify' for CoD4
LMGTFY!

Its not a glitch... Its the future!

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Zone where players can not save.

Post by Drofder2004 » June 20th, 2011, 8:29 pm

Fixed the notify for CoD4 usage.
Also, might be worth tweaking for an array of no save areas.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Zone where players can not save.

Post by IzNoGoD » June 20th, 2011, 10:46 pm

Drofder2004 wrote:Fixed the notify for CoD4 usage.
Also, might be worth tweaking for an array of no save areas.
Although im not very familiar with mapping, i guess trigger_multiple already does this?
LMGTFY!

Its not a glitch... Its the future!

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Zone where players can not save.

Post by Drofder2004 » June 20th, 2011, 10:57 pm

IzNoGoD wrote:
Drofder2004 wrote:Fixed the notify for CoD4 usage.
Also, might be worth tweaking for an array of no save areas.
Although im not very familiar with mapping, i guess trigger_multiple already does this?
trigger_multiple is just a trigger that detects an entity. I would figure "multiple" has lost its original meaning, ut has nothing to do with allowing multiples.

Each individual trigger_multiple is considered an entity.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Zone where players can not save.

Post by Drofder2004 » June 20th, 2011, 11:49 pm

Not quite. It would be a lot more effective to make a thread per zone and then when entering the zone a thread on that player, instead of a thread per person with multiple loops.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Zone where players can not save.

Post by IzNoGoD » June 21st, 2011, 12:15 am

That is a bit of a problem, because then it can be glitched.
Triggers only allow one player to activate them, and once activated by said player, they cannot be activated by another player.

istouching() removes this disability, and allows multiple players to "touch" a trigger, but it increases the serverload a bit.
LMGTFY!

Its not a glitch... Its the future!

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Zone where players can not save.

Post by Drofder2004 » June 21st, 2011, 12:47 am

IzNoGoD wrote:istouching() removes this disability, and allows multiple players to "touch" a trigger, but it increases the serverload a bit.
If you use "istouching" then you also no longer need a trigger, a "script_brushmodel" with an invisible texture set to non-coliding.
And if you can use a script_brushmodel, you can then avoid using an array, because you select all the brushes and make them one entire brushmodel...

Requires testing I feel, but in theory, this method would be incredibly more resourceful than triggers and loops.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Zone where players can not save.

Post by Drofder2004 » June 21st, 2011, 12:53 am

Double posting to correct myself!

Infact, I proved a long time ago, that a trigger mutliple infact triggers on ALL entities within the trigger, not just one!

http://www.megavideo.com/?v=9NPPNNC8

Test = Drop 30 'bots' onto a trigger multiple and see if they all get a thread given to the, and quite clearly, they do :)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Zone where players can not save.

Post by megazor » June 21st, 2011, 1:33 am

try this:

Code: Select all

 main()
{
        level.trig_stopsave=getent("nosave","targetname");	//the only brushmodel out of the 'no draw not solid' texture
        level thread cunt();
}
 
cunt()
{
        while(-1111111111111111111111111111111)
        {
	wait 0;   //hopefully this will work. so the rest of the loop will run after the player may have saved their position. so it will be overriden within the same frame, not in .05 second.
	players = getEntArray("player", "classname");
	for (i = 0; i < players.size; i++)
	{
             	  	if (players[i].sessionstate != "playing")
			continue;
		if (!players[i] isTouching(level.trig_stopsave))
		{
			if (isDefined(players[i].defloration))
				players[i].defloration = undefined;
			continue;
		}

		if (!isDefined(players[i].defloration))
			for (a = 1; a < 4; a++)
			{
				players[i].defloration = 1;
				players[i].cj["save_backup"]["org"+a]=players[i].cj["save"]["org"+a];
				players[i].cj["save_backup"]["ang"+a]=players[i].cj["save"]["ang"+a];
			}
		else
			for (a = 1; a < 4; a++)
				if (players[i].cj["save"]["org"+a] != players[i].cj["save_backup"]["org"+a])
				{
					players[i].cj["save"]["org"+a] = players[i].cj["save_backup"]["org"+a];
					players[i].cj["save"]["ang"+a] = players[i].cj["save_backup"]["ang"+a];
				}

         	}
        wait .05;
        }
}

User avatar
Paragon
CJ Wannabe
CJ Wannabe
Posts: 28
Joined: May 9th, 2011, 8:35 am

Re: Zone where players can not save.

Post by Paragon » June 21st, 2011, 10:01 am

Thanks guys for helping me :D .
Megazor's script works just like i wanted , thanks you very much.

IzNoGoD's script works too , but you can't save/load anymore , if you saved in the trigger and you have to reconnect to be able to save / load again.

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Zone where players can not save.

Post by IzNoGoD » June 21st, 2011, 10:52 am

Damnit

For it to work, edit this line:
else if(!self.spamming
to
else if(self.spamming

(remove the !)
LMGTFY!

Its not a glitch... Its the future!

Lawless
CJ Fan
CJ Fan
Posts: 110
Joined: January 25th, 2011, 7:11 pm
Gamertag: x STRAF3Zz v2

Re: Zone where players can not save.

Post by Lawless » June 23rd, 2011, 11:36 pm

IzNoGoD wrote:Damnit

For it to work, edit this line:
else if(!self.spamming
to
else if(self.spamming

(remove the !)
IzNoGoD wrote:You could at least have made your topic title a little more descriptive...
Quote from the thread !!!!!HELP!!!!!

Ehm...? *cough*hypocrite*cough*
Join my server @ 217.163.22.223:28960

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests