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

Members Online

»
0 Active | 114 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP 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 4
Category: CoD4 Scripting
Scripting and coding with Call of Duty 4.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: Linking Door Handle to a Moving Door
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Thursday, Apr. 24, 2008 03:15 am
Anyone know how to make a door handle ( misc/model ) to be able to move with the door as it opens and closes? I'd like to add door handles to the doors I have because they look pretty bare right now and a little goofy without door handles.

Do I have to make a door prefab of it already built? If so, do I have to make the trigger with the prefab as well? Making a prefab isn't necessary though because I can make one door and duplicate it for all the doors in my map, once I make one. Just need to know how to link a model to a moving brushmodel.
Share |
bNasty
General Member
Since: Feb 26, 2008
Posts: 94
Last: Feb 18, 2009
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Thursday, Apr. 24, 2008 05:47 am
See this thread.

It has scripts to make the door move, how to link the door handle, and how to add sound to the door.
Share |
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Thursday, Apr. 24, 2008 07:53 am
Yeah, I saw that post, but its not clear enough on how to do it. There are pieces of the tut. all over the thread. Not easy to follow and parts of scripts tossed about.

Guy says to add this to the existing script, which is fine, but doesn't say where in the script to add it...

Code:

self.doorhandle = getent(self.doormodel.target, "targetname");
self.doorhandle linkto(self.doormodel);


or

Code:

self.doorhandle = getent(self.doormodel.target, "targetname");
self.doorhandle enablelinkto();
self.doorhandle linkto(self.doormodel);



Also doesn't explain how to link the handle to the door in radiant. He briefly explains how to set up the door, which I know how to do, but NOT how to set up the handle.

What I'm guessing you have to do is right click the 2D screen and make a script_model of the door handle. (One of the door handle models) Place it. Assuming I already have my Door + Origin + Trigger set up already. Select the Door, then the Door Handle and hit "W" to weld them. A red line should appear, not blue. Correct? Then in the script, it would look something like this...

Code:

main()
{
	thread door();
}

door()
{
	doortrigger = getentarray("doortrig","targetname");
	for(i=0;i<doortrigger.size;i++)
	{
		doortrigger [i] thread door_think();
	}
}

door_think()
{
	self.doormoving = false;
	self.doorclosed = true;
	self.doormodel = getent(self.target, "targetname");
        self.doorhandle = getent(self.doormodel.target, "targetname");
        self.doorhandle enablelinkto();
        self.doorhandle linkto(self.doormodel);
		while (1)
		{
			self waittill("trigger");
			if(!self.doormoving)
			self thread door_move();
		}
}

door_move()
{
	self.doormoving = true;
	if(self.doorclosed)
	{
		self.doormodel playsound ("dooropen");
		self.doormodel rotateyaw(-90, 1, 0.5, 0.5);
		self.doormodel waittill("rotatedone");
		self.doorclosed = false;
	}
	else
	{
		self.doormodel playsound ("doorclose");
		self.doormodel rotateyaw(90, 1, 0.5, 0.5);
		self.doormodel waittill("rotatedone");
		self.doorclosed = true;
	}
	self.doormoving = false;
}



I get an error on Map load


Quote:

******* script runtime error *******
cannot cast undefined to string: (file 'maps/mp/mp_test_door.gsc', line 20)
self.doorhandle = getent(self.doormodel.target, "targetname");
*
Error: called from:
(file 'maps/mp/mp_test_door.gsc', line 11)
doortrigger thread door_think();
*
Error: called from:
(file 'maps/mp/mp_test_door.gsc', line 3)
thread scripted_door();
*
Error: called from:
(file 'maps/mp/mp_test.gsc', line 7)
maps\mp\mp_test_door::main();
*
Error: started from:
(file 'maps/mp/mp_test.gsc', line 1)
main()
*
Error: ************************************



Not sure what else to try here...

edited on Apr. 24, 2008 03:57 am by DeekCiti
Share |
HarkoninVSC
General Member
Since: Jan 25, 2008
Posts: 294
Last: Apr 24, 2008
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Thursday, Apr. 24, 2008 02:19 pm
You have several options;

1) Place the "doorhandle" in the editor and link it to the door.
Then call it in script with doorhandle = self.target

2) use the linkto function in script eg..doorhandle linkto(door)

As far as placement of the code snippet you place it where you want your "handle" to link to the "door", basically before the actual movement.
Share |
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Thursday, Apr. 24, 2008 03:29 pm
Quote:

1) Place the "doorhandle" in the editor and link it to the door.
Then call it in script with doorhandle = self.target


ok, lol... How? is the grand question here. How do you properly link it to the door in Radiant... That is all I've been simply asking the whole time. You just need to be more descriptive on that part there...

I'm obviously doing something wrong in the editor. I'm linking the handle to the door through the method in my last post. What I was asking there in my last post is if that was the proper way to link the handle to the door in Radiant or not? I was also asking in my last post if this is the proper placement of your code snippet in the door script.

Code:

main()
{
	thread door();
}

door()
{
	doortrigger = getentarray("doortrig","targetname");
	for(i=0;i<doortrigger.size;i++)
	{
		doortrigger [i] thread door_think();
	}
}

door_think()
{
	self.doormoving = false;
	self.doorclosed = true;
	self.doormodel = getent(self.target, "targetname");
        self.doorhandle = getent(self.doormodel.target, "targetname");
        self.doorhandle linkto(self.doormodel);
		while (1)
		{
			self waittill("trigger");
			if(!self.doormoving)
			self thread door_move();
		}
}

door_move()
{
	self.doormoving = true;
	if(self.doorclosed)
	{
		self.doormodel playsound ("dooropen");
		self.doormodel rotateyaw(-90, 1, 0.5, 0.5);
		self.doormodel waittill("rotatedone");
		self.doorclosed = false;
	}
	else
	{
		self.doormodel playsound ("doorclose");
		self.doormodel rotateyaw(90, 1, 0.5, 0.5);
		self.doormodel waittill("rotatedone");
		self.doorclosed = true;
	}
	self.doormoving = false;
}



Because no matter what I do I still get the same error on Map Load that I got in my last post. [duh]
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»