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

Members Online

»
0 Active | 6 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: Elevator
WACThriller93
General Member
Since: Oct 5, 2008
Posts: 20
Last: Oct 30, 2009
[view latest posts]
Level 1
Category: CoD4 Scripting
Posted: Tuesday, Jun. 9, 2009 01:19 am
Ok well here's the deal. I put an elevator in my map, It works great map loads everything looks good
it goes up when you push the up and down when you push down. But here comes the problem. When the elevator is at the bottom and u push the button it goes up. But when you push it again instead of coming back down it keeps going up out of the shaft same thing with the down button at the top if you push it it goes down and if you push it again it keeps going down below the map.

elevator script

main()
{
thread elevator_up();
thread elevator_down();
}

elevator_up()
{
elevator = getent("elevator","targetname");
up = getent("up","targetname");

while(1)
{
up waittill ("trigger");
wait 2;
elevator moveZ (775,8,2,2);
elevator waittill ("movedone");
}
}

elevator_down()
{
elevator = getent("elevator","targetname");
down = getent("down", "targetname");

while(1)
{
down waittill ("trigger");
wait 2;
elevator moveZ (-776,8,2,2);
elevator waittill ("movedone");
}
}
Share |
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Tuesday, Jun. 9, 2009 05:54 am
If you want to try a script a little easier, give this one a try instead of the one you've got.

When you make your elevator, obviously make sure all the parts (parts that move as elevator) are all one script_brushmodel. When you make your trigger, or triggers, give them both the same targetname of "elevator", just like in the script.

The only thing that has a targetname is the trigger. Make sure you select the trigger then elevator script_brushmodels and press (W) to link them.

Anyways, here is the script.

Code:
main()
{
	thread elevator();
}

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

elevator_think()
{
	level.elevator_currentstation = 1;
	self.elevator_maxstations = 2;
	self.elevator_moving = false;
	self.elevator_model = getent(self.target, "targetname");

	while (1)
	{
		self waittill("trigger");
		maps\mp\_utility::triggerOff();
		if(!self.elevator_moving)
		{
			self thread elevator_move();
		}
	}
}

elevator_move()
{
	self.elevator_moving = true;
	self.elevator_model playsound ("elevator");
	if (level.elevator_currentstation == 1)
	{
		wait (2);
		self.elevator_model movez(775, 8, 2, 2);	//move elevator to top floor
	}
	if (level.elevator_currentstation == 2)
	{
		wait (2);
		self.elevator_model movez(-776, 8, 2, 2);	//move elevator back to bottom floor
	}
	level.elevator_currentstation++;
	if (level.elevator_currentstation > self.elevator_maxstations)
	{
		level.elevator_currentstation = 1;
	}
	self.elevator_model waittill("movedone");
	maps\mp\_utility::triggerOn();
	self.elevator_moving = false;
}


Made it so trigger disappears during elevator move. If you have two triggers, and they both need to be hidden during elevator move, then make sure you have both selected when you create them as triggers, so the game see's them as one entity.

Added in your two wait(2) times, not sure what you had those for, and also your current coordinates of movement. If you don't have a sound set up, you might want to comment out that line there I have to play sound.

// self.elevator_model playsound ("elevator");

I hope it helps. If you have trouble with it I'll check back here and there.
Share |
WACThriller93
General Member
Since: Oct 5, 2008
Posts: 20
Last: Oct 30, 2009
[view latest posts]
Level 1
Category: CoD4 Scripting
Posted: Tuesday, Jun. 9, 2009 10:12 pm
script errror
http://screenshot.xfire.com/screenshot/natural/02962ec74a3affcdd3c8fee9c45a838abc22d376.png

edited on Jun. 9, 2009 06:19 pm by WACThriller93
Share |
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Tuesday, Jun. 9, 2009 11:12 pm
You need to select all your Elevator parts. You can do this by holding Alt+shift+left click. It Selects a group of Brushes, in this case a group of script_brushmodels.

If they still had the old targetname, they need to be reset.

While they are selected, right click 2D window to ungroup them, (Ungroup) then while still selected make them a script_brushmodel once again.

After that, take your trigger/triggers and link them once again to the brushmodels.

I've made many elevators and moving objects using this script so I assume it is how you set it up. The error is looking at the elevator model, which are the script_brushmodels.

Try that and let me know if you get it solved.
Share |
WACThriller93
General Member
Since: Oct 5, 2008
Posts: 20
Last: Oct 30, 2009
[view latest posts]
Level 1
Category: CoD4 Scripting
Posted: Tuesday, Jun. 9, 2009 11:44 pm
I fixed it
Share |
RAMIDUS
General Member
Since: Aug 24, 2006
Posts: 91
Last: Nov 17, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Tuesday, Sep. 1, 2009 03:01 pm
Hi, I'm making a very deep coal mine with elevator into it. At first I tried single "movez" command to single way down, but it didnt work - bad syntax...bad token...blah blah blah.
So I decided to get working, precious syntax from here - sorry for copying.

Now's the problem: When loading the map, it freezes and gives the error: unknown function: raw/maps/_laststand.gsc. I don't get why it complaints about the file which is even not mentioned in the script.
I tried to delete that file. It really wasn't necessary for running the map, because it gave other error[biggrin]:

Error: unknown function: maps/mp/gametypes/_hud_util.gsc
font Elem = newHudElem (team);

Surprisingly, I didn't succeed with deleting this one, too [biggrin]...why is it needed for my map? I have never came across this stuff before...so why now?
Starting to be fed up with WaW mapping...sometimes I feel like rubbing my left ear by my right hand...[sad]


Share |
RAMIDUS
General Member
Since: Aug 24, 2006
Posts: 91
Last: Nov 17, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Tuesday, Sep. 1, 2009 07:32 pm
I only restarted my PC and the situation changed: it says: bad syntax on line 22, which is this one:

Quote:
self.elevator_maxstations = 2;
I can't understand whyt has changed since the last restart, that that problem with stock gsc file is gone and replaced with this...
Share |
WACThriller93
General Member
Since: Oct 5, 2008
Posts: 20
Last: Oct 30, 2009
[view latest posts]
Level 1
Category: CoD4 Scripting
Posted: Tuesday, Sep. 1, 2009 10:22 pm
can you post all your scripts and your contents of the zone file.
Share |
RAMIDUS
General Member
Since: Aug 24, 2006
Posts: 91
Last: Nov 17, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Wednesday, Sep. 2, 2009 04:19 am
mine.gsc:

Code:
#include maps\_utility; 

#include common_scripts\utility;

#using_animtree("generic_human"); 

main()
{
	thread elevator();
}

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

elevator_think()
{
	level.elevator_currentstation = 1;
	self.elevator_maxstations = 2;
	self.elevator_moving = false;
	self.elevator_model = getent(self.target, "targetname");
	while(1)	
	
	{
		self waittill("trigger");
		maps\mp\_utility::triggerOff();
		if(!self.elevator_moving)
		{
			self thread elevator_move();
		}
	}
}

elevator_move()
{
	self.elevator_moving = true;
	self.elevator_model playsound ("elevator");
	if (level.elevator_currentstation == 1)
	{
		wait (1);
		self.elevator_model movez(24572,60,10,5);	//move elevator to top floor
	}
	if (level.elevator_currentstation == 2)
	{
		wait (1);
		self.elevator_model movez(-24572,60,10,5);	//move elevator back to bottom floor
	}
	level.elevator_currentstation++;
	if (level.elevator_currentstation > self.elevator_maxstations)
	{
		level.elevator_currentstation = 1;
	}
	self.elevator_model waittill("movedone");
	maps\mp\_utility::triggerOn();
	self.elevator_moving = false;
}


mine_amb.gsc:

Code:
#include common_scripts\utility; 

#include maps\_utility;

#include maps\_ambientpackage;

#include maps\_music;

#include maps\_busing;

main()
{
}


mine_anim.gsc:

Code:
#include common_scripts\utility; 

#include maps\_utility; 

#include maps\_anim; 

#using_animtree( "generic_human" ); 
main()
{
	// Example Anim
	// level.scr_anim["intro_officer"]["intro"] = %ch_makinraid_intro_officer_a; 
}


mine_fx.gsc:

Code:
#include maps\_utility; 

main()
{
	// Example FX
	// level._effect["cigarette"] = LoadFx( "maps/mak/fx_cigarette_smoke" );
}


zone file:

Code:
ignore	code_post_gfx
ignore	common
// map specific files	
col_map_sp	maps/mine.d3dbsp
gfx_map	maps/mine.d3dbsp
rawfile	maps/mine.gsc
rawfile	maps/mine_amb.gsc
rawfile	maps/mine_anim.gsc
rawfile	maps/mine_fx.gsc
// Weapons	
weapon	sp/m1garand
weapon	sp/colt
weapon	sp/fraggrenade
weapon	sp/m8_white_smoke
// Viewarms	
xmodel	viewmodel_usa_marine_arms
xmodel	viewmodel_usa_marine_player
// 3rd person model	
include	common_player_us
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

»