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 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
Next Page
subscribe
Author Topic: Reading a file
cod2coder
General Member
Since: Aug 16, 2012
Posts: 20
Last: Jan 10, 2016
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Saturday, Aug. 18, 2012 08: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 11: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 |
cod2coder
General Member
Since: Aug 16, 2012
Posts: 20
Last: Jan 10, 2016
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Sunday, Aug. 19, 2012 09: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 11: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 11: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 12:01 pm
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 12:05 pm
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 04:27 pm
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 06:07 pm
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 07: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 Topic is Locked
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

»