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

Members Online

»
0 Active | 8 Guests
Online:

LATEST FORUM THREADS

»
water
CoD4 MP Mapping
Rainbow HELP....
CoD4 MP Mapping

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, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Restricted Access
Page
Next Page
subscribe
Author Topic: Reading a file
przemekh10
General Member
Since: Aug 16, 2012
Posts: 17
Last: Jan 28, 2013
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Saturday, Aug. 18, 2012 01:47 pm
How to read file in CoD2? For example guids.txt. I need to save guid list (line by line) and read it into cod2.
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Saturday, Aug. 18, 2012 04:45 pm
http://www.zeroy.com/script/file/closefile.htm
http://www.zeroy.com/script/file/fgetarg.htm
http://www.zeroy.com/script/file/fprintfields.htm
http://www.zeroy.com/script/file/fprintln.htm
http://www.zeroy.com/script/file/freadln.htm
http://www.zeroy.com/script/file/openfile.htm

Also
http://modsonline.com/Forums-top-146152.html
Share |
przemekh10
General Member
Since: Aug 16, 2012
Posts: 17
Last: Jan 28, 2013
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Sunday, Aug. 19, 2012 02:40 am
Doesnt work to me :( Don't know why.

Code:

filenum = OpenFile( "test.txt", "read" );

if (filenum != -1)
	{
		iprintlnbold("File openned!");
	}


I tried to put file test.txt everywhere. In:
cod2\
cod2\main\
cod2\main\scriptdata\

And still "filenum" returns "-1"
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 04:52 am
przemekh10 writes...
Quote:
Doesnt work to me :( Don't know why.

Code:

filenum = OpenFile( "test.txt", "read" );

if (filenum != -1)
	{
		iprintlnbold("File openned!");
	}


I tried to put file test.txt everywhere. In:
cod2\
cod2\main\
cod2\main\scriptdata\

And still "filenum" returns "-1"


are you testing on a local server? if you are testing localy the read function dosnt work. its stupid but yeah i had to learn that the hard way.
Share |
Mitch*
General Member
Since: Jan 23, 2007
Posts: 24
Last: Nov 10, 2012
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Sunday, Aug. 19, 2012 04:56 am
liltc64 writes...
Quote:
przemekh10 writes...
Quote:
Doesnt work to me :( Don't know why.

Code:

filenum = OpenFile( "test.txt", "read" );

if (filenum != -1)
	{
		iprintlnbold("File openned!");
	}


I tried to put file test.txt everywhere. In:
cod2\
cod2\main\
cod2\main\scriptdata\

And still "filenum" returns "-1"


are you testing on a local server? if you are testing localy the read function dosnt work. its stupid but yeah i had to learn that the hard way.


Indeed. Dedicated needs to be 2 or 1 (not sure). It seems reading fails when you test it locally. (I thought only writing works locally)

Edit: Always close the file when the filenum isn't -1. Otherwise this will cause your server to crash when a new map gets loaded.

edited on Aug. 19, 2012 05:03 am by Mitch*
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Sunday, Aug. 19, 2012 05:01 am
try to write instead. It should create the file. Find it :)
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 05:05 am
make sure to close the file to thats a big thing. always close the file when your done with it and you might want to use "append" instead of "write" when you are writing the file for your sake since your saving guids. and yeah you can only write on a local server but you cannot read unless you have dedicated 2
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 09:27 am
liltc64 writes...
Quote:
przemekh10 writes...
Quote:
Doesnt work to me :( Don't know why.

Code:

filenum = OpenFile( "test.txt", "read" );

if (filenum != -1)
	{
		iprintlnbold("File openned!");
	}


I tried to put file test.txt everywhere. In:
cod2\
cod2\main\
cod2\main\scriptdata\

And still "filenum" returns "-1"


are you testing on a local server? if you are testing localy the read function dosnt work. its stupid but yeah i had to learn that the hard way.


All the file functions work on a Local server for testing, you just can't map rotate, as then it doesn't work.

First map on a Local server = fine; second map = it fails.
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 11:07 am
Tally writes...
Quote:
liltc64 writes...
Quote:
przemekh10 writes...
Quote:
Doesnt work to me :( Don't know why.

Code:

filenum = OpenFile( "test.txt", "read" );

if (filenum != -1)
	{
		iprintlnbold("File openned!");
	}


I tried to put file test.txt everywhere. In:
cod2\
cod2\main\
cod2\main\scriptdata\

And still "filenum" returns "-1"


are you testing on a local server? if you are testing localy the read function dosnt work. its stupid but yeah i had to learn that the hard way.


All the file functions work on a Local server for testing, you just can't map rotate, as then it doesn't work.

First map on a Local server = fine; second map = it fails.


false, iv ran into this problem enough times to say thats not true. its true it wont work on the next map and crash if you do not close the file. but the read function in general will not work for a local server. prove me otherwise and please explain what you did to make it work if you can cause iv ran into it so many times.
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Sunday, Aug. 19, 2012 12:37 pm
Datapoint:


In dedicated 0:

All filereads fail.
All filewrites succeed.
All fieappends succeed.

In any other dedicated: (1 or 2)
All file operations succeed.

Good luck :)
Share |
Restricted Access Restricted Access
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Why console gaming is dying
Quote:Consider this: Dedicated gaming sales — including living-room consoles...
Devs: Games are being dumb...
Click 'read more' to view the contents of this post.
Loadout
Gun Crafting to the Max. edited on Sep. 25, 2012 06:57 pm by Morp...
Introducing the Source Fil...
Surprised this wasn't made a long time ago. Sounds like a nice little feature.
Introducing the Source Fil...
The Source Filmmaker (SFM) is the movie-making tool built and used by us he...

Partners & Friends

»