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

Members Online

»
0 Active | 93 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

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 MP Mapping
CoD 4 mapping and level design for multiplayer.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: Scripting Help!!!
somedude
General Member
Since: Aug 3, 2005
Posts: 53
Last: Mar 26, 2008
[view latest posts]
Level 3
Category: CoD4 MP Mapping
Posted: Tuesday, Mar. 25, 2008 09:47 pm
Ok, well i made an elevator for my map and it has two triggers for it to work, its pretty simple, but i keep getting an error saying array is not an object, i know why, because im using getentarray, but if i change getentarray to getent it will give me another error saying that i used getent with multiple entities. What can i use then? Here is my script (dont laugh):

Code:
elevator1()

{
elevatormodel = getent ("elevatorcar", "targetname");
elevatordoorminusy = getent ("doorminusy", "targetname");
elevatordoorplusy = getent ("doorplusy", "targetname");
elevatorlights = getent ("elevatorlight", "targetname");
elevatortrigger = getent ("elevatorswitch", "targetname");
while (1)
{
elevatortrigger waittill ("trigger");
wait 3;
elevatordoorminusy movey (-30, 1.5);
elevatordoorplusy movey (30, 1.5);
wait 6.5;
elevatordoorminusy movey (30, 1.5);
elevatordoorplusy movey (-30, 1.5);
wait 3.5;
elevatormodel movez (3680, 12);
elevatordoorminusy movez (3680, 12);
elevatordoorplusy movez (3680, 12);
elevatorlights movez (3680, 12);
wait 14;
elevatordoorminusy movey (-30, 1.5);
elevatordoorplusy movey (30, 1.5);
wait 6.5;
elevatordoorminusy movey (30, 1.5);
elevatordoorplusy movey (-30, 1.5);
wait 3.5;
elevatormodel movez (-3680, 5);
elevatordoorminusy movez (-3680, 5);
elevatordoorplusy movez (-3680, 5);
elevatorlights movez (-3680, 5);
wait 7;
}
}


Help please!
Share |
SpeedHighway
General Member
Since: Apr 30, 2005
Posts: 494
Last: Apr 9, 2008
[view latest posts]
Level 5
Category: CoD4 MP Mapping
Posted: Tuesday, Mar. 25, 2008 11:36 pm
Okay, need more information

How many elevators do you have?
That would be the only reason you should have multiple entities under the same name. If you have more than one entity for the same name and it's all one elevator, then I'll help with that, if it's something else, we need to determine that.

Looking at this example, you definitely do not want to be using getentarray (unless you have multiple elevators)

You said you have more than one switch? That's the part where you need to use getentarray. But it's not a magic button, if you use an array, you need to rewrite a bit of the code.

What line are you getting an error on?

Is this example of code what you're talking about, because there's no getentarray in the entire thing.

:)

edited on Mar. 25, 2008 07:38 pm by SpeedHighway
Share |
somedude
General Member
Since: Aug 3, 2005
Posts: 53
Last: Mar 26, 2008
[view latest posts]
Level 3
Category: CoD4 MP Mapping
Posted: Wednesday, Mar. 26, 2008 02:06 am
yeah i copy pasted the code i was trying to work with, here is where i have getentarray


Code:
elevator1()

{
elevatormodel = getent ("elevatorcar", "targetname");
elevatordoorminusy = getent ("doorminusy", "targetname");
elevatordoorplusy = getent ("doorplusy", "targetname");
elevatorlights = getent ("elevatorlight", "targetname");
elevatortrigger = getentarray ("elevatorswitch", "targetname");
while (1)
{
elevatortrigger waittill ("trigger");
wait 3;
elevatordoorminusy movey (-30, 1.5);
elevatordoorplusy movey (30, 1.5);
wait 6.5;
elevatordoorminusy movey (30, 1.5);
elevatordoorplusy movey (-30, 1.5);
wait 3.5;
elevatormodel movez (3680, 12);
elevatordoorminusy movez (3680, 12);
elevatordoorplusy movez (3680, 12);
elevatorlights movez (3680, 12);
wait 14;
elevatordoorminusy movey (-30, 1.5);
elevatordoorplusy movey (30, 1.5);
wait 6.5;
elevatordoorminusy movey (30, 1.5);
elevatordoorplusy movey (-30, 1.5);
wait 3.5;
elevatormodel movez (-3680, 5);
elevatordoorminusy movez (-3680, 5);
elevatordoorplusy movez (-3680, 5);
elevatorlights movez (-3680, 5);
wait 7;
}
}


i get the error at: elevatortrigger = getentarray ("elevatorswitch", "targetname");

I only have one elevator, two triggers.


edited on Mar. 25, 2008 10:09 pm by somedude
Share |
SpeedHighway
General Member
Since: Apr 30, 2005
Posts: 494
Last: Apr 9, 2008
[view latest posts]
Level 5
Category: CoD4 MP Mapping
Posted: Wednesday, Mar. 26, 2008 03:14 pm
Okay, if you have more than one trigger, you're going to have to put everything in a function. The problem with this is that it becomes a pain to make sure both triggers can't be hit at the same time. (Why do you have 2 triggers when you have the elevator move, wait, then move?)

I can jot down something to help if that's what you need, but first I should know if you seriously even want 2 triggers. If you do, then the logic of your script will need an overhaul =D. Let me know what I can do to help. :)
Share |
sudswu
General Member
Since: Mar 19, 2008
Posts: 104
Last: Sep 5, 2010
[view latest posts]
Level 4
Category: CoD4 MP Mapping
Posted: Wednesday, Jul. 23, 2008 06:55 pm
mind if i jump in here? i have an elevator question too...hopefully and easy one and we all like a tidy forum :)

i want to have 2 elevators...no doors or anything...i have one working but cant get a second one to trigger....

what do i need to do for the second script + targetnames?

here is the first...a direct copy and paste from cod tutorials (remember to look there for cod4 tips too :) )

Code:
main() {
level.elevatorDown = true; // elevator starts at bottom: true/false
level.elevatorMoving = false; // elevator is not currently moving
thread elevator_start();
}

elevator_start() {
elevator = getentarray ("elevatorswitch","targetname");
if ( isdefined(elevator) )
for (i = 0; i < elevator.size; i++)
elevator[i] thread elevator_think();
}

elevator_think() {
while (1) {
self waittill ("trigger");
if (!level.elevatorMoving)
thread elevator_move();
}
}

elevator_move() {
elevatormodel = getent ("elevatormodel", "targetname");
level.elevatorMoving = true;
speed = 8;
height = 1330;
wait (1);
if (level.elevatorDown) { // moves to top
elevatormodel playsound ("elevator1"); // sound definition for soundaliases.csv
wait (1); // wait a second to hear the motor start and then start the movement of the lift - feels more realistic
elevatormodel moveZ (height, speed);
elevatormodel waittill ("movedone");
level.elevatorDown = false;
}
else { // moves to bottom
elevatormodel playsound ("elevator1"); // sound definition for soundaliases.csv
wait (1);  // wait a second to hear the motor start and then start the movement of the lift - feels more realistic
elevatormodel moveZ (height - (height * 2), speed);
elevatormodel waittill ("movedone");
level.elevatorDown = true;
}
level.elevatorMoving = false;
}
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 MP Mapping

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

»