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

Members Online

»
0 Active | 5 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: How can I reference an entire array of objects in a script
bNasty
General Member
Since: Feb 26, 2008
Posts: 94
Last: Feb 18, 2009
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Monday, Jun. 23, 2008 05:46 am
I have the following
myobjs = getentarray("myobj","targetname");

Now what I need to do is move the entire array at once, I was thinking something like this, but doesn't work. [banghead]

myobjs[] movex (50, 1); -or- myobjs movex(50,1);

any help would be appreciated greatly.
Share |
The_Caretaker
General Member
Since: Jun 8, 2004
Posts: 11625
Last: Jul 7, 2009
[view latest posts]
Level 10
Category: CoD4 Scripting
Posted: Monday, Jun. 23, 2008 06:47 am
Code:
for (k=0;k<myobjs.size;k++)
{
   myobjs[k] movex(50,1);
}



edited on Jun. 23, 2008 05:54 am by The_Caretaker
Share |
bNasty
General Member
Since: Feb 26, 2008
Posts: 94
Last: Feb 18, 2009
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Monday, Jun. 23, 2008 09:04 pm
thanks for the reply Cartaker,

I tried that but only one entity moved. Here is the script I setup based on your suggestion.
Code:
moveojbs()

{
myobjs = getentarray("myobj","targetname");
for(k=0;k<myobjs.size;k++)
while(1)
{
wait 3;
   myobjs[k] movex(50,0.01);
   myobjs[k] waittill("movedone");

wait 2;
   myobjs[k] movex(-50,0.01);
   myobjs[k] waittill("movedone");
}
}
Share |
codmp
General Member
Since: Feb 7, 2006
Posts: 905
Last: Aug 1, 2011
[view latest posts]
Level 7
Category: CoD4 Scripting
Posted: Monday, Jun. 23, 2008 09:29 pm
Try something like this:
Code:

moveojbs()

{
myobjs = getentarray("myobj","targetname");

while(1)
{
		for(k=0;k<myobjs.size;k++)
		{
		
   			myobjs[k] movex(50,0.01);
   			myobjs[k] waittill("movedone");

			wait 2;
   			myobjs[k] movex(-50,0.01);
   			myobjs[k] waittill("movedone");
		
		}
}

}



In your code above, it looks like the for loop runs through once, then goes into the while loop, which then keeps on looping. Because of that, you have only defined one of the objects in the array.
Share |
marcp22
General Member
Since: May 14, 2005
Posts: 76
Last: Jul 15, 2008
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Monday, Jun. 23, 2008 09:34 pm
if you want the entire array to mave as one object which is what i got from what you said your really better off making it as one brush model... but try this

Code:
moveojbs()
{
myobjs = getentarray("myobj","targetname");
wait 3;
for(k=0;k<myobjs.size;k++)
{
   myobjs[k] movex(50,0.01);
   if(k=myobjs.size)
	{
		myobjs[k] waittill("movedone")
	}
}
wait 2;
for(k=0;k<myobjs.size;k++)
{
   myobjs[k] movex(-50,0.01);
   if(k=myobjs.size)
	{
		myobjs[k] waittill("movedone")
	}
   
}
}
Share |
bNasty
General Member
Since: Feb 26, 2008
Posts: 94
Last: Feb 18, 2009
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Monday, Jun. 23, 2008 11:05 pm
Thanks guys, works like a charm. [jumping]

The reason I don't have it as a single brush model is that I have these entities built as a prefab, and I didnt want to tear that apart and add the part seperately.

I appreciate the help greatly.
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

»