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

Members Online

»
0 Active | 9 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 subscribe
Author Topic: script for elevator with 2 switches
newbie11
General Member
Since: Jan 23, 2007
Posts: 59
Last: Aug 3, 2009
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Monday, Oct. 29, 2007 07:32 am
hey
I'm trying to make a script for elevator with 2 switches.
here's what i've done but it doesnt really work well.
help?
Quote:
main()
{
thread move_brushmodel();
level.counter_num=1; // lift starts at bottom
}

move_brushmodel()
{
trigger = getent ("elevatorswitch", "targetname"); //switch at bottom
trig = getent ("elevatorswitch2", "targetname"); //switch at top
elevator = getent ("elevatormodel", "targetname");
while (1)
{
trigger waittill ("trigger");
if(level.counter_num==1)
{
trig thread maps\mp\_utility::triggerOff(); // disables switches while lift is moving
trigger thread maps\mp\_utility::triggerOff();
elevator movez(416,10,1,1);
level.counter_num=0; // =lift is at bottom
trig thread maps\mp\_utility::triggerOn();
trigger thread maps\mp\_utility::triggerOn();
}

else
{
trig waittill ("trigger");
if(level.counter_num==0)
{
trigger thread maps\mp\_utility::triggerOff();
trig thread maps\mp\_utility::triggerOff();
elevator movez(-416,10,1,1);
trigger thread maps\mp\_utility::triggerOn();
trig thread maps\mp\_utility::triggerOn();
level.counter_num=1; // =lift is at top
}
}
}
}
Share |
codmp
General Member
Since: Feb 7, 2006
Posts: 905
Last: Aug 1, 2011
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Monday, Oct. 29, 2007 03:29 pm
What happens when you try the script? Post what goes wrong/the problem.
Share |
newbie11
General Member
Since: Jan 23, 2007
Posts: 59
Last: Aug 3, 2009
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Monday, Oct. 29, 2007 03:51 pm
the upper switch works ONLY if the lift is up and 1st you press the bottom switch and then the upper.
[confused]
Share |
(VM)Monkey
General Member
Since: Jul 31, 2006
Posts: 113
Last: Mar 24, 2008
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Monday, Oct. 29, 2007 07:38 pm
The problem in the script is that you have to activate elevatorswitch before you enter the if/else. The waittill for the elevatorswitch2 is in the else part. So right now, if the level.counter_num does not equal one, you have to press elevatorswitch before you can press the elevatorswitch2.

This is the way I do it for my elevators:
Code:

main()
{
trigger = getent ("elevatorswitch", "targetname"); //switch at bottom
trig = getent ("elevatorswitch2", "targetname"); //switch at top

level.counter_num = 1;

thread trigger triggerwatch();
thread trig triggerwatch();
}

triggerwatch()
{
     elevator = getent("elevatormodel", "targetname");
     
     while(1)
     {
          self waittill("trigger");

          if(level.counter_num == 1)
          {
               level.counter_num = 0; // elevator is moving
               //insert movement code here
               level.counter_num = 2; // elevator is stopped at second floor
          }
          else if (level.counter_num == 2)
          {
               level.counter_num = 0;
               // insert movement code here
               level.coutner_num = 1; // elevator is stopped at first floor
          }
          else
               wait 1; // elevator is moving
     }
}
Share |
newbie11
General Member
Since: Jan 23, 2007
Posts: 59
Last: Aug 3, 2009
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Monday, Oct. 29, 2007 08:54 pm
thanks a lot :D [thumbs_up]
Share |
Restricted Access Topic is Locked 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

»