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

Members Online

»
0 Active | 6 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

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
Next Page
subscribe
Author Topic: Elevator Problem
n3BuL
General Member
Since: Nov 10, 2008
Posts: 44
Last: Jul 2, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Thursday, Feb. 12, 2009 02:52 pm
Hi!

I'm trying to make an elevator with 2 buttons. One at the bottom, and the other at the top.
They are both supposed to make the elevator switch position (if the elevator is down, it goes up and if it is up, it goes down).

I used this tutorial: http://www.modsonline.com/Tutorials-read-563.html and then I made a few changes to the script.

What I got so far is:
Code:
main()
{
thread elevator();
}

elevator()
{
elevator=getent("elevator","targetname");       //the elevator
trig=getent("elevatorswitch","targetname");     //switch at bottom
trig2=getent("elevatorswitch2","targetname");   //switch at top
while(1)
{
trig or trig2waittill ("trigger");  //supposed to make the ele go up or down
elevator movez (320,7,1.9,1.9);  //ele moves
elevator waittill ("movedone");
wait(1);
trig or trig2 waittill ("trigger");  //supposed to make the ele go up or down
elevator movez (-320,7,1.9,5);  //ele moves
elevator waittill ("movedone");
wait(1);
}
}


What I need to change is the "trig or trig2". I know that "or" is not an available command, but I can't explain it with different words.

I tried using only one trigger (at the top and bottom), but the triggers didn't work - the elevator was moving up and down all the time (without me pushing any buttons).

I tried searching on the forum, but I couldn't find this exact problem anywhere..
Btw.. I just started looking at scripts yesterday, so please keep it simple [ohwell]

edited on Feb. 12, 2009 09:53 am by n3BuL
Share |
ChusGMh
General Member
Since: Oct 7, 2008
Posts: 65
Last: Oct 4, 2010
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Thursday, Feb. 12, 2009 04:07 pm
Hehe elevator with 2 triggers [casanova]

I send u the script its custom so if it doens't work just tell me [wave]


main()
{
thread elevator();
}

elevator()
{
elevator=getent("elevator","targetname");
trig=getent("trig_elevator","targetname");
trig2=getent("trig_elevator2","targetname");
while(1)
{
trig waittill ("trigger");
elevator movez (-250,7,1.9,1.9);
elevator waittill ("movedone");
wait(1);
trig2 waittill ("trigger");
elevator movez (-250,7,1.9,1.9);
elevator waittill ("movedone");
wait(1);
elevator movez (250,7,1.9,5);
elevator waittill ("movedone");
}
}

If this script works good u will have 2 triggers(buttons) then u only must change the -250 or 250 for it go up or down if it doens't work try this ONE isn't made by me i found in a map so it must work


main()
{
level.elevatorDown = true;
level.elevatorMoving = false;
thread elevator_start();
}

elevator_start() {
elevator = getentarray ("elevatorswitch","targetname");
if ( isdefined(elevator) )
for (i = 0; i < elevator.size; i++)
elevator thread elevator_think();
}

elevator_think() {
while (1) {
self waittill ("trigger");
if (!level.elevatorMoving)
thread elevator_move();
}
}

elevator_move() {
elevatormodel = getent ("elevatormodel", "targetname");
level.elevatorMoving = true;
speed = 11;
height = 2090;
wait (0);
if (level.elevatorDown) {
elevatormodel playsound ("elevator1");
wait (0);
elevatormodel moveZ (height, speed);
elevatormodel waittill ("movedone");
level.elevatorDown = false;
}
else {
elevatormodel playsound ("elevator1");
wait (1);
elevatormodel moveZ (height - (height * 2), speed);
elevatormodel waittill ("movedone");
level.elevatorDown = true;
}
level.elevatorMoving = false;
}
Share |
n3BuL
General Member
Since: Nov 10, 2008
Posts: 44
Last: Jul 2, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Thursday, Feb. 12, 2009 09:57 pm
The first one wouldn't work for sure.. It starts down, then you get it up, but lets say you don't go with the the elevator. Then you can't get it down again, since it requires switch2 to be pushed.

And I'm pretty sure the second wont work either - since it doesn't have 2 buttons.. But i'll try before saying it doesn't work :) Maybe it would work.. I just have to edit a few things...

EDIT: The script crashed my computer -.-' I tried it 2 times to be sure. The 2nd time it only crashed cod2 (lucky me) [crazy]

edited on Feb. 12, 2009 05:11 pm by n3BuL
Share |
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Thursday, Feb. 12, 2009 10:56 pm
use that code box arthasisgod!

--------------

Take a look at the vCoD elevator tutorial - it works in exactly the same way as CoD2.

http://www.modsonline.com/Tutorials-read-169.html

The script there allows you to have as many triggers as you need - all with the targetname of "elevatorswitch".

The script contains a variable that remembers where the elevator is.

Each trigger has a thread run on it so any trigger can be activated and it will cause the elevator to move.

With triggers, running threads in parallel is the only way to monitor for you 'or' statement.

Post back if you have any more questions or problems!

Share |
n3BuL
General Member
Since: Nov 10, 2008
Posts: 44
Last: Jul 2, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Friday, Feb. 13, 2009 12:46 am
It works perfect! [thumbs_up]
Thanks a lot!
Share |
n3BuL
General Member
Since: Nov 10, 2008
Posts: 44
Last: Jul 2, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Friday, Feb. 13, 2009 07:37 pm
Now I have another problem - same type, just with a slider.
I can't find a way to use 2 triggers on this since the level thingy apparently only works with elevators :p

So far this is what I made

Code:
main()
{
thread slider();
}

slider()
{
slidermodel=getent("slidermodel","targetname");		//the slider
sliderswitch=getent("sliderswitch","targetname");	//the sliderswitch
while(1)
{
triggeron();
sliderswitch waittill ("trigger");	//the slider starts
triggeroff();
slidermodel moveX (544,7,2,2);		//it moves
slidermodel waittill ("movedone");	//it is done moving
wait(1);
triggeron();
sliderswitch waittill ("trigger");	//wait for another trigger
triggeroff();
slidermodel moveX (-544,7,2,2);		//it moves
slidermodel waittill ("movedone");	//it is done moving
wait(1);
triggeron();
}
}

triggeroff()
{
	if(!isdefined(self.realOrigin))
		self.realOrigin = self.origin;

	if(self.origin == self.realorigin)
		self.origin += (0, 0, -10000);
}

triggeron()
{
	if(isDefined(self.realOrigin))
		self.origin = self.realOrigin;
}


It works - except that it does like the elevator - it starts without me triggering it..

(don't mind the comments, it is so I can remember what the function does :p)
Share |
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Friday, Feb. 13, 2009 08:21 pm
Is this like a sliding door?

If so, you can follow the tutorial again exactly (obviously pick different targetnames) and use the same script.

The only thing you'll need to change is toturn the moveZ commands to moveX ones
Share |
n3BuL
General Member
Since: Nov 10, 2008
Posts: 44
Last: Jul 2, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Friday, Feb. 13, 2009 10:39 pm
Ahh.. I knew I forgot to write something. No - it's not a sliding door..
It is well.. How do I say it.. You stand on a platform, and when you press F, it moves to a different location (in the same height).
Hope you understand :s it is hard to explain.
Share |
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Friday, Feb. 13, 2009 11:03 pm
Well again, theres not really any difference between that and a sliding door and an elevator. Try just modifying the elevator script so it uses moveX or moveY (depending on which way it needs to move).
Share |
n3BuL
General Member
Since: Nov 10, 2008
Posts: 44
Last: Jul 2, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Friday, Feb. 13, 2009 11:52 pm
I tried using the elevator script earlier, but now I realize that I must have made some kind of error. Because it is working - almost.. [banghead]

The code is now
Code:
main() {
level.sliderDown = true; // elevator starts at bottom: true/false
level.sliderMoving = false; // elevator is not currently moving
thread slider_start();
}

slider_start() {
slider = getentarray ("sliderswitch","targetname");
if ( isdefined(slider) )
for (i = 0; i < slider.size; i++)
slider[i] thread slider_think();
}

slider_think() {
while (1) {
self waittill ("trigger");
if (!level.sliderMoving)
thread slider_move();
}
}

slider_move() {
slidermodel = getent ("slidermodel", "targetname");
level.sliderMoving = true;
triggeroff();						//trigger off
wait (0);
if (level.slider) { // moves to top
wait (0);
triggeroff();						//trigger off
slidermodel moveX (544,7,2,2);
slidermodel waittill ("movedone");
level.sliderDown = false;
triggeron();						//trigger on
}
else { // moves to bottom
wait (0);
triggeroff();						//trigger off
slidermodel moveX (-544,7,2,2);
slidermodel waittill ("movedone");
level.sliderDown = true;
triggeron();						//trigger on
}
level.sliderMoving = false;
}

triggeroff()
{
	if(!isdefined(self.realOrigin))
		self.realOrigin = self.origin;

	if(self.origin == self.realorigin)
		self.origin += (0, 0, -10000);
}

triggeron()
{
	if(isDefined(self.realOrigin))
		self.origin = self.realOrigin;
}


It DOES move at the first time, but when I trigger it again, it doesn't go back - it goes the same way as the first time.. :/

I think this have something to do with the level.sliderDown since it finds out whether the slider is down or up (height/Z instead of length/X).. But I don't know anything about how the level thingy works, so don't listen to me [rolleyes]

Thanks for the help so far :)

edited on Feb. 13, 2009 06:54 pm by n3BuL
Share |
Restricted Access Topic is Locked
Page
Next 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

»