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 4
Category: CoD4 Scripting
Scripting and coding with Call of Duty 4.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: Getting an Arrays target...
Drapan
General Member
Since: May 9, 2004
Posts: 290
Last: Apr 18, 2009
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Saturday, Nov. 15, 2008 09:09 pm
I've got 3 triggers, each with a targetname of "montrig" (short for monitor trigger for those interested). They're in a Array called "montrigs".

Now to the tricky part, They all got their individual and unique target (all being script_models). Identified by:
Code:
monitor = getent(self.target,"targetname");

(Self being the trigger) This works fine as long as you only need to affect one trigger/target at a time but I'd like to change all the script_models to a different model at the same time. So the question is, How do I put all the target entities into an array so they all can be affected at once?

I know this can be achieved by giving them each their own targetname but as I'm planning to have a lot of these triggers/script_models around the map it's gonna be a pain giving them each a separate name

edited on Nov. 15, 2008 04:10 pm by Drapan
Share |
novemberdobby
General Member
Since: Sep 17, 2006
Posts: 1965
Last: Oct 13, 2013
[view latest posts]
Level 8
Forum Moderator
Category: CoD4 Scripting
Posted: Saturday, Nov. 15, 2008 10:47 pm
If I'm reading this right, you want to go thru all of the montrigs' targets and put them into an array?

try something like:

Code:

targets = [];
for(i = 0; i < montrigs.size; i++)
	targets[targets.size] = montrigs[i].target;


then you can do something to the targets like:

Code:

for(i = 0; i < targets.size; i++)
{
	targets[i] hide();
}
Share |
Drapan
General Member
Since: May 9, 2004
Posts: 290
Last: Apr 18, 2009
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Sunday, Nov. 16, 2008 05:34 pm
NovemberDobby writes...
Quote:
If I'm reading this right, you want to go thru all of the montrigs' targets and put them into an array?
That is exactly what I'd like to do.

Tried your code and it seems to think that "targets[ i ]" (without spaces) is a string cause it gives an error at that line with the marker pointing at it. Here's the function I've got so far.

Code:
monitorerror(monfx, monfx2)
{
 monErrored=false;

 while(!monErrored)
 {
  self waittill ("trigger");

  montrigs = getentarray("montrig","targetname");

  targets = [];
  for(i=0;i< montrigs.size;i++)
  {
   targets[targets.size] = montrigs[i].target;
  }

  for(i=0;i<targets.size;i++)
  {
   targets[i] SetModel("ch_icbm_consolemonitor1");
  }

  for(i=0;i<montrigs.size;i++)
  {
   montrigs[i] dobreak(monfx, monfx2);
  }

  monErrored=true;
  self delete();
 }
}


Scripting has never been my strong side but it seems that this should work, obviously it doesn't but I've got the feeling it's just something minor. Thanks by the way.
Share |
novemberdobby
General Member
Since: Sep 17, 2006
Posts: 1965
Last: Oct 13, 2013
[view latest posts]
Level 8
Forum Moderator
Category: CoD4 Scripting
Posted: Sunday, Nov. 16, 2008 06:13 pm
Which error is it? Also you could try replacing the two later i's with different letters, that can cause problems if you ever do an array in an array.

Code:

monitorerror(monfx, monfx2)
{
 monErrored=false;

 while(!monErrored)
 {
  self waittill ("trigger");

  montrigs = getentarray("montrig","targetname");

  targets = [];

  for(i=0;i< montrigs.size;i++)
   targets[targets.size] = montrigs[i].target;

  for(b=0;b<targets.size;b++)
   targets[b] SetModel("ch_icbm_consolemonitor1");

  for(c=0;c<montrigs.size;c++)
   montrigs[c] dobreak(monfx, monfx2);

  monErrored=true;
  self delete();
 }
}
Share |
Drapan
General Member
Since: May 9, 2004
Posts: 290
Last: Apr 18, 2009
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Sunday, Nov. 16, 2008 06:43 pm
"String is not an entity" is the error it's giving me. http://i118.photobucket.com/albums/o98/Drapan/stringisnotanentity2.jpg

Still getting the same error after changing the letters.

Share |
novemberdobby
General Member
Since: Sep 17, 2006
Posts: 1965
Last: Oct 13, 2013
[view latest posts]
Level 8
Forum Moderator
Category: CoD4 Scripting
Posted: Sunday, Nov. 16, 2008 06:54 pm
Got it - we were putting the target's (string) names into the targets[] array instead of the actual entities:

Code:

monitorerror(monfx, monfx2)
{
 monErrored=false;

 while(!monErrored)
 {
  self waittill ("trigger");

  montrigs = getentarray("montrig","targetname");

  targets = [];

  for(i=0;i< montrigs.size;i++)
   targets[targets.size] = getent(montrigs[i].target, "targetname");

  for(b=0;b<targets.size;b++)
   targets[b] SetModel("ch_icbm_consolemonitor1");

  for(c=0;c<montrigs.size;c++)
   montrigs[c] dobreak(monfx, monfx2);

  monErrored=true;
  self delete();
 }
}

Share |
Drapan
General Member
Since: May 9, 2004
Posts: 290
Last: Apr 18, 2009
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Sunday, Nov. 16, 2008 07:35 pm
Thanks alot! Works like a charm!

Here's the final result http://www.xfire.com/video/436a7/
Share |
novemberdobby
General Member
Since: Sep 17, 2006
Posts: 1965
Last: Oct 13, 2013
[view latest posts]
Level 8
Forum Moderator
Category: CoD4 Scripting
Posted: Sunday, Nov. 16, 2008 07:51 pm
Hahaha, that's genius! [rocking]

By the way, how did you get such good quality sound recording from cod4? Mine is always muffled...did you have to set something up specially or is it just like that?

edited on Nov. 16, 2008 02:56 pm by NovemberDobby
Share |
Drapan
General Member
Since: May 9, 2004
Posts: 290
Last: Apr 18, 2009
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Sunday, Nov. 16, 2008 08:06 pm
Didn't do anything in particular except turning the volume up (in windows) like crazy, first few recordings was barely had any sound at all, could just hear something off in a distance.

You can shoot and break the monitors, the montrigs is the damage triggers for that breakage.

edited on Nov. 16, 2008 03:06 pm by Drapan
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 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

»