More than 2 .gsc?

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

Moderator: Core Staff

Post Reply
Creazeee
CJ Wannabe
CJ Wannabe
Posts: 8
Joined: February 18th, 2012, 2:49 am

More than 2 .gsc?

Post by Creazeee » March 15th, 2012, 8:43 pm

Is it possible to have more than 1 .gsc files in the map? I tried setting one as teleporter.gsc and mp_[mapname].gsc. The teleporter.gsc doesn't work. When I tried switching them, the teleporter it started to work, but the other script didn't. So do I have to put it as one .gsc file? I am putting 10 teleporters and one rotate brushmodel in my map. Could someone give me the script? :S


Nvm, I just didn't add this line to my .gsc file.


maps\mp\teleport::main();


-.-'

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

Re: More than 2 .gsc?

Post by Pedsdude » March 15th, 2012, 9:03 pm

I just have all my scripting in one file anyway - less can go wrong.
Image
Image

ekat
CJ Newbie
CJ Newbie
Posts: 53
Joined: September 15th, 2010, 4:56 pm

Re: More than 2 .gsc?

Post by ekat » March 15th, 2012, 9:08 pm

Try this:
thread maps\mp\teleport1::main();
thread maps\mp\teleport2::main();

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: More than 2 .gsc?

Post by Rezil » March 16th, 2012, 12:18 am

You can use multiple .gsc files. It depends on what you want to do with the code in the .gsc. My general practice is this:

- If you have code that is dependant on your map(say, a mini game that uses entities you placed in Radiant), you call the main function using:

Code: Select all

.iwd_path\.gsc_name::main_thread(optional_parameters);
For example:

Code: Select all

maps\mp\gametypes\_misc::foo();
- If your functions are more general(eg. you create a new HUD element for a player), you can actually include the .gsc before doing anything else:

Code: Select all

#include maps\mp\_utility; /*called before main()*/
This tells the engine to include everything from that .gsc file in the .gsc you called it in. Again, this is my way of doing things, it could be the wrong way but I haven't run into any problems with either method.
I just have all my scripting in one file anyway - less can go wrong.
This will work for most people, and is the best way of doing things if you don't have any complex code.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

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

Re: More than 2 .gsc?

Post by Drofder2004 » March 16th, 2012, 8:34 pm

Rezil wrote:

Code: Select all

#include maps\mp\_utility; /*called before main()*/
This tells the engine to include everything from that .gsc file in the .gsc you called it in. Again, this is my way of doing things, it could be the wrong way but I haven't run into any problems with either method.
This should only be used if you are calling the same functions repetitively.

Usually used for maths functions that dont exist in the engine and functions that create things (such as FX, HUD, etc)

The simplest example is databases.
It is quicker to return an entire array of information from a database in one search than it is to repeatably search for the same information many times.
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

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: More than 2 .gsc?

Post by IzNoGoD » March 17th, 2012, 12:59 am

Drofder2004 wrote:
Rezil wrote:

Code: Select all

#include maps\mp\_utility; /*called before main()*/
This tells the engine to include everything from that .gsc file in the .gsc you called it in. Again, this is my way of doing things, it could be the wrong way but I haven't run into any problems with either method.
This should only be used if you are calling the same functions repetitively.

Usually used for maths functions that dont exist in the engine and functions that create things (such as FX, HUD, etc)

The simplest example is databases.
It is quicker to return an entire array of information from a database in one search than it is to repeatably search for the same information many times.
Nah, it is optimized@compile time.

btw, OP stated that he solved the problem, even before the first reply...
LMGTFY!

Its not a glitch... Its the future!

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

Re: More than 2 .gsc?

Post by Drofder2004 » March 17th, 2012, 2:03 am

IzNoGoD wrote:Nah, it is optimized@compile time.

btw, OP stated that he solved the problem, even before the first reply...
So, there are no benefits or issues with using an #include instead of a direct call 'maps/mp/etc'?
If that is the case, why do we not simply include everything else in every file and never use a direct call again?

Surely the "include" is not just for a small amount of character saving convenience?

Also, jsut because the OP found a solution, does not mean the OP knew about all the possible solutions.
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 38 guests