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: mp triggers help
newbie11
General Member
Since: Jan 23, 2007
Posts: 59
Last: Aug 3, 2009
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Tuesday, Sep. 18, 2007 06:11 pm
I need a little help . Here's my idea. I have 2 triggers. I want to make this: if the 2nd trigger is activated , when the player activates the first , message 1 appears. If the player hadnt activated the 2nd trigger then message 2 appears. Any ideas how to make this?
Share |
(VM)Monkey
General Member
Since: Jul 31, 2006
Posts: 113
Last: Mar 24, 2008
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Tuesday, Sep. 18, 2007 06:28 pm
in your main():

Code:

level.second_activated = false;

thread firsttrigger();
thread secondtrigger();


then:

Code:

firsttrigger()
{
     trig = getent("firsttriggername", "targetname");

     trig waittill("trigger", player);

     if (level.second_activated)
     {
          player iprinlnbold("whatever");
     }
     else
     {
          player iprintlnbold("whatever");
     }
}

secontrigger()
{
     trig = getent("secondtriggername", "targetname");

     trig waittill("trigger");
     
     level.second_activated = true;
}


That's just a basic script, but should be enough to let you know how to code it the way you need it to be coded.
Share |
newbie11
General Member
Since: Jan 23, 2007
Posts: 59
Last: Aug 3, 2009
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Tuesday, Sep. 18, 2007 06:46 pm
THANKS a lot !!!! [thumbs_up]
Share |
newbie11
General Member
Since: Jan 23, 2007
Posts: 59
Last: Aug 3, 2009
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Tuesday, Sep. 18, 2007 07:20 pm
edit:
There was a small problem with the script because the player could activate trigger 1 only once. I fixed it by adding thread firsttrigger(); So the code will look like this
Code:
firsttrigger()
{
     trig = getent("door1_trigger","targetname");
     door1 = getent("door1","targetname");

     trig waittill("trigger", player);

     if (level.second_activated)
     {
          player iprintlnbold("whatever");
          thread firsttrigger();
     }
     else
     {
          player iprintlnbold("whatever2");
          thread firsttrigger();
     }
}
Share |
(VM)Monkey
General Member
Since: Jul 31, 2006
Posts: 113
Last: Mar 24, 2008
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Tuesday, Sep. 18, 2007 07:40 pm
Ahh. I see. I was just coding it as a one shot thing, just to give you an idea. I was tempted to do it the other way, but I wasn't sure if that was what you wanted.

This might work better for you.

Code:

firsttrigger()
{
     trig = getent("firsttriggername", "targetname");

     while (1)
     {
          trig waittill("trigger", player);
     
          if (level.second_activated)
          {
               player iprinlnbold("whatever");
               level.second_activated = false;
          }
          else
          {
               player iprintlnbold("whatever");
          }
     }
}

secondtrigger()
{
     trig = getent("secondtriggername", "targetname");

     while(1)
     {
          trig waittill("trigger");
     
          level.second_activated = true;
     }
}
Share |
The_Caretaker
General Member
Since: Jun 8, 2004
Posts: 11625
Last: Jul 7, 2009
[view latest posts]
Level 10
Category: CoD2 Scripting
Posted: Tuesday, Sep. 18, 2007 07:52 pm
Monkeys way is the correct way to do this. It doesn't recall the firsttrigger() function every time the 1st trigger is pressed. Calling functions takes memory.
Not that your version won't work, newbie11, Monkeys way is just a bit more correct :p
Share |
newbie11
General Member
Since: Jan 23, 2007
Posts: 59
Last: Aug 3, 2009
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Tuesday, Sep. 18, 2007 07:54 pm
@monkey , that's nice too but i dont need to respawn the trigger because it is trigger damage and when u shoot it an object gets destroyed and it wont be realistic to respawn. I needed to add thread firsttrigger(); because if the player activated trigger 1 and got msg1 and then activated trigger 2 he wouldnt be able to activate trigger 1 again to see the 2nd message. I understand what you thought, it is my mistake that I didnt explain better in my first post. Thanks again :)

caretaker , in my case I dont want to respawn the trigger and if trigger 2 is activated once it cant be deactivated anymore in my way.

edited on Sep. 18, 2007 04:01 pm by newbie11
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

»