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

Members Online

»
0 Active | 12 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
Previous Page
subscribe
Author Topic: Prefabs and scripting
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Thursday, Sep. 23, 2010 10:41 am
The problem is not missing entities. When you use getentarray it returns an array of objects, not a single object.

What you need to do is start a new thread for each trigger and rebuild your prefab so as to link the trigger to the block it relates to.

First open your prefab. Remove the block targetname (by using the delete key / pair button in the entity properties window). Then De-select. Next select the trigger and still holding shift, select the block. Then press 'w'. A line with an arrow on it should appear linking the two entities. You can move the enties apart to make this step easier and once linked move them back into position.

Next to the script:

Code:
main()
{
   triggers = getentarray ("trigger","targetname");
   
   for(i=0; i < triggers.size; i++)
      trigger[i] thread waitfordamage();
}

waitfordamage()
{
   block = getent(self.target,"targetname");
   
   if(!isDefined(block)) // check that the trigger is linked to a block
   {
      iprintln("Missing Linked Block Entity");
      return;
   }
   
   self waittill("trigger");
   
   block delete();  
}


You can adjust things like the allowed methods of damage and the amount of damage the trigger has to take before triggering in the entity window.
Share |
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Thursday, Sep. 23, 2010 10:53 am
about time pedros back on the forums lol [thumbs_up]
Share |
Zelzahim
General Member
Since: Dec 31, 2008
Posts: 42
Last: Sep 23, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Thursday, Sep. 23, 2010 12:44 pm
Hats off to you, Pedro. That made it work. Thanks alot.
Share |
ivan_cro
General Member
Since: Jul 21, 2008
Posts: 463
Last: Oct 27, 2010
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Thursday, Sep. 23, 2010 01:14 pm
Where/how have you learned C? (Pedro)

ivan_cro
Share |
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Thursday, Sep. 23, 2010 09:29 pm
Self taught mainly. First scripts were for a mapping project, but then that turned to small mods and then more complex projects built from scratch.

Did a bit of C and C# at uni, but with CoD it was just a matter of getting stuck into some of the stock scripts. C# and C are both stricter than cod scripting, so I find scripting a lot more enjoyable for this reason.
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

»