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

Members Online

»
0 Active | 74 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 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Previous Page
subscribe
Author Topic: is it possible?? lift Q
-Ghost-
General Member
Since: Jun 21, 2006
Posts: 36
Last: Oct 31, 2007
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Saturday, Aug. 4, 2007 02:55 am
is there away to make the lift stop at the 3rd floor and not move any higher when the trigger has been used? i've found if i use one trigger you do infact go to the middle then press the trigger again and procede to the 3rd floor, now the problem is; if someone pushes the trigger from the 1st floor when the lift is on the 3rd the lift goes threw the roof and won't stop.

i need a block command if there is one, i've also tried using the trigger to open the lift door and raise the lift at the same time but again i'm having a problem; when i press the trigger the lift doors do infact open but the lift moves up at the same time, i've tried the wait(4) command but does nothing.....

code i'm using:

Code:
lift()
{
door=getent("lift1","targetname");
trig=getent("trig1","targetname");
while(1)
{
trig waittill ("trigger");
//wait (4);
door movez (136,4,0,4.0);
door waittill ("movedone");
trig waittill ("trigger");
}
}


any suggestions or some code would be appreciated...

thanks

Ghost

edited on Aug. 3, 2007 10:57 pm by -Ghost-
Share |
(VM)Monkey
General Member
Since: Jul 31, 2006
Posts: 113
Last: Mar 24, 2008
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Saturday, Aug. 4, 2007 08:52 am
Here's the way I did it. My building has 11 floors that the elevators go to. I have eleven triggers for my elevator, one per floor. I gave the triggers a script_noteworthy value of the floor it pointed to.

For example, the trigger that takes you to the third floor has the key of "script_worthy", and a value of "3".

The triggers all had targets of the script_brushmodels I used for the buttons. I'm sure there was a better way to do it, but it works. =)

My elevator entity has a variable called "moving", and one called "atfloor". Those are pretty self explanatory as to what they are for.

Here's the core of the code

Code:

towerInit()
{
	eleva.cab.cab = getent("acab", "targetname");
	eleva.atfloor = 1; //elevator starts out at level 1
	eleva.moving = false;

	eleva.buttons = getentarray("buttonatrig", "targetname");
	
	for(i=0; i < eleva.buttons.size; i++)
	{
		ent = getent(eleva.buttons[i].target, "targetname");
		eleva.buttons[i] enablelinkto();
		eleva.buttons[i] linkto(ent);
		switch (eleva.buttons[i].script_noteworthy)
		{
			case "1": 	eleva.buttons[i].script_noteworthy = 1;
				 	break;
			case "2": 	eleva.buttons[i].script_noteworthy = 2;
					break;
			case "3": 	eleva.buttons[i].script_noteworthy = 3;
				 	break;
			case "4": 	eleva.buttons[i].script_noteworthy = 4;
					break;
			case "5": 	eleva.buttons[i].script_noteworthy = 5;
				 	break;
			case "6": 	eleva.buttons[i].script_noteworthy = 6;
				 	break;
			case "7": 	eleva.buttons[i].script_noteworthy = 7;
				 	break;
			case "8": 	eleva.buttons[i].script_noteworthy = 8;
				 	break;
			case "9": 	eleva.buttons[i].script_noteworthy = 9;
				 	break;
			case "10":	eleva.buttons[i].script_noteworthy = 10;
					break;
			default: 	eleva.buttons[i].script_noteworthy = 0;
				 	break;
		}

		eleva.buttons[i] thread buttonThink(eleva);
	}
}
buttonThink(elevator)
{
	while(1)
	{
		self waittill("trigger");
		if ((elevator.atfloor != self.script_noteworthy) && (!elevator.moving))
		{
			elevator.moving = true;
			closeDoor(elevator);
			direction = self.script_noteworthy - elevator.atfloor;
			moveCab(elevator, direction);
			elevator.atfloor = elevator.atfloor + direction;
			openDoor(elevator);
			elevator.moving = false;
		}
		else
			wait .1;
	}
}

moveCab(elevator, direction)
{
	if (direction < 0)
	{
		speed = direction * -2;
	}
	else
	{	
		speed = direction * 2;
	}	
	
	elevator.cab.cab movez((136*direction), speed, 1, 1);
	for(i=0; i < elevator.buttons.size; i++)
	{
		ent = getent(elevator.buttons[i].target, "targetname");
		ent movez((136*direction), speed, 1, 1);
	}
	elevator.cab.cab waittill("movedone");
		
}


I left out the openDoor() and closeDoor() functions because those really only apply to my elevator, and are more confusing to explain than they're probably worth in this situation.

The thing about this code is it's pretty easily modified to add or remove floors. In fact, my tower started out as 9 floors, but I added roof access and a basement. Changing the code to add in the two floors only took a few seconds.

Basically, what it does is it knows the floor the elevator is at. If you shoot the button to go to the third floor, it takes the floor number that you want to go to, and subtracts from that the floor that you're at.

IE, elevator at floor 4, you want to go to 1.

eleva.atfloor = 4;
self.script_noteworthy = 1;

direction = self.script_noteworthy - eleva.atfloor;
direction = -3;

It now knows it has to move down three floors. There are 136 units between each floor, so it moves -3*136, or 408 units down.

Hopefully that made sense and is actually helpful.

edited on Aug. 4, 2007 04:55 am by (VM)Monkey
Share |
KlemenKrajnc
General Member
Since: Dec 15, 2006
Posts: 19
Last: Oct 27, 2007
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Saturday, Aug. 4, 2007 09:44 am
Have you in each floor 1 elevator??
Share |
Restricted Access Topic is Locked
Page
Previous Page
subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 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

»