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

Members Online

»
0 Active | 10 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 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Previous Page Next Page
subscribe
Author Topic: Reading a file
Tally
General Member
Since: Apr 21, 2005
Posts: 819
Last: Oct 26, 2012
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Sunday, Aug. 19, 2012 08:14 pm
Groan, so looks like I'm going to have to prove it:

Here is a test video of my Domination gametype ported from COD4 to COD2, run on a LISTEN SERVER. It uses openFile( filename, "read" ) for both the location of the domination flags, and the start spawnpoints:



Here is the code for the startspawns:

Code:
init()
{
	if( !init_mapConfig() )
	{
		printLn( "^1No Start Spawns found in Level!" );
		level.startSpawns = false;
		return;
	}
}

init_mapConfig()
{
	startspawns = [];
	number = 0;
	
	filename = undefined;
	if( level.native )
		filename = "stock_startspawns.ini";
	else
		filename = "custom_startspawns.ini";
	
	file = OpenFile( filename, "read" );
	
	if( file == -1 )
		return( false );
	
	currentmap = false;
	for( ;; )
	{
		elems = freadln( file );
		
		if( elems == -1 )
			break;
			
		if( elems == 0 )
		{
			currentmap = false;
			continue;
		}
	
		line = "";
		for( pos = 0; pos < elems; pos++ )
		{
			line = line + fgetarg( file, pos );
			if( pos < elems - 1 )
				line = line + ",";
		}
		
		if( getSubStr( line, 0, 2 ) == "//" || getSubStr( line, 0, 1 ) == "#" )
			continue;
			
		array = strtok( line, " " );

		if( array[0] == getcvar( "mapname" ) )
		{
			currentmap = true;
			continue;
		}
		
		if( currentmap )
		{
			switch( array[0] )
			{
				case "startspawns":
					team = array[1];
					origin_str = getsubstr( array[2], 1 );
					origin_array = strtok( origin_str, "," );
					origin = ( int( origin_array[0] ), int( origin_array[1] ), int( origin_array[2] ) );
					startspawns[number] = spawn( "script_origin", origin );
					startspawns[number].origin = origin;
					startspawns[number].angles = ( 0, int( array[3] ), 0 );
					startspawns[number].team = team;
					startspawns[number].targetname = "mp_spawn_" + team + "_start";
					defineExtraSpawnpointArray( startspawns[number] );
					number++;
					break;

				default:
					break;
			}
		}
	}
	
	CloseFile( file );
	
	if( !startspawns.size )
		return( false );
	
	return( true );
}

defineExtraSpawnpointArray( spawnpoint )
{	
	if( !isdefined( level.extraSpawnpoints ) )
		level.extraSpawnpoints = [];
		
	if( !isdefined( level.extraSpawnpoints[spawnpoint.targetname] ) )
		level.extraSpawnpoints[spawnpoint.targetname] = [];
		
	level.extraSpawnpoints[spawnpoint.targetname][ level.extraSpawnpoints[spawnpoint.targetname].size ] = spawnpoint;
}


Here is the startspawns scriptdata file for mp_harbor:

Code:
mp_harbor
startspawns allies (-6565,-8492,67) 168
startspawns allies (-6584,-8641,74) 172
startspawns allies (-6594,-8758,68) 164
startspawns allies (-6593,-8843,71) 167
startspawns allies (-6698,-8842,71) 175
startspawns allies (-6701,-8727,70) 170
startspawns allies (-6710,-8603,64) 173
startspawns allies (-6728,-8494,61) 176
startspawns allies (-6823,-8487,60) 173
startspawns allies (-6827,-8630,60) 169
startspawns allies (-6830,-8755,63) 172
startspawns allies (-6815,-8856,59) 177
startspawns allies (-6911,-8848,56) 176
startspawns allies (-6904,-8735,62) 176
startspawns allies (-6913,-8618,66) 177
startspawns allies (-6921,-8522,61) 182
startspawns allies (-6842,-8568,57) 170
startspawns allies (-6728,-8897,62) 161
startspawns axis (-11800,-8379,59) 350
startspawns axis (-11792,-8280,63) 353
startspawns axis (-11775,-8138,72) 355
startspawns axis (-11784,-8019,81) 353
startspawns axis (-11682,-8033,59) 354
startspawns axis (-11684,-8146,58) 356
startspawns axis (-11684,-8265,57) 356
startspawns axis (-11684,-8368,57) 353
startspawns axis (-11579,-8383,57) 355
startspawns axis (-11580,-8247,58) 354
startspawns axis (-11580,-8111,58) 357
startspawns axis (-11578,-7963,54) 353
startspawns axis (-11578,-8029,57) 355
startspawns axis (-11666,-7962,59) 357
startspawns axis (-11781,-7943,72) 352
startspawns axis (-11484,-8248,63) 173
startspawns axis (-11478,-8127,60) 171
startspawns axis (-11489,-7985,55) 171


Here is the server startup .BAT file I use to test:

Code:
@echo off
@echo STARTING COD2
cd C:\Program Files (x86)\Activision\Call of Duty 2\
CoD2MP_s.exe +set fs_game test +set developer 1 +set developer_script 1 +exec dedicated.cfg +set sv_punkbuster 0 +map_rotate
@echo COMPLETE


The server is set to dedicated 0 - in other words a LISTEN SERVER.

Now, unless I am missing something, the code I just posted clearly shows that openFile( filename, "read" ) is used on a LISTEN SERVER:

Code:
file = OpenFile( filename, "read" );


Discuss.
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Sunday, Aug. 19, 2012 09:31 pm
Strange... i agreed the others (earlier testings), but lines and 3D-prints are dedi 0 only

but good job Tally =)
Share |
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Sunday, Aug. 19, 2012 10:36 pm
whats in dedicated.cfg? i only ask cause iv tested this many times and read will not work for me, even iznogod tested earlyer to try to prove me wrong and didnt work for him neither. is there something you are doing that we are missing???

actually maybe cause developer_script i havnt tested using that i dont think im not home right now to check that so later ill try to see unless someone has the answer to why his works and the rest of us it dosnt?
edited on Aug. 19, 2012 03:39 pm by liltc64
Share |
Tally
General Member
Since: Apr 21, 2005
Posts: 819
Last: Oct 26, 2012
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Sunday, Aug. 19, 2012 10:55 pm
liltc64 writes...
Quote:
whats in dedicated.cfg? i only ask cause iv tested this many times and read will not work for me, even iznogod tested earlyer to try to prove me wrong and didnt work for him neither. is there something you are doing that we are missing???

actually maybe cause developer_script i havnt tested using that i dont think im not home right now to check that so later ill try to see unless someone has the answer to why his works and the rest of us it dosnt?
edited on Aug. 19, 2012 03:39 pm by liltc64


Nothing is in dedicated.cfg which would affect the outcome, but if you want to see it, here it is:

Code:
set scr_domdebug 1

set sv_hostname "^1DemonMod"
set sv_maxclients "32"

set scr_motd ""

//
set sv_allowdownload "0"
seta sv_wwwDownload "1"
seta sv_wwwBaseURL ""
seta sv_wwwDlDisconnected "1"

// In-game voice communication system
set sv_voice "1"
set sv_voiceQuality "9"
set voice_deadChat "0"
set voice_global "0"
set voice_localEcho "0"
set winvoice_mic_mute "1"
//
set rcon_password ""
set g_password ""
set sv_privatepassword ""
set g_allowvote "1"

set logfile 2

// SHARED GAMETYPE DEFAULTS
set scr_friendlyfire		0
set scr_drawfriend		1
set scr_forcerespawn		1
set scr_killcam			0
set scr_spectatefree		1
set scr_spectateenemy		1
set scr_teambalance		1
set scr_graceperiod		5

set g_gametype "dom"
set sv_maprotationcurrent ""
set sv_maprotation "map mp_harbor map mp_carentan map mp_burgundy map mp_brecourt map mp_burgundy map mp_railyard map mp_brecourt map mp_railyard map mp_dawnville"


TBH, the COD2 modding community has been using the openFile( filename, "read" ) function successfully on Listen servers since the function was first discovered to be useful to modding back in early 2007 by Amway. Both the AWE and the eXtreme+ mod teams have been successfully getting it to work on Listen servers.

If you still don't believe me, just grab a copy of AWE Community edition mod, and run the Breakthrough gametype. That uses the "read" function. Just run the gametype on a Listen server and you will see it works fine.

Nedgerblansky - who wrote the Dvar Replacment module element using the file functions - used to always test on a Listen server. He never complained about not being able to use the "read" function. We have always known that it was a map rotation that killed the successful use of the functions. Nothing else.

BTW - it also has nothing to do with developer or developer_script.
Share |
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Monday, Aug. 20, 2012 10:07 am
no its not that i dont believe you i see you clearly using it. but i can go and do the same thing and read wont work for me unless dedicated is 1 or 2. and im still not seeing how it just works for you theres just has to be something you are doing that im missing? im just looking for an answer thats all, i see the proof just not an answer. when i test my mods i just simply start up cod and do /developer 1, /g_gametype "gametype",/devmap mp_carentan and test... and read simply does not work like that unless like iv been saying... dedicated 1 or 2. so whats the answer to that???[confused]
Share |
Tally
General Member
Since: Apr 21, 2005
Posts: 819
Last: Oct 26, 2012
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Monday, Aug. 20, 2012 10:36 am
liltc64 writes...
Quote:
no its not that i dont believe you i see you clearly using it. but i can go and do the same thing and read wont work for me unless dedicated is 1 or 2. and im still not seeing how it just works for you theres just has to be something you are doing that im missing? im just looking for an answer thats all, i see the proof just not an answer. when i test my mods i just simply start up cod and do /developer 1, /g_gametype "gametype",/devmap mp_carentan and test... and read simply does not work like that unless like iv been saying... dedicated 1 or 2. so whats the answer to that???[confused]


As I said, it isn't just me that can do it. You can run AWE Community edition and get Breakthrough gametype to work on a Listen Server, and it uses "read" to set up the flags for it.

I did that very thing - I wanted to see if my memory was failing me or something. So, I downloaded AWE Community edition yesterday from here:

http://callofduty.filefront.com/file/Additional_War_Effects;76452

And I ran a test Listen Server and the use of "read" for Breakthrough gametype worked fine. No problem at all.

Also, MeatBot - this is a mod which is heavily reliant on the use of the "read" file function. When developing waypoints for it, you MUST run a Listen server. So that again PROVES that the "read" function works on a Listen server.

Neither the developers for AWE Community Edition (of which I was a developer) nor the MeatBot mod make a note in any of the readme files saying that "read" file function does not work on a Listen server. And that's because we all got it working since 2007, and no one bumped into the problem while developing mods back then.

My only conclusion is that all you people that say you can't get "read" to work, that the fault must be the code in your mods. It is the only thing that can be causing "read" to fail. Everyone else since 2007 who has made use of the "read" function has successfully managed to use it on a Listen server. It is only a handful of you guys, on this forum now, here in 2012, who are insisting that it doesn't work. I suggest you go look at your code again, as we all managed to do it successfully.
Share |
Tally
General Member
Since: Apr 21, 2005
Posts: 819
Last: Oct 26, 2012
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Monday, Aug. 20, 2012 11:13 am
Additional Info:

I wanted to see if the use of "read" worked from the main folder, and wasn't reliant on an fs_game folder. So, I stuck my Domination mod, with its scriptdata folder, into the main folder.

I booted up the game to the main menu. From there, I dropped down console and typed:

/g_gametype dom

then:

/map mp_carentan

The game successfully launched, and the "read" function to set both the origins of the Dom flags, and to set the start spawns, worked perfectly. No problems at all.

Here is a video of it happening:



This demonstrates that the use of the "read" function is not reliant on an fs_game folder.
Share |
Sevenz
General Member
Since: Apr 24, 2006
Posts: 2390
Last: May 10, 2013
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Monday, Aug. 20, 2012 01:29 pm
i tried the openfile functions myself twice, but it failed just like for others here. I really don't know why, might depend on the surrounding code (similar to precache stuff, which has to be done before any wait command). However, i do believe that it actually works, as i played meatbot mod myself!

Tally: Do you know if writing works for CoD4 SP in dev mode?
Share |
Sevenz
General Member
Since: Apr 24, 2006
Posts: 2390
Last: May 10, 2013
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Monday, Aug. 20, 2012 01:34 pm
[doublepost]
Share |
Tally
General Member
Since: Apr 21, 2005
Posts: 819
Last: Oct 26, 2012
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Monday, Aug. 20, 2012 01:39 pm
Sevenz writes...
Quote:
i tried the openfile functions myself twice, but it failed just like for others here. I really don't know why, might depend on the surrounding code (similar to precache stuff, which has to be done before any wait command). However, i do believe that it actually works, as i played meatbot mod myself!

Tally: Do you know if writing works for CoD4 SP in dev mode?


1. I believe timing is critical to the file functions as long as you wait until a frame ends. So, if you are using any file function during a game, and not before a match has started, use the waittillframeend function before you run your functions.

2. As memory serves me, all the file functions work in COD4 dev mode. They just don't work outside of dev mode, like they do in COD2.

EDIT -

Hang on, I remember Perry Hart (of Pezbot) saying something to me about writing to a file even in dev mode. But I can't for the life of me remember what it was. I know that I tried it as soon as the mod tools were out, and I remember all of the functions working. Still, my memory isn't what it used to be.
Share |
Restricted Access Topic is Locked
Page
Previous Page Next Page
subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 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

»