elevator script???

Have questions about CoD/UO mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
orestis5
CJ Wannabe
CJ Wannabe
Posts: 27
Joined: September 28th, 2010, 7:24 pm

elevator script???

Post by orestis5 » October 2nd, 2010, 8:56 am

hello guys i need help with creating an elevator.i created a script>brushmodel then i pressed n and write key:targetname
value:elevator

afterward i created a script and i putted this:

main()
{
thread elevator();
}

elevator()
{
elevator=getent("elevator","targetname")­;
trig=getent("trig_elevator","targetname"­);
while(1)
{
trig waittill ("trigger");
elevator movez (555,7,1.9,1.9);
elevator waittill ("movedone");
wait(1);
elevator movez (-555,7,1.9,5);
elevator waittill ("movedone");
}
}

and i had created a mapname.gsc and i wrote this:

main()
{
maps\mp\_load::main();

setExpFog(0.0001, 0.55, 0.6, 0.55, 0);
// setCullFog(0, 16500, 0.55, 0.6, 0.55, 0);
ambientPlay("ambient_france");

game["allies"] = "american";
game["axis"] = "german";
game["attackers"] = "allies";
game["defenders"] = "axis";
game["american_soldiertype"] = "normandy";
game["german_soldiertype"] = "normandy";

setCvar("r_glowbloomintensity0", ".25");
setCvar("r_glowbloomintensity1", ".25");
setcvar("r_glowskybleedintensity0",".3") ;

maps\mp\elevator::main();




}
when i run the map im getting a script compile error.any ideas????thanks for reading

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: elevator script???

Post by megazor » October 2nd, 2010, 2:57 pm

in the game console, do:

Code: Select all

developer 1
map NameOfYouRMap
after the error appeared, open the game console - u will see there a message about the cause of the error.

Pedsdude
Site Admin
Site Admin
Posts: 15908
Joined: October 15th, 2004, 7:18 pm
Location: UK

Re: elevator script???

Post by Pedsdude » October 2nd, 2010, 3:00 pm

I would personally recommend placing all your scripting in one gsc file, not spread over multiple files.

Code: Select all

main()
{

maps\mp\_load::main();

setExpFog(0.0001, 0.55, 0.6, 0.55, 0);
// setCullFog(0, 16500, 0.55, 0.6, 0.55, 0);
ambientPlay("ambient_france");
game["allies"] = "american";
game["axis"] = "german";
game["attackers"] = "allies";
game["defenders"] = "axis";
game["american_soldiertype"] = "normandy";
game["german_soldiertype"] = "normandy";
setCvar("r_glowbloomintensity0", ".25");
setCvar("r_glowbloomintensity1", ".25");
setcvar("r_glowskybleedintensity0",".3") ;

thread elevator();

}

elevator()
{
elevator=getent("elevator","targetname")­;
trig=getent("trig_elevator","targetname"­);
while(1)
{
trig waittill ("trigger");
elevator movez (555,7,1.9,1.9);
elevator waittill ("movedone");
wait(1);
elevator movez (-555,7,1.9,5);
elevator waittill ("movedone");
}
}
Also, try and use targetnames that aren't likely to conflict with targetnames in other people's maps (e.g. call 'elevator', 'mymap_elevator' for example).

I'm guessing you actually made a trigger for trig_elevator? (you didn't mention so in your post)

What is the script compile error? (it should say in console, if not then turn developer on and try again)
Image
Image

orestis5
CJ Wannabe
CJ Wannabe
Posts: 27
Joined: September 28th, 2010, 7:24 pm

Re: elevator script???

Post by orestis5 » October 3rd, 2010, 8:09 am

well i had already check the console and it was writing<<unexpected end of file>>thnx for the answers

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: elevator script???

Post by megazor » October 3rd, 2010, 12:26 pm

it must have written the number of the wrong string. unexpected end usually means you have missed a '}'.

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: elevator script???

Post by <LT>YosemiteSam[NL] » October 3rd, 2010, 12:59 pm

I use this elevator script with CoD2 (probably works with CoD aswell)
With this script the elevator also goes back up when a player is standing underneath it and gets hit.
Feel free to use it and change the x,y,z and brush/sound names stuff accordingly.

Code: Select all

main(){

   thread elevator_init();
}

elevator_init(){
   
   // elevator 1
   thread elevator_start(getent ("elevatorright_base", "targetname"), 
                     getent ("elevatorright", "targetname"), 
                     getent ("elevatorhit", "targetname"), 
                     getent ("speaker_one", "targetname"),
                     "elevator1_hit_player");
}

elevator_start(elevator, move_trig, hit_trig, speaker, elendon){
   
   move_trig enablelinkto();
   move_trig linkto(elevator);
   
   hit_trig enablelinkto();
   hit_trig linkto(elevator);
   
   
   thread elevator(elevator, move_trig, speaker, elendon);
   thread elevator_hit(elevator, move_trig, hit_trig, speaker, elendon);
}

elevator(elevator, move_trig, speaker, elendon){

   level endon(elendon);

     // if we are already at this position it the elevator won't move
      elevator moveTo((-128, 2128, 10), 1.4); 
      if(elevator.origin != (-128, 2128, 10))
      speaker playsound ("elevator_move");      
      elevator waittill("movedone");
      speaker playsound ("elevator_stop");

   while(1)
   {
      

      move_trig waittill("trigger");
      elevator moveTo((-128, 2128, 298), 1.4);
      speaker playsound ("elevator_move");      
      elevator waittill("movedone");
      speaker playsound ("elevator_stop");      
      wait 2;
      elevator moveTo((-128, 2128, 10), 1.4);   
      speaker playsound ("elevator_move");
      elevator waittill("movedone");
      speaker playsound ("elevator_stop");
   }
}

elevator_hit(elevator, move_trig, hit_trig, speaker, elendon){
   // all elevator parts and triggers
   
   while(1)
   {
      hit_trig waittill("trigger");
      level notify(elendon);
      elevator moveTo((-128, 2128, 298), 1.4);
      speaker playsound ("elevator_move");
      elevator waittill("movedone");
      speaker playsound ("elevator_stop");
wait 2;

      thread elevator(elevator, move_trig, speaker, elendon);
      wait 0.5;
}   
}

orestis5
CJ Wannabe
CJ Wannabe
Posts: 27
Joined: September 28th, 2010, 7:24 pm

Re: elevator script???

Post by orestis5 » October 4th, 2010, 12:49 pm

thnx cj :lol: :D :o

CoDgh0st
CJ Wannabe
CJ Wannabe
Posts: 3
Joined: September 14th, 2011, 12:10 am

Re: elevator script???

Post by CoDgh0st » October 17th, 2011, 5:15 pm

I know this is pretty much a dead topic now, but I wanted to point out what I see for anyone searching for this. The original script has more than one main() function, which isn't allowed unless I'm mistaken. I don't have time to test to see if this works, but I'm sure that would cause an error.

If I get time to test I'll be back to post the results.

Pedsdude
Site Admin
Site Admin
Posts: 15908
Joined: October 15th, 2004, 7:18 pm
Location: UK

Re: elevator script???

Post by Pedsdude » October 17th, 2011, 7:12 pm

It was technically two .gsc files, so I think it was OK.
Image
Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: elevator script???

Post by Drofder2004 » October 18th, 2011, 12:22 am

Indeed, as long as the functions are in separate files and you do not use an "include", then that is fine.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest