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

Members Online

»
0 Active | 13 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 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: How to add a script
zanakinz
General Member
Since: Apr 11, 2010
Posts: 17
Last: May 11, 2010
[view latest posts]
Level 1
Category: CoD4 MP Mapping
Posted: Tuesday, May. 11, 2010 04:55 pm
How do i add a script.. (not brushmodel but like pure C++ coding..) its a big list of a script...
Code:

main(){	thread self_closing_doors();}self_closing_doors(){	doors = getentarray("door_trig","targetname");	for(i=0; i<doors.size; i++)	{		doors[i] thread door_think();	}}door_think(){	self.doormoving = false;	self.doormodel = getent(self.target, "targetname");	while(1)	{		self waittill("trigger");		if(!self.doormoving)		{			self thread door_move();		}	}}door_move(){	self maps\mp\_utility::triggerOff();	self.doormoving = true;	self.doormodel playsound("metal_open");	self.doormodel rotateyaw(self.count, 2, 0.5, 0.5);	self.doormodel waittill("rotatedone");	wait (5);	self.doormodel playsound("metal_close");	self.doormodel rotateyaw((self.count * -1), 2, 0.5, 0.5);	self.doormodel waittill("rotatedone");	self maps\mp\_utility::triggerOn();	self.doormoving = false;}
Share |
Xylozi
General Member
Since: Jul 12, 2008
Posts: 218
Last: Mar 1, 2012
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD4 MP Mapping
Posted: Tuesday, May. 11, 2010 05:13 pm
If this is for a map, then you'll need to add it to your map's .gsc file, like this:

Code:

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

	maps\mp\_compass::setupMiniMap( "compass_map_mp_mapname" );

	game["allies"] = "marines";
	game["axis"] = "opfor";
	game["attackers"] = "axis";
	game["defenders"] = "allies";
	game["allies_soldiertype"] = "desert";
	game["axis_soldiertype"] = "desert";
	
	setdvar( "r_specularcolorscale", "2" );
	
	setdvar( "compassmaxrange", "1800" );
	
	thread SetupMovingDoors();
}

SetupMovingDoors()
{	
	doors = getEntArray( "door_trig", "targetname" );	
	
	for( i = 0; i < doors.size; i++ )	
	{		 
		doors[i] thread DoorLogic();	
	}
}

DoorLogic()
{	
	self.doorMoving = false;	
	self.doormodel = getEnt( self.target, "targetname" );	
	
	while(1)
	{		
		self waittill( "trigger" );		
		
		if( !self.doorMoving )		
		{			
			self thread MoveDoor( self.doormodel );		
		}	
	}
}

MoveDoor( door )
{	
	self maps\mp\_utility::triggerOff();	
	
	self.doormoving = true;	
	
	door playSound( "metal_open" );	
	door rotateYaw( self.count, 2, 0.5, 0.5 );	
	door waittill( "rotatedone" );
	
	wait(5);	
	
	door playSound( "metal_close" );	
	door rotateYaw( (self.count * -1), 2, 0.5, 0.5 );
	door waittill( "rotatedone" );	
	
	self maps\mp\_utility::triggerOn();	
	
	self.doormoving = false;
}
Share |
zanakinz
General Member
Since: Apr 11, 2010
Posts: 17
Last: May 11, 2010
[view latest posts]
Level 1
Category: CoD4 MP Mapping
Posted: Tuesday, May. 11, 2010 05:17 pm
okay i did and now im getting when im compiling reflections...
Code:
Script compile error
Bad syntax
maps/mp/mp_(MAPNAME)::main();
(See console for details)


I blocked out my map name.. just incase..
Share |
{PADZ}grimreaper
General Member
Since: Apr 23, 2005
Posts: 334
Last: Aug 11, 2011
[view latest posts]
Level 5
Category: CoD4 MP Mapping
Posted: Tuesday, May. 11, 2010 06:24 pm
Open your console (shift ~) and see where the * is in your script. The * indicates where the syntax error is.
Share |
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 MP Mapping
Posted: Tuesday, May. 11, 2010 07:09 pm
Xylozi writes...
Quote:
If this is for a map, then you'll need to add it to your map's .gsc file, like this:



I wouldn't do that, but that's just me. SP maybe but MP, you should keep all your scripts separate from each other, including the map's .gsc file.

There are plenty of tuts on here for adding new scripts to maps.

Quote:
The error is probably because he copied and pasted into the map's gsc file and now has too many brackets.
Share |
Xylozi
General Member
Since: Jul 12, 2008
Posts: 218
Last: Mar 1, 2012
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD4 MP Mapping
Posted: Tuesday, May. 11, 2010 09:18 pm
Well there is little reason to split different functions into new files, unless your adding lots of new functions/systems and need to organise it.
Share |
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 MP Mapping
Posted: Wednesday, May. 12, 2010 06:38 am
Xylozi writes...
Quote:
Well there is little reason to split different functions into new files, unless your adding lots of new functions/systems and need to organise it.


Yes, and I agree, but I learned here quickly that starting that way and putting other scripts into the map's .gsc file just creates clutter. Not only that, it is much easier to add a self contained script as in (its own separate .gsc file) than to try and add a new function into the map's .gsc file just to debug the problem errors.

A map's .gsc file is built for certain functions. Defining certain things. If you create a separate script just to handle your doors, you can create a boundary between the rest of your work, and your doors, instead of clutter for the future as your map grows and develops.

The problem is, you get in the habit of adding extra things to your maps .gsc file when really they should be kept organised and separated.

Would you rather debug 100 lines of code or 20? [duh] I would rather have my errors contained in separate files than clutter all up in one. [crazy]
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

»