Page 1 of 2

Zone where players can not save.

Posted: June 20th, 2011, 9:12 am
by Paragon
Is is possible to make a zone on a map where players can't save ? ;s
And if it it , then how ?

Re: Zone where players can not save.

Posted: June 20th, 2011, 9:41 am
by IzNoGoD
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.

Re: Zone where players can not save.

Posted: June 20th, 2011, 1:31 pm
by Drofder2004
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"]

Re: Zone where players can not save.

Posted: June 20th, 2011, 7:53 pm
by IzNoGoD
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;
        }
}

Re: Zone where players can not save.

Posted: June 20th, 2011, 8:29 pm
by Drofder2004
Fixed the notify for CoD4 usage.
Also, might be worth tweaking for an array of no save areas.

Re: Zone where players can not save.

Posted: June 20th, 2011, 10:46 pm
by IzNoGoD
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?

Re: Zone where players can not save.

Posted: June 20th, 2011, 10:57 pm
by Drofder2004
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.

Re: Zone where players can not save.

Posted: June 20th, 2011, 11:49 pm
by Drofder2004
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.

Re: Zone where players can not save.

Posted: June 21st, 2011, 12:15 am
by IzNoGoD
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.

Re: Zone where players can not save.

Posted: June 21st, 2011, 12:47 am
by Drofder2004
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.

Re: Zone where players can not save.

Posted: June 21st, 2011, 12:53 am
by Drofder2004
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 :)

Re: Zone where players can not save.

Posted: June 21st, 2011, 1:33 am
by megazor
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;
        }
}

Re: Zone where players can not save.

Posted: June 21st, 2011, 10:01 am
by Paragon
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.

Re: Zone where players can not save.

Posted: June 21st, 2011, 10:52 am
by IzNoGoD
Damnit

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

(remove the !)

Re: Zone where players can not save.

Posted: June 23rd, 2011, 11:36 pm
by Lawless
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*