elevator script???
Moderator: Core Staff
elevator script???
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
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
Re: elevator script???
in the game console, do:
after the error appeared, open the game console - u will see there a message about the cause of the error.
Code: Select all
developer 1
map NameOfYouRMap
Re: elevator script???
I would personally recommend placing all your scripting in one gsc file, not spread over multiple files.
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)
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");
}
}
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)


Re: elevator script???
well i had already check the console and it was writing<<unexpected end of file>>thnx for the answers
Re: elevator script???
it must have written the number of the wrong string. unexpected end usually means you have missed a '}'.
-
- Core Staff
- Posts: 2155
- Joined: December 7th, 2004, 2:07 am
- Location: Netherlands
- Contact:
Re: elevator script???
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.
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;
}
}
Re: elevator script???
thnx cj




Re: elevator script???
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.
If I get time to test I'll be back to post the results.
-
- Core Staff
- Posts: 13315
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: elevator script???
Indeed, as long as the functions are in separate files and you do not use an "include", then that is fine.

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
Who is online
Users browsing this forum: No registered users and 1 guest