0

I'm developing a mod for Quake2. When the level is changed, some stats are cleared and some are written to save game file.

My mod has a level system that affects the power of weapons, etc things.

But, then i encountered a problem. I want to save my character data to a file and then read it to restore the values on level change.

A Friend of mine said that i should use fwrite for writing the data.

fwrite (&ent->client->pers.lvl, sizeof(int), 1, fp);
fwrite(&ent->client->pers.exp, sizeof(int), 1, fp); 
fwrite(&ent->client->pers.money, sizeof(int), 1, fp);

But i dont have any idea how the read the data..I know the place where to read the data though.. So I'm requesting help on reading binary data.

(Also i dont know if i did something wrong in fwrite so someone can say a word or two about them for me)

Any help is welcome :)

2
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by Vms100
0

Any examples?

Also how can i read the level, exp and money variables from binary file?

0

>Any examples?
Click me!

>Also how can i read the level, exp and money variables from binary file?
Whoa, deja vu! To read a file you use the inverse of how you wrote the file. So instead of fwrite, use fread. Didn't I already say that?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.