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

Members Online

»
0 Active | 61 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
Category: CoDUO Mapping
CoD United Offensive mapping and level design.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: script help needed plz
pallchrn
General Member
Since: Feb 12, 2004
Posts: 31
Last: Feb 16, 2010
[view latest posts]
Level 2
Category: CoDUO Mapping
Posted: Friday, Nov. 2, 2007 02:46 pm
ok what im having trouble with is one door + two triggers

i have tried copying the 1st trigger and giving the 2nd trigger the same targetname ( all i get is the door repeatadly going up and down)

as the triggers was opposite through the wall i tried making the trigger big to go through the wall for it to work. but as it touches a brush dosnt work.

therefore i thought i would script it.

so what i need is trigger 1 to activate (door goes up)
Or trigger 2 goes up if activate
trigger 2 OR trigger 1 for next sequence = triggered and goes down

so they kind of work with each other knowing if the door = up or down.

this is what i have so far
##################################
main()

{
thread electricdoor();
}




electricdoor()
{

trigger = getent("door_sequence_trigger", "targetname");
trigger waittill("trigger");
thread activate_the_door();
}
activate_the_door()
{
aufzug = getent("updowndoor", "targetname");
movingdoor = getent("doorsound", "targetname");
wait 1;
movingdoor playsound("gantrys");
aufzug moveZ(170, 5);
aufzug waittill("movedone");


thread electronicdoor2();
}

electronicdoor2()
{
trigger = getent("door_sequence_trigger", "targetname");

trigger waittill("trigger");
thread activate_the_door2();
}
activate_the_door2()
{

aufzug = getent("updowndoor", "targetname");
movingdoor = getent("doorsound", "targetname");

wait 1;
movingdoor playsound("gantrys");
aufzug moveZ(-170, 5);
wait 1;


aufzug waittill("movedone");


thread electricdoor();
}
#####################################
trigger 2 is called "door_sequence_2"

but not added yet

any help will be appreciated. thankyou...
Share |
The_Caretaker
General Member
Since: Jun 8, 2004
Posts: 11625
Last: Jul 7, 2009
[view latest posts]
Level 10
Category: CoDUO Mapping
Posted: Friday, Nov. 2, 2007 05:15 pm
You can do it like this:

Add a global variable to tell if the door is moving (like in the elvator tutorial) level.doormoving=false

Then add a second function kinda like this

electronicdoor2b()
{
trigger = getent("door_sequence_trigger_2", "targetname");
trigger waittill("trigger");
if (!level.doormoving)
{
thread activate_the_door2();
}
}

And call it at the end of your activate_the_door function, just like you did with the electronicdoor2 function.
Do the same on your original electronicdoor2 function.

In your activate_the_door2 function add the line
level.doormoving=true at the beginning and level.doormoving=false at the end, to tell the game the door is moving or has finished.

Voila.. something like that should work.
Share |
playername
Preferred Member
Since: Aug 24, 2006
Posts: 821
Last: Apr 15, 2011
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoDUO Mapping
Posted: Friday, Nov. 2, 2007 07:25 pm
TC you didn't notice he didn't use getentarray...
Here you go
Code:

main()
{
thread electricdoor();
}

electricdoor()
{
level.doormoving=false;
level.doorup=false;

trigger = getentarray("door_sequence_trigger", "targetname"); //triggers

if(!isdefined(trigger)
	{
	iprintln("Trigger not found!");
	}
thread activate_the_door(trigger);
}

activate_the_door(other)
{

if(!level.doorup)
	{
	//if door is down, go up.
	other waittill("trigger");

	aufzug = getent("updowndoor", "targetname"); //door
	level.doormoving=true;
	movingdoor = getent("doorsound", "targetname"); //sound
	aufzug moveZ(170, 5);
	wait 1;
	movingdoor playsound("gantrys");
	aufzug waittill("movedone");
	level.doorup=ture;
	level.doormoving=false;
	}
else
	{
	//if door is up, go down.
	other waittill("trigger");

	aufzug = getent("updowndoor", "targetname"); //door
	level.doormoving=true;
	movingdoor = getent("doorsound", "targetname"); //sound
	aufzug moveZ(-170, 5);
	wait 1;
	movingdoor playsound("gantrys");
	aufzug waittill("movedone");
	level.doorup=false;
	level.doormoving=false;
	}
}


If that doesn't work let me go, I did this with coppy paste really fast.
nullFew tips for coding.
1. Keep the script as short as possible.
2. Don't comment every line. Only comment portions where they may be needed to point something out.
3. Don't over complicate the script, keep it organized and easy to read.

These help you find simple errors and makes it easy to make changes.
Share |
The_Caretaker
General Member
Since: Jun 8, 2004
Posts: 11625
Last: Jul 7, 2009
[view latest posts]
Level 10
Category: CoDUO Mapping
Posted: Friday, Nov. 2, 2007 08:18 pm
He doesn't need to use getentarray, because he gave the two triggers different names, door_sequence_trigger and door_sequence_2.
Share |
pallchrn
General Member
Since: Feb 12, 2004
Posts: 31
Last: Feb 16, 2010
[view latest posts]
Level 2
Category: CoDUO Mapping
Posted: Saturday, Nov. 3, 2007 11:22 am
thankyou i shall try and test after refixing my windows ;p
Share |
pallchrn
General Member
Since: Feb 12, 2004
Posts: 31
Last: Feb 16, 2010
[view latest posts]
Level 2
Category: CoDUO Mapping
Posted: Monday, Nov. 5, 2007 10:22 pm
i tried the script but got a bad syntax error
Share |
The_Caretaker
General Member
Since: Jun 8, 2004
Posts: 11625
Last: Jul 7, 2009
[view latest posts]
Level 10
Category: CoDUO Mapping
Posted: Tuesday, Nov. 6, 2007 01:53 am
"a syntax error" is not very helpful.. press the ~ key and get us the full error so we can work on the problem.

Also post the .gsc file you use so we can see the problem.
Share |
pallchrn
General Member
Since: Feb 12, 2004
Posts: 31
Last: Feb 16, 2010
[view latest posts]
Level 2
Category: CoDUO Mapping
Posted: Tuesday, Nov. 6, 2007 05:19 pm
I FINALLY GOT IT WORKING ;P

thx for all your help i shall post the script here: its the same as tutorial but has 2 working trigger simultanious


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

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

elevator_start2() {
elevator = getentarray ("door_trigger_2","targetname");
if ( isdefined(elevator) )
for (i = 0; i < elevator.size; i++)
elevator thread elevator_think();
}


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

elevator_move() {
elevatormodel = getent ("updowndoor", "targetname");
level.elevatorMoving = true;
speed = 2;
height = 170;
wait (1);
if (level.elevatorDown) { // moves to top
elevatormodel playsound ("gantryso"); // 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 ("gantryso"); // 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 |
pallchrn
General Member
Since: Feb 12, 2004
Posts: 31
Last: Feb 16, 2010
[view latest posts]
Level 2
Category: CoDUO Mapping
Posted: Tuesday, Nov. 6, 2007 05:21 pm
another problem

when the door comes down is there a way of adding a brush to stop ppl going underneath or hurt trigger to squash them?
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty : CoDUO 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

»