Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds
Watch MODSonair

Members Online

»
0 Active | 9 Guests
Online:

LATEST FORUM THREADS

»
help pls
CoD2 Scripting
Rainbow HELP....
CoD4 MP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Restricted Access subscribe
Author Topic: Triggered teleport
bobiman
General Member
Since: May 11, 2012
Posts: 15
Last: Dec 17, 2012
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Monday, Jul. 2, 2012 06:05 am
Hi,

i am today thinking about an anti-camp idea:

i'd like to make an area in my map where people can camp.
So far its fine, but i also want to put an end to the camp
So the players could camp in the area, but at some point they would have to leave.

I tought to make a trigger_use for teleport, but it wont do the work cuz players would not trigger it.
So i am trying to have a cooldown which starts when players walks into the trigger multiple area, and when it reaches 0 or whatever, the player is telported

Moreover, i also make a triggerable entity that would move,
but is it possible to have the player teleported after he triggers the entity?
Like he presses F,
door moves,
player teleports

Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Monday, Jul. 2, 2012 09:01 am
Code:

main()
{
	level.campspots=[];
	level.teleporttarget=getent("where_players_go_when_camping","targetname");
	addcampspots();
	thread waitforconnect();
}

waitforconnect()
{
	while(true)
	{
		level waittill("connecting",player);
		player thread waitforspawn();
	}
}

waitforspawn()
{
	self endon("disconnect");
	while(true)
	{
		self waittill("spawned_player");
		self thread onspawn();
	}
}

onspawn()
{
	self endon("disconnect");
	self endon("spawned_player");
	self endon("killed_player");
	self endon("killed"); //not sure if its killed_player or just killed. Including both has almost no negative effect on performance.
	self.camptimer=0;
	while(true)
	{
		touching=false;
		for(i=0;i<level.campspots.size;i++)
		{
			if(self istouching(level.campspots[i]))
			{
				touching=true;
				break;
			}
		}
		if(touching)
			self.camptimer++;
		else
			self.camptimer=0;
		if(self.camptimer>30) //adjust the 30 to the wanted amount of campseconds
		{
			if(isdefined(self.sessionstate)&&self.sessionstate=="playing")
			{
				self.camptime=0;
				self setorigin(level.teleporttarget.origin);
			}
		}
		wait 1;
	}
}

addcampspots()
{
	level.campspots[level.campspots.size]=getent("campspotone","targetname");
	level.campspots[level.campspots.size]=getent("thathightreeinyourmap","targetname");
	level.campspots[level.campspots.size]=getent("campspotthree","targetname");
	level.campspots[level.campspots.size]=getent("campspottwo","targetname");
}

adjust the 30 to the required amount of anti-camptime (30 is 30 seconds of camping before getting teleported)

add campspots/remove campspots in the addcampspots() function. It should be self-explainatory.
Campspots should be trigger_multiple or any other trigger that can be detected by istouching()

The teleporttarget should be a script_origin or anything else that has a .origin.

Good luck

{code is untested. No warranty etc}

edited on Jul. 2, 2012 10:17 am by IzNoGoD
Share |
bobiman
General Member
Since: May 11, 2012
Posts: 15
Last: Dec 17, 2012
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Monday, Jul. 2, 2012 09:52 am
just tested.
Had some hard time with a forgotten parenthesis giving me a bad syntax,
but i could finally test it and..
it works perfectly.

I used
the area where people camp= trig_multi> targetname=camping
the area where you end up after too much camping= script origin> targetname=campingisover

so it gives me:

{
level.campspots=[];
level.teleporttarget=getent("campingisover","targetname");
addcampspots();
thread waitforconnect();
}


waitforconnect()
{
while(true)
{
level waittill("connecting",player);
player thread waitforspawn();
}
}

waitforspawn()
{
self endon("disconnect");
while(true)
{
self waittill("spawned_player");
self thread onspawn();
}
}

onspawn()
{
self endon("disconnect");
self endon("spawned_player");
self endon("killed_player");
self endon("killed");
self.camptimer=0;
while(true)
{
touching=false;
for(i=0;i {
if(self istouching(level.campspots))
{
touching=true;
break;
}
}
if(touching)
self.camptimer++;
else
self.camptimer=0;
if(self.camptimer>10)
{
if(isdefined(self.sessionstate)&&self.sessionstate=="playing")
{
self.camptime=0;
self setorigin(level.teleporttarget.origin);
}
}
wait 1;
}
}

addcampspots()
{
level.campspots[level.campspots.size]=getent("camping","targetname");
}


the max camp time is set to 10

tyvm izno for that proscript
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Monday, Jul. 2, 2012 10:17 am
code updated. added the forgotten ) in the setorigin.
Share |
Restricted Access Restricted Access subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Why console gaming is dying
Quote:Consider this: Dedicated gaming sales — including living-room consoles...
Devs: Games are being dumb...
Click 'read more' to view the contents of this post.
Loadout
Gun Crafting to the Max. edited on Sep. 25, 2012 06:57 pm by Morp...
Introducing the Source Fil...
Surprised this wasn't made a long time ago. Sounds like a nice little feature.
Introducing the Source Fil...
The Source Filmmaker (SFM) is the movie-making tool built and used by us he...

Partners & Friends

»